Skip to content
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

Feature request : Supply axis index when specifying mimic joint. #1684

Open
adityapande-1995 opened this issue Nov 17, 2022 · 3 comments
Open
Assignees
Labels
status: in-progress tag: feature request Indicates new feature requests

Comments

@adityapande-1995
Copy link

Is your feature request related to a problem? Please describe.
When specifying mimic joint (https://dartsim.github.io/dart/main/d6/d5b/classdart_1_1dynamics_1_1Joint.html#ae65b6209299935e602b675f84091c499)

 void dart::dynamics::Joint::setMimicJoint( 
        const Joint* _mimicJoint, double _mimicMultiplier, double _mimicOffset)

Only the joint pointer, multiplier, and offset are supplied to the method. The section here : (

assert(joint->getNumDofs() == mimicJoint->getNumDofs());
) dictates that the degrees of freedom for both axes should be the same.

This does not allow mimicking individual axes of a multi-axis joint, such as enabling a revolute joint to mimic one axis of an universal joint, or have an universal joint mimic only one axis of another universal joint. In such cases, it should be permitted to specify the axis index to be mimicked for each joint, and expand the implementation of the mimic joint to accommodate this situation.

Describe the solution you'd like
For instance, the new method could look like :

 void dart::dynamics::Joint::setMimicJoint( const Joint* _mimicJoint, std::size_t _index  , double _mimicMultiplier, double _mimicOffset)

Additional context
Originally came up here : gazebosim/gz-physics#431

cc @scpeters

@jslee02 jslee02 self-assigned this Dec 8, 2022
@jslee02 jslee02 added the tag: feature request Indicates new feature requests label Dec 8, 2022
@scpeters
Copy link
Collaborator

scpeters commented May 5, 2023

I'll expand on Aditya's API proposals. (Note that in our proposal for adding a mimic constraint to SDFormat, we have started using "follower" and "leader" terminology, so I will use that same terminology here.)

At a minimum, we'd like to mimic an individual Dof of a multi-Dof joint. So that API could look like:

void dart::dynamics::Joint::setMimicJoint(
  std::size_t _followerDof,
  const Joint* _leaderJoint,
  std::size_t _leaderDof,
  double _mimicMultiplier,
  double _mimicOffset);

But that only supports mimicry of a single Dof and the current MimicConstraint supports mimicry of multiple Dofs, so we could extend the _followerDof and _leaderDof parameters from scalars to a map:

void dart::dynamics::Joint::setMimicJoint(
  std::map<std::size_t, std::size_t> _followerToLeaderDofsMap,
  const Joint* _leaderJoint,
  double _mimicMultiplier,
  double _mimicOffset);

Using this latter API, the following calls should be equivalent:

// Current API with a universal joint mimicking another universal joint
universalFollowerJoint->setMimicJoint(universalLeaderJoint, multiplier, offset);
// Proposed API using std::map of Dofs
universalFollowerJoint->setMimicJoint({{0, 0}, {1, 1}}, universalLeaderJoint, multiplier, offset);

But a revolute joint could also mimic a single axis of a universal joint:

revoluteFollowerJoint->setMimicJoint({{0, 1}}, universalLeaderJoint, multiplier, offset);

Or a single axis of a universal joint could mimic a revolute joint:

universalFollowerJoint->setMimicJoint({{1, 0}}, revoluteLeaderJoint, multiplier, offset);

@jslee02
Copy link
Member

jslee02 commented May 13, 2023

Thank you for the detailed description! The feature request appears well-defined and feasible. I've attempted to address this in PR #1752.

@scpeters
Copy link
Collaborator

I left a comment at #1752 (comment) about a potential need for further API changes in Joint::setActuatorType

@jslee02 jslee02 removed this from the DART 6.14 milestone Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: in-progress tag: feature request Indicates new feature requests
Projects
None yet
Development

No branches or pull requests

3 participants