Gazebo | Ignition | Community
Ask Your Question

Apply force to object through plugin

asked 2019-09-13 05:50:13 -0600

lolistic gravatar image


is there a way to apply a force to objects/models.

There is "SetLinearAccel", but I can't find any command for applying a force.

Thanks in advance

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-09-23 02:51:07 -0600

lolistic gravatar image

From my own experience, it seems like the answer is that one can't apply force to a model/object, only a link. This can be solved by getting the desired link from the model, where the names of the links can be changed in the .world file:

this->model->GetLink("body")->SetForce(ignition::math::Vector3d(1.0, 0.0, 0.0);

The same goes for applying torque:

this->model->GetLink("body")->SetTorque(1.0, ignition::math::Vector3d(1.0, 0.0, 0.0);

Hope this helps someone else.

edit flag offensive delete link more


Extremely helpful, my slight variation is below

this->model->GetLink("link_name")->SetForce(ignition::math::Vector3d(forceX, forceY, forceZ));
this->model->GetJoint("joint_name")->SetForce(0, torque);

One thing that was very hard to find anywhere is how to apply a torque to a link. It's done the same way as a force, but Gazebo knows what to do when "SetForce" is done on a joint (revolute joint in my case). The "0" within SetForce() is the axis index, which I think could be non

Joshua658413 gravatar imageJoshua658413 ( 2020-12-07 21:11:15 -0600 )edit

Question Tools

1 follower


Asked: 2019-09-13 05:50:13 -0600

Seen: 920 times

Last updated: Sep 23 '19