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, 13 Jul 2016 04:25:03 -0500Cart Controller help!https://answers.ros.org/question/239417/cart-controller-help/Hi!
I am making a cart controller. The idea is using a delta of time, iterate a given number of times to converge to the desired position. So the set parameters are dt (delta time) and N (iterations)
This is the made steps
1. Get the desired task positions
2. Get the actual joint positions
3. Calculate jacobian for actual joint position
4. Calculate actual task position for the joint position
5. Calculate the error (for position and orientation)
6. Divide the error by delta time to get velocity in task space.
7. Using the jacobian and the velocity in task space, calculate the velocity in joint space.
8. Using the velocity in joint space and the delta of time, calculate the necessary (new) joint positions.
9. Iterate from 3 to 8 a number of times.
My variables are:
KDL::JntArray q_ (actual joint positions)
KDL::Frame x_des (the desired task position)
KDL::Frame x_s; (Task positions calculations)
KDL::JntArray q_ (joint positions calculations)
KDL::Jacobian J_ (jacobian)
KDL::Twist xerr_ (Task space error)
KDL::Twist xdot_s (Task space velocity)
Now this is the algoritm.
----------
...
q_s=q_;
k=0;
while(!k>iter){
k++;
jnt_to_jac_solver_->JntToJac(q_s, J_); //Calculate jacobian for joint position
jnt_to_pose_solver_->JntToCart(q_s, x_s); //Calculate task position for the joint position
xerr_.vel = x_des.p-x_s.p; //Calculate the error for position
xerr_.rot = 0.5 * (x_des.M.UnitX() * x_s.M.UnitX() + x_des.M.UnitY() * x_s.M.UnitY() + x_des.M.UnitZ() * x_s.M.UnitZ());
//Calculate the error for orientation
xdot_s.vel = xerr_.vel/dt; //Divide the error by dt to get xdot_s
**xdot_s.rot = xerr_.rot/dt; //Divide the error by dt to get xdot_s**
qdot_s=f(xdot_s,J_); //Then using xdot_s, and the jacobian, I calculate qdot_s
q_s=q_s+dt*qdot_s; //New joint position
----------
The problem is that using that it doesn't perform well. I have check that it works when I don't use the error of rotation to calculate xdot_s (that happens when I comment the Bold line in my code). So I'm pretty sure I am not calculating well the error in rotation (and so the velocity in task space).
Could someone of you please help me?
Thank you so much.Wed, 13 Jul 2016 04:15:51 -0500https://answers.ros.org/question/239417/cart-controller-help/Comment by gvdhoorn for <p>Hi!</p>
<p>I am making a cart controller. The idea is using a delta of time, iterate a given number of times to converge to the desired position. So the set parameters are dt (delta time) and N (iterations)</p>
<p>This is the made steps</p>
<ol>
<li>Get the desired task positions</li>
<li>Get the actual joint positions</li>
<li>Calculate jacobian for actual joint position</li>
<li>Calculate actual task position for the joint position</li>
<li>Calculate the error (for position and orientation)</li>
<li>Divide the error by delta time to get velocity in task space.</li>
<li>Using the jacobian and the velocity in task space, calculate the velocity in joint space.</li>
<li>Using the velocity in joint space and the delta of time, calculate the necessary (new) joint positions.</li>
<li>Iterate from 3 to 8 a number of times.</li>
</ol>
<p>My variables are:</p>
<p>KDL::JntArray q_ (actual joint positions)</p>
<p>KDL::Frame x_des (the desired task position)</p>
<p>KDL::Frame x_s; (Task positions calculations)</p>
<p>KDL::JntArray q_ (joint positions calculations)</p>
<p>KDL::Jacobian J_ (jacobian)</p>
<p>KDL::Twist xerr_ (Task space error)</p>
<p>KDL::Twist xdot_s (Task space velocity)</p>
<p>Now this is the algoritm.</p>
<hr>
<p>...</p>
<p>q_s=q_;</p>
<p>k=0;</p>
<p>while(!k>iter){</p>
<p>k++;</p>
<p>jnt_to_jac_solver_->JntToJac(q_s, J_); //Calculate jacobian for joint position</p>
<p>jnt_to_pose_solver_->JntToCart(q_s, x_s); //Calculate task position for the joint position</p>
<p>xerr_.vel = x_des.p-x_s.p; //Calculate the error for position</p>
<p>xerr_.rot = 0.5 * (x_des.M.UnitX() * x_s.M.UnitX() + x_des.M.UnitY() * x_s.M.UnitY() + x_des.M.UnitZ() * x_s.M.UnitZ());
//Calculate the error for orientation</p>
<p>xdot_s.vel = xerr_.vel/dt; //Divide the error by dt to get xdot_s</p>
<p><strong>xdot_s.rot = xerr_.rot/dt; //Divide the error by dt to get xdot_s</strong> </p>
<p>qdot_s=f(xdot_s,J_); //Then using xdot_s, and the jacobian, I calculate qdot_s</p>
<p>q_s=q_s+dt*qdot_s; //New joint position</p>
<hr>
<p>The problem is that using that it doesn't perform well. I have check that it works when I don't use the error of rotation to calculate xdot_s (that happens when I comment the Bold line in my code). So I'm pretty sure I am not calculating well the error in rotation (and so the velocity in task space).</p>
<p>Could someone of you please help me? </p>
<p>Thank you so much.</p>
https://answers.ros.org/question/239417/cart-controller-help/?comment=239419#post-id-239419ROS does make use of [KDL](http://www.orocos.org/kdl) in various places, but you might get better answers on a more appropriate mailing list / forum. For KDL, I think that could be [orocos-users](https://ls.kuleuven.be/cgi-bin/wa?SUBED1=OROCOSUSERS&A=1).Wed, 13 Jul 2016 04:25:03 -0500https://answers.ros.org/question/239417/cart-controller-help/?comment=239419#post-id-239419