Add methods to compute the Jacobian of a rigid contact point - #386
Add methods to compute the Jacobian of a rigid contact point#386kbonnet001 wants to merge 10 commits into
Conversation
add methods to compute jacobian of rigid contact point
pariterre
left a comment
There was a problem hiding this comment.
That seems about right
Can you add Test for this please.
At some point, we probably want a proper python wrapper around the contacts too. If you want to tackle this, let me know, I can help you start the process!
@pariterre reviewed 2 files and all commit messages, and made 7 comments.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on kbonnet001).
src/RigidBody/Contacts.cpp line 273 at r1 (raw file):
} size_t BIORBD_NAMESPACE::rigidbody::Contacts::contactId(
That seems to be the internal biorbd id
src/RigidBody/Contacts.cpp line 455 at r1 (raw file):
updateKin ? &Q : nullptr); utils::Matrix J = updatedModel.CalcPointJacobian(
from that point, it should be:
return rigidContactJacobian(updatedMode, Q, idx); (and contact few lines prior can be removed)
src/RigidBody/Contacts.cpp line 401 at r1 (raw file):
} utils::Matrix BiorbdEigen3::rigidbody::Contacts::projectContactJacobian(
Is this because if a contact is declared on one or two axes, the contactJacobian returns a 3xN matrix regadless? If so, I feel that this method can be fused with the contactJacobian and simply add a flag "bool keepAxes = true" would do the trick.
EDIT: I just had a look and biorbd does not interface the contact Jacobian, so I assume you are calling the RBDL method to get the jacobian? If so, I suggest we create a dedicate contactJacobian in biorbd (so without the "project" in the name) and it returns the expected jacobian matrix (with the flag for keepAxes). This would be similar to markersJacobian in Markers.cpp.
RE-EDIT: Okay so "rigidContactJacobian" is actually what I was referring to in the first "EDIT". As I understand it, projectContactJacobian should not be called by the user as it is more a utility method than anything else. So in the header file, the method should be surrounded by:
protected:
// DOC
methodName(...)
public:This last edit is the only thing that should be done regarding this long comment (I keep my reasoning here just in case though)
src/RigidBody/Contacts.cpp line 490 at r1 (raw file):
for (size_t idx = 0; idx < nbRigidContacts(); ++idx) { const auto& contact = rigidContact(idx);
The inner for-loop could be simplified by:
G.push_back(rigidContactsJacobian(updatedModel, Q, idx));
include/RigidBody/Contacts.h line 200 at r1 (raw file):
/// \throw std::runtime_error if the contact does not exist /// size_t contactId(const utils::String& name) ;
Is there a reason to access contactId? They can be confusing... because there is basically two id types accross biorbd: the internal biorbd ids and the rbdl ids. They can match or not... (I can't remember for the contacts right now)
If it is necessary, and the current ids are for biorbd (as opposed to rbdl), then there is nothing to change. If however this is the rbdl id, change the name for "contactRbdlId"
include/RigidBody/Contacts.h line 370 at r1 (raw file):
/// \return Vector of Jacobians for all rigid contacts (projected onto active axes) /// std::vector<utils::Matrix> rigidContactsJacobian(
Swap this overload with the next, so it is consistent with the previous block
pariterre
left a comment
There was a problem hiding this comment.
@pariterre made 2 comments.
Reviewable status: all files reviewed, 8 unresolved discussions (waiting on kbonnet001).
src/RigidBody/Contacts.cpp line 401 at r1 (raw file):
} utils::Matrix BiorbdEigen3::rigidbody::Contacts::projectContactJacobian(
BiorbdEigen3 is the wrong namespace as it won't work with the Casadi Backend. you should use BIRORBD_NAMESPACE which automatically takes the value the is required
src/RigidBody/Contacts.cpp line 416 at r1 (raw file):
for (size_t i = 0; i < 3; ++i) { if (axes[i]) { Jout.row(r++) = J.row(i);
The test currently fail here, but for now, I suspect it is because of the namespace naming discussed earlier
|
@kbonnet001 |
|
Thanks @pariterre for your comments :) Below are the different fixes and some explanations:
I will take a one-month break and continue adding tests in September. |
pariterre
left a comment
There was a problem hiding this comment.
Have a good break :)
@pariterre reviewed 7 files and all commit messages, made 1 comment, and resolved 8 discussions.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on kbonnet001).
Add several methods to the
Contactsclass:contactId: returns the index of a contact from its name.
rigidContactJacobian (and its 3 overloads): similar to
markersJacobianimplemented in theMarkersclass, these functions compute the Jacobian of a rigid contact point. TheremoveAxisparameter has been removed because it modifies the position of the contact point, which is not the intended behavior. Instead, we only want to ignore axes that are not active without altering the geometry of the point.projectContactJacobian: this method has been added to preserve only the active axes of the contact point Jacobian. It performs the projection of the full 3D Jacobian onto the set of active contact directions.
"axis xy", only the rows corresponding to the x and y directions are kept (i.e., rows[:2, :]of the full Jacobian).This change is