jiminy
jiminy copied to clipboard
[core] Add force getter to AbstractConstraint
virtual pinocchio::Force computeForce(pinocchio::ReferenceFrame rf) const = 0;
How to handle the case where spatial force is not meaningful ?
Two options:
- [1] Return an exception if not implemented by default to make it optional.
- [2] Provide a lower-level abstract constraint class that it providing this extra method.
[1] goes against the concept of abstract class if some method cannot be called for derived classes, which is bad. While [2] makes it impossible to call computeForce
without performing a static cast on AbstractConstraintBase
.
I suggest going into the direction of [2]. However, constraintsHolder_t
should be refactor to stop handling constraints only through the base class AbstractConstraintBase
and instead storing the actual type. To do this properly, it requires the use of visitors and CRTP pattern.
A similar issue arises for being able to set the normal for contact constraints. Maybe an abstract class ContactConstraintBase
dedicated to contact constraints should be added.