Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

OPC UA setJointsStr not working

#1
Hi,

 
   We are experimenting with RoboDK OPCUA-server. We are able to transfer StationParameters and StationValues between UAExpert and RoboDK and also we can retrieve current position of robot by calling method getJointsStr. But when calling method setJointsStr we get “succeeded” but robot does not actually move, what might be the problem?


String is: -26.260000, -100.000000, 27.470000, 114.000000, -54.280000, 0.000000


   



Tero
#2
Hi Tero,

Using setJointsStr should place the robot at the given joint position without simulating a movement. Also, if the joints you provide are outside the robot limits it is possible that the values will be saturated to show the robot limitations (Fanuc has a virtual coupling for joints 2 and 3).

Albert
#3
Hi,   

I have been trying to use values received from robot with getJointsStr. So it should be within limits of robot. I have also tried using different robot Kuka KR6 but no luck with that either.

Tero


Quote:Hi Tero,

Using setJointsStr should place the robot at the given joint position without simulating a movement. Also, if the joints you provide are outside the robot limits it is possible that the values will be saturated to show the robot limitations (Fanuc has a virtual coupling for joints 2 and 3).

Albert
#4
Hi,

   Are you sure this is not a bug? I did following mods to OPC-UA server code and now it works, BUT still robot position is not updated before I click "View -> Fit all".

       






(02-18-2021, 10:28 AM)Albert Wrote: Hi Tero,

Using setJointsStr should place the robot at the given joint position without simulating a movement. Also, if the joints you provide are outside the robot limits it is possible that the values will be saturated to show the robot limitations (Fanuc has a virtual coupling for joints 2 and 3).

Albert
#5
Problem was that double values from string_2_doubles was used with setJoints tJoints needs to be used instead. Here is quick hack that makes it work:

static UA_StatusCode setJointsStr(void *h, const UA_NodeId objectId, size_t inputSize, const UA_Variant *input, size_t outputSize, UA_Variant *output) {
   PluginOPCUA *plugin = (PluginOPCUA*)h;
   if (inputSize < 2){
       qDebug()<<"Input size: " << inputSize << "  Output size: " << outputSize;
       return UA_STATUSCODE_BADARGUMENTSMISSING;
   }

   QString str_item;
   QString str_joints;
   if (!Var_2_Str(input+0, str_item)){
       return UA_STATUSCODE_BADARGUMENTSMISSING;
   }
   if (!Var_2_Str(input+1, str_joints)){
       return UA_STATUSCODE_BADARGUMENTSMISSING;
   }

  // ShowMessage(plugin, QObject::tr("item is: %1").arg(str_item));
   ShowMessage(plugin, QObject::tr("position is: %1").arg(str_joints));

   Item item = plugin->RDK->getItem(str_item);
   ShowMessage(plugin, QObject::tr("item is: %1").arg(item->Name()));

   if (!plugin->RDK->Valid(item)){ //if (!ItemValid(robot)){
       ShowMessage(plugin, QObject::tr("setJointsStr: RoboDK Item provided is not valid"));
       return UA_STATUSCODE_BADARGUMENTSMISSING;
   }
   double joints[nDOFs_MAX];
   item->Joints().GetValues(joints);
   int numel = nDOFs_MAX;
   ShowMessage(plugin, QObject::tr("Num joint is: %1").arg(numel));
   string_2_doubles(str_joints, joints, &numel);
   if (numel <= 0){
       ShowMessage(plugin, QObject::tr("setJointsStr: Invalid joints string"));
       return UA_STATUSCODE_BADARGUMENTSMISSING;
   }
   ShowMessage(plugin, QObject::tr("joint 1 is: 3"));
   tJoints joints2 = item->Joints();

   for(int o=0; o < nDOFs_MAX ;o++){   //double values from array cannot be used directly we need to use tJoints instead
       joints2.Data()[o] = joints[o];
       ShowMessage(plugin, QObject::tr("Joint%1 is: %2").arg(o).arg(joints2.Data()[o]));
   }

   bool can_move = item->MoveJ(joints2);
   if (!can_move){
       ShowMessage(plugin, QObject::tr("The robot can't move to this location"));
   }
else {

   item->setJoints(joints2);
   //Sleep(200);
   plugin->RDK->Render();}

   return UA_STATUSCODE_GOOD;
}
  




Users browsing this thread:
1 Guest(s)