Implement the Inverse kinematics in the repository#229
Conversation
|
IB-IK in BLF @lrapetti @paolo-viceconte @Yeshasvitvs @claudia-lat |
f5670c5 to
1054f67
Compare
320443d to
66473a0
Compare
|
Implementation finished! The PR is ready to be reviewed |
S-Dafarra
left a comment
There was a problem hiding this comment.
Some initial comments
| m_pimpl->upperBound.segment(index, constraint.get().task->size()) = b; | ||
| m_pimpl->constraintMatrix.middleRows(index, constraint.get().task->size()) = A; | ||
|
|
||
| index += constraint.get().task->size(); |
There was a problem hiding this comment.
Maybe it is worth adding an assert, in the end, to check that no constraint has changed size.
There was a problem hiding this comment.
Note that it would be enough to check if at the end index is equal to the total number of constraints. You cannot know which constraint increased in dimension, but you know that at least one did.
| * InverseKinematics implements the interface for the inverse kinematics. Please inherits this class | ||
| * if you want to implement your custom IK. | ||
| */ | ||
| class InverseKinematics : public BipedalLocomotion::System::Advanceable<IKState> |
There was a problem hiding this comment.
This seems something that gives in output the robot velocity, so could it make sense to call it VelocityInverseKinematics , to distinguish it from the position-based inverse kinematics?
| REQUIRE(ikAndTasks.ik->get().jointVelocity.isApprox(iDynTree::toEigen(jointsVel), tolerance)); | ||
| REQUIRE(desiredCoMVelocity.isApprox(iDynTree::toEigen(kinDyn->getCenterOfMassVelocity()), tolerance)); | ||
| REQUIRE(desiredVelocity.isApprox(iDynTree::toEigen(kinDyn->getFrameVel(controlledFrame)), tolerance)); |
There was a problem hiding this comment.
To be honest, I am not sure if this is checking if the QPIK is working. You are initializing it already in the solution when setting the robot state in line 149, right?
There was a problem hiding this comment.
Right. Do you have in mind a possible idea to write a better test?
There was a problem hiding this comment.
It really depends on what you want to test 😉
There was a problem hiding this comment.
As discussed F2F I reimplemented the test in df1e11f
Here I run the IK sequentially and I check that the solution converged to the desired one. The tests run in three different models automatically generated by iDynTree.
While I was writing the test I noticed that osqp-eigen does not support unconstrained optimization problems. This is actually a limitation since we may want to consider all the tasks in the cost function (If I'm not mistaken the AnDy ik works in this way @lrapetti )
There was a problem hiding this comment.
Is it a limitation of osqp or osqp-eigen? It may be worked around with some box constraints on the control variables, eventually with large (but not infinite) bounds.
There was a problem hiding this comment.
While I was writing the test I noticed that osqp-eigen does not support unconstrained optimization problems. This is actually a limitation since we may want to consider all the tasks in the cost function (If I'm not mistaken the AnDy ik works in this way @lrapetti )
I am not sure why you are making this decision to avoid using constraint in IK.
Since a constraint is ensured to be respected (with a good sampling time), while a soft constraint added to the task can be violated. Anyhow, as far as I remember and logically, you should be able to solve the optimization problem without constraints as well.
There was a problem hiding this comment.
That's just a possible implementation. It has pros and cons. For example, you may decide to use no constraints so that you are sure you always get a solution, even if you have two completely contradictory tasks.
There was a problem hiding this comment.
Note that in a manifold, if you have a set of constraints such that the possible space of your solution is not empty, it should retrieve a best solution as a result, and it is the task of the designer to do not fix such contradictory constraints!
There was a problem hiding this comment.
and it is the task of the designer to do not fix such contradictory constraints!
You should not trust anyone 😁
Jokes apart, one thing is what you should do or not, another thing is a limitation introduced by the software. You should not justify a flaw in the design with the excuse that the corresponding use cases are not good enough.
There was a problem hiding this comment.
|
To be honest I found a bit difficult to understand what the InverseKinematics interface was just from the docs, so I tried to sketch a diagram (always remembering that every system can be thought in terms of inputs/outpus/state/parameters) of a possible use of this class (possible because the use can be different in other contexts, for example I guess @lrapetti use case is different and he just integrates the IK output to obtain the position). For the task I made an example of just a single non-Lie group task, but I think that is ok for keeping the diagram small. (raw diagram: In this diagram, the logic that is exposed by the My doubts are the following:
|
|
Hi @traversaro
We can also rename it in
The inverse kinematics is strictly related to
The
In the |
Good point!
Yes, I think that a description like this in the description of some setKinDyn method would be great.
Good idea, it clearly conveys the message that the output is output is the robot velocities that needs to be integrated. |
As per t2t discussion, tipically only the joint part of the vector is taken and the base is ignored, because the tasks of the QP are such that the velocities are compatible with the active contact constraints. |
e5d24ee to
2e99078
Compare
|
For the sake of completeness, I add the two schemes that explain how the class can be used. The IK component can actually be used as Velocity controller or real IK. Indeed it is important to notice that Here you can find an example of the IK component used as a velocity controller Here you can find an example of the IK component used as inverse kinematics. In this case, the Here the updated blocks ExplanationWalkingIK.zip I added this explanation in the doxygen documentation 4f8b58e cc @traversaro |
|
Here two updated images: |






This PR implements the InverseKinematics component in the repository.
In details, it introduces the class
taskand the interfaceinverse kinematics,The
taskdescribes a generic task that can be handled in inverse kinematics. I also implemented 4 concrete classes that describe different tasks Namelly:SE3Task: a task that ensures the tracking of a cartesian trajectorySO3Task: it ensures the tracking of the desired orientationJointsTrackingTask: it ensures the tracking of a desired joint configuration. (You can use it as a regularization factor)CoMTask: it ensures the tracking of the CoMOnce the user has a list of tasks the user can build the inverse kinematics with the
InverseKinematicsinterface.I also implemented a
QPInverseKinematicsclass. This is a concrete implementation of an integration base IK. In this specific implementation, I usedosqp-eigento solve theikproblem.I also implemented some tests.
The PR is ready to be reviewed @traversaro @S-Dafarra.