Gazebo | Ignition | Community
Ask Your Question

Ignition Gazebo: set joint position

asked 2021-08-16 03:27:06 -0600

temero gravatar image

updated 2021-08-16 03:37:53 -0600


I want to manually set a joint position in my plugin for Ignition and trying to figure out how to do it. I've tried to set it through the JointPosition component but with no success.

What I did:
1. Found joint by the name
2. Created JointPosition component for this joint
3. Used SetData() to set new joint position
4. Used SetChanged to force an update on the client side

Entity joint = _ecm.EntityByComponents(

auto jointPosComp = _ecm.Component<components::JointPosition>(joint);
if (jointPosComp == nullptr)
  ignmsg << "jointPosComp created" << std::endl;
  _ecm.CreateComponent(joint, components::JointVelocity());

ignerr << "jointPosComp: " << jointPosComp->Data()[0] << std::endl;

      [](const std::vector<double> &, const std::vector<double> &) -> bool
        // No check for equality - always return false
        return false;

When I run it in PreUpdate section, even though I change JointPosition, I still get a JointPosition of 0 on the next iteration.

Any suggestions how to manually change joint position?


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-08-16 14:13:10 -0600

azeey gravatar image

updated 2021-08-16 14:15:29 -0600

It's generally not recommended to the set the joint position on a continual basis since it can cause the physics engine to misbehave. If you want to set the position at the beginning of simulation, you can use the JointPositionReset component.

The JointPosition component contains the current position of the joint and is updated by the Physics system.

edit flag offensive delete link more


JointPositionReset is working fine. Thank you.

temero gravatar imagetemero ( 2021-08-23 09:28:00 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2021-08-16 03:27:06 -0600

Seen: 46 times

Last updated: Aug 16