ROS Answers: Open Source Q&A Forum - RSS feedhttps://answers.ros.org/questions/Open source question and answer forum written in Python and DjangoenROS Answers is licensed under Creative Commons Attribution 3.0Wed, 06 May 2020 13:59:46 -0500How to get KDL solver to solve for 6D, and not 3D only.https://answers.ros.org/question/351415/how-to-get-kdl-solver-to-solve-for-6d-and-not-3d-only/Hi all,
I am trying to use KDL to calculate the inverse kinematics of a UR5 robot. I am using something like this
constexpr std::size_t num_joints = 6;
// initial guess of joint angles
KDL::JntArray joints_init;
joints_init.resize(num_joints);
// joints_init.data[0] = -0.5;
// joints_init.data[1] = -M_PI / 2;
// joints_init.data[2] = -M_PI / 2;
// joints_init.data[4] = M_PI / 2;
// joints_init.data[5] = 0.3;
/**********************************
* target robot pose of tool w.r.t.
*********************************/
KDL::Frame target_frame; // set desired end effector position
/***************************************************************************
* pose corresponding to [0, -PI/2, -PI/2, 0, PI/2, 0] according to TF
**************************************************************************/
KDL::Vector pos;
pos.data[0] = -0.675;
pos.data[1] = 0.1110;
pos.data[2] = 0.511;
// set desired end effector rotation
KDL::Rotation rot;
target_frame.p = pos;
target_frame.M = rot.RPY(-3.141, -1.568, -0.004);
KDL::JntArray joints_result;
joints_result.resize(num_joints);
std::cout << "Calling solver for IK!" << std::endl;
int status = ik_solver.CartToJnt(joints_init, target_frame, joints_result);
It seems that this works for the position only. I thought that the solver should solve for 6D also. Am I using this wrong? Does it only solve for position (3D) and not for the full pose(6D)?
Thanks!Mon, 04 May 2020 18:22:22 -0500https://answers.ros.org/question/351415/how-to-get-kdl-solver-to-solve-for-6d-and-not-3d-only/Answer by Nitesh_j for <p>Hi all,</p>
<p>I am trying to use KDL to calculate the inverse kinematics of a UR5 robot. I am using something like this</p>
<pre><code>constexpr std::size_t num_joints = 6;
// initial guess of joint angles
KDL::JntArray joints_init;
joints_init.resize(num_joints);
// joints_init.data[0] = -0.5;
// joints_init.data[1] = -M_PI / 2;
// joints_init.data[2] = -M_PI / 2;
// joints_init.data[4] = M_PI / 2;
// joints_init.data[5] = 0.3;
/**********************************
* target robot pose of tool w.r.t.
*********************************/
KDL::Frame target_frame; // set desired end effector position
/***************************************************************************
* pose corresponding to [0, -PI/2, -PI/2, 0, PI/2, 0] according to TF
**************************************************************************/
KDL::Vector pos;
pos.data[0] = -0.675;
pos.data[1] = 0.1110;
pos.data[2] = 0.511;
// set desired end effector rotation
KDL::Rotation rot;
target_frame.p = pos;
target_frame.M = rot.RPY(-3.141, -1.568, -0.004);
KDL::JntArray joints_result;
joints_result.resize(num_joints);
std::cout << "Calling solver for IK!" << std::endl;
int status = ik_solver.CartToJnt(joints_init, target_frame, joints_result);
</code></pre>
<p>It seems that this works for the position only. I thought that the solver should solve for 6D also. Am I using this wrong? Does it only solve for position (3D) and not for the full pose(6D)?</p>
<p>Thanks!</p>
https://answers.ros.org/question/351415/how-to-get-kdl-solver-to-solve-for-6d-and-not-3d-only/?answer=351626#post-id-351626In simple words 6d will have more flexibility on complex task and it will faster interms of calculating the position , velocity, I would suggest to go with ik fast from open rave ....or try the UR's Ur kinematics package to sort out the confusionWed, 06 May 2020 12:53:37 -0500https://answers.ros.org/question/351415/how-to-get-kdl-solver-to-solve-for-6d-and-not-3d-only/?answer=351626#post-id-351626Comment by Nitesh_j for <p>In simple words 6d will have more flexibility on complex task and it will faster interms of calculating the position , velocity, I would suggest to go with ik fast from open rave ....or try the UR's Ur kinematics package to sort out the confusion</p>
https://answers.ros.org/question/351415/how-to-get-kdl-solver-to-solve-for-6d-and-not-3d-only/?comment=351642#post-id-351642All the bestWed, 06 May 2020 13:59:46 -0500https://answers.ros.org/question/351415/how-to-get-kdl-solver-to-solve-for-6d-and-not-3d-only/?comment=351642#post-id-351642Comment by Pinknoise2077 for <p>In simple words 6d will have more flexibility on complex task and it will faster interms of calculating the position , velocity, I would suggest to go with ik fast from open rave ....or try the UR's Ur kinematics package to sort out the confusion</p>
https://answers.ros.org/question/351415/how-to-get-kdl-solver-to-solve-for-6d-and-not-3d-only/?comment=351639#post-id-351639Thanks for the answer. I've figured a much better solution after being disappointed with how KDL IK solver performed. My solution was to switch to the symbolic version of the IK by using the ur_kinematics ROS package from [https://github.com/ros-industrial/universal_robot](https://github.com/ros-industrial/universal_robot). It now works like a charm, returns a max of 8 solutions, and always work.Wed, 06 May 2020 13:53:27 -0500https://answers.ros.org/question/351415/how-to-get-kdl-solver-to-solve-for-6d-and-not-3d-only/?comment=351639#post-id-351639