Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Change robot's configuration through API C++
#1
Hi,

Is it possible to change robot's configuration (Front/Up/Positive) through C++ API?
I know I can read the configuration using 

tConfig config;

ROBOT->JointsConfig(ROBOT->Joints(),config);

But I want to change the config, for example only elbow down, but still be confident that the robot EE has the same Cartesian pose as before!
#2
You should do something like this:

Code:
// Calculate all available solutions:
tJoints joints = ROBOT->Joints();
QList<tJoints> joints_list = ROBOT->SolveIK_All(ROBOT->SolveFK(joints));

// Iterate over all available solutions:
for (int i=0; i<joints_list.length(); i++){
    // Choose your preferred robot joints
    tConfig jnts_config;
    ROBOT->JointsConfig(joints_list[i], jnts_config);
}

// Set your preferred/optimal robot joints:
ROBOT->setJoints(new_joints);
#3
(01-28-2020, 10:58 PM)Albert Wrote: You should do something like this:

Code:
// Calculate all available solutions:
tJoints joints = ROBOT->Joints();
QList<tJoints> joints_list = ROBOT->SolveIK_All(ROBOT->SolveFK(joints));

// Iterate over all available solutions:
for (int i=0; i<joints_list.length(); i++){
    // Choose your preferred robot joints
    tConfig jnts_config;
    ROBOT->JointsConfig(joints_list[i], jnts_config);
}

// Set your preferred/optimal robot joints:
ROBOT->setJoints(new_joints);

Hi Albert,

I did exactly as you said. now I get an unexpected problem. I have debugged and it seems like  SolveIK_All sometimes fails.


So when I run this code, sometimes (strangely) I get one of these messages:
Communication problems with the RoboDK API
or sometimes
RoboDK API ERROR: " "

I tried it on two other machines. In one (more powerful) it didn't happen. In another (less powerful) it happened, maybe even more often. That's why I thought maybe it is a timeout problem? I am not sure.

Moreover, I am solving IK in a loop for 136 times. Sometimes, it shows one of these message once and then keeps working as nothing happened, but then after 5+ calls to SolveIK_All, it crashes with these messages.

Here is a snippet of the code:


Code:
   tJoints newJoints = ROBOT->Joints();
   cout << " Solve-all-started " ;
   QList<tJoints> joints_list = ROBOT->SolveIK_All(ROBOT->SolveFK(newJoints));
   cout << "done " ;
   tConfig jnts_config;
   // Iterate over all available solutions:
   for (int i=0; i<joints_list.length(); i++){
       cout << "Choose-config " ;
       // Choose your preferred robot joints
       ROBOT->JointsConfig(joints_list[i], jnts_config);
       if (jnts_config[0]==0 && jnts_config[1]==0){
           // Set your preferred/optimal robot joints:
           *jointResult = joints_list[i];
           break;
       }
   }
   cout << "Set-joints " ;
   ROBOT->setJoints(currentJoints);
   
   return true;
 And summery of the results after many tries:

   
As it can be seen, after 9th target it cannot communicate, therefore no configuration is desirable and then it goes to target 10 and 11 with dragging the problem and finally it crashes.


here,
   
the error shows up after target 107 once and after that everything works and finally with no problem the code continues.


here,
   
the error shows up after 11 and 17 and not problem all the way to 45 that it crashes!


As it can be seen, the problem happens after "Solve-all-started" and before "done".

Do you have any idea why this is happening?
#4
This is probably a bug. It would be great if you can you provide a Qt project that shows this issue and the RDK file.
  




Users browsing this thread:
1 Guest(s)