-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
External torque estimation, URDF refining #41
External torque estimation, URDF refining #41
Conversation
Added (not working yet) estimation of cartesian wrench on end effector based on the estimated external torque and the jacobian. This should theoretically work, but does not (yet). The reason may be that the dynamic model is still totally wrong, and even if the estimated external torques look good, they lead to totally faulty computations. |
@marcoesposito1988 how are you doing with this? |
@carlosjoserg: apparently getting closer. I am playing with weights to test the force estimation, and the results are less absurd after the last commit. I am trying to understand if there is still a systematic error, and if this can be removed. Of course the dynamic model is just a guess, so there could be endless improving on that side. But I hope that the maths and the code are right. |
@carlosjoserg: from these preliminary tests (done by attaching a ~1Kg mass with a rope) I get quite consistent results.. at least, as consistent as they can be given a ~1N noise on each joint. In particular the noise of the first joints is multiplied by the length of the arm, so this can have a very big impact on the performance. For debugging I also included the estimated external force in the robot base reference frame, and I compared the result to the estimated weight-force of the attached object to the force along Z. The value never exited the range 12-16N. Most importantly, this even held at singular positions (where the internal torque_tcp_est variable completely got crazy). If you are interested I can also commit the estimation in the base reference frame. |
But the dynamic model shouldn't affect for a wrench estimation at the TCP if the robot is still, right? Or are you estimating while moving?
This is nice.
I don't know how yet, but it would be nice if one can just ask the estimated wrench at any frame in the arm, not necessarily the TCP, and also express everything at any requested reference frame as well. Oly that probably this would need a tf listener. |
As of now I am only experimenting while keeping the robot still, yes. But I might use this with the robot moving as well in the future. What I meant is that the round numbers we put in the URDF might differ for very small quantities from the actual values, which may lead to bigger error in the final estimation. Still, the more I play with this, the happier I am. The torque still looks a bit overestimated, but the cartesian force looks really proper. Computing at arbitrary reference frames would require a TF listener and maybe a service; I would rather put this in an external node. Still, we might publish the force in the two most important frames, i.e. tool and base. What do you think? |
Agree |
for (unsigned i = 0; i < joint_handles_.size(); i++) { | ||
(*joint_position_)(i) = joint_handles_[i].getPosition(); | ||
(*joint_velocity_)(i) = joint_handles_[i].getVelocity(); | ||
(*joint_acceleration_)(i) = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The velocity is obtained by derivation of the position, and then smooth filtering, why don't you do the same for the acceleration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I'm lazy 😇
I added it. Does it look correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean like the whole approach?
Yes, sure, I don't exactly how the KDL solver works, it looks like it gives you all wrenches at all links directly, wonderful.
int ret = id_solver_->CartToJnt(*joint_position_, | ||
*joint_velocity_, | ||
*joint_acceleration_, | ||
*joint_wrenches_, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I'm reviewing still...
According to the api, this joint_wrenches_ is an input, right? Where do you update it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose you are using joint_wrenches_= 0 always, so it is just to estimate the torque at the joints from the model, is that it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If so, I think that the class you should use is ChainDynParam, I couldn't find a forward dynamic solver.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I use the inverse dynamics solver to find the expected joint torques given the current position, velocity and acceleration of the robot. Then I subtract the expected from the measured joint torques to find the estimated external joint torques.
So joint_wrenches is input, and I set it to zero to find the expected joint torques when there is no object applying a force on the robot.
I think that the inverse dynamics solver is a higher-level solver than ChainDynParam, and is closer to what we want. Or do you see any problem with this approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's fine, I was just wondering that if you never consider external forces (joint_wrenhes_ = 0), perhaps there was no need to use the solver, because you are not actually solving neither a FD nor an ID problem, also because the motion is measured not planned, but the numbers are the same as in an ID problem.
So, as you wish, no problem, let me know when to merge.
Though, I'd change the var name in case we ever use it, since it is not joint wrenches as if the joint generated the wrenches, but wrenches at the segments, I believe expressed in the corresponding joint frame from this, it doesn't say that, only:
f_ext The external forces (no gravity) on the segments Output parameters:
anyways, it is zero in our case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I'm still playing with it because today I get very crappy performance out of the controller. I don't know if I changed something wrong; in the meantime I realised that I was computing the acceleration in a very wrong way 😇 so I fixed it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I might have found the reason.. I think that the numerical stability was due to using the damped pseudo-inverse of the Jacobian. Somehow the change did not make it into the git commit.
I would say that we can test it a bit more, and then merge it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I think this is the best we can get. Compared to the internal KRL variable named "torque_tcp_est", forces are a bit underestimated, but the controller is way less noisy when no external force is acting on the robot. It also does not get crazy at singularities. So I would vote for merging. |
You may want to have a look at the masses in the following document, they improve the estimation for me over the current values and also over the ones suggested in this PR. |
This pull request contains:
The current status is a precision in estimating external torques around +/-1.5Nm, with no tool attached to the robot. In other words, the maximum torque that is estimated for the robot with nothing attached in various positions is +/-1.5Nm. This should be a good starting point, since the internal torque estimation of the Kuka controller also has a comparable precision.