RoboDK Forum
Change robot's configuration through API C++- Printable Version

+- RoboDK Forum (//www.sinclairbody.com/forum)
+-- Forum: RoboDK (EN) (//www.sinclairbody.com/forum/Forum-RoboDK-EN)
+--- Forum: RoboDK API (//www.sinclairbody.com/forum/Forum-RoboDK-API)
+--- Thread: Change robot's configuration through API C++ (/Thread-Change-robot-s-configuration-through-API-C)



Change robot's configuration through API C++-mFarzanehkaloorazi-01-28-2020

Hi,

Is it possible to change robot's configuration (Front/Up/Positive) through C++ API?
我知道我可以阅读配置使用

tConfigconfig;

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!


RE: Change robot's configuration through API C++-Albert-01-28-2020

You should do something like this:

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

// Iterate over all available solutions:
for (int i=0; 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);



RE: Change robot's configuration through API C++-mFarzanehkaloorazi-01-31-2020

(01-28-2020, 10:58 PM)Albert Wrote:You should do something like this:

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

// Iterate over all available solutions:
for (int i=0; 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 likeSolveIK_Allsometimes fails.


So when I run this code, sometimes (strangely) I get one of these messages:
CommunicationproblemswiththeRoboDKAPI
or sometimes
RoboDKAPIERROR:" "

I tried it on two other machines. In one (more powerful) it didn't happen. In another (less powerful) it happened,maybeeven 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 joints_list = ROBOT->SolveIK_All(ROBOT->SolveFK(newJoints));
cout << "done " ;
tConfig jnts_config;
// Iterate over all available solutions:
for (int i=0; icout << "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?


RE: Change robot's configuration through API C++-Albert-01-31-2020

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.