# Ways of applying force to a body in Gazebo

In a Gazebo API there are many methods of applying force to a link.

- AddForce
- AddForceAtRelativePosition
- AddForceAtWorldPosition
- AddLinkForce
SetForce

AddRelativeTorque

- AddTorque
- SetTorque

What do they do? What is the difference between AddForce and SetForce? How is AddLinkForce different from the others?

Here is their specification:

virtual void AddForce ( const math::Vector3 & _force )pure virtual Add a force to the body.Parameters [in] _force Force to add. Implemented in BulletLink, SimbodyLink, ODELink, and DARTLink.

virtual void AddForceAtRelativePosition ( const math::Vector3 & _force, const math::Vector3 & _relPos )pure virtual Add a force to the body at position expressed to the body's own frame of reference.Parameters [in] _force Force to add. [in] _relPos Position on the link to add the force. Implemented in BulletLink, SimbodyLink, ODELink, and DARTLink.

virtual void AddForceAtWorldPosition ( const math::Vector3 & _force, const math::Vector3 & _pos )pure virtual Add a force to the body using a global position.Parameters [in] _force Force to add. [in] _pos Position in global coord frame to add the force. Implemented in BulletLink, SimbodyLink, ODELink, and DARTLink.

virtual void AddLinkForce ( const math::Vector3 & _force, const math::Vector3 & _offset = math::Vector3::Zero )pure virtual Add a force expressed in the link frame.Parameters [in] _force Direction vector expressed in the link frame. Each component corresponds to the force which will be added in that axis and the vector's magnitude corresponds to the total force. [in] _offset Offset position expressed in the link frame. It defaults to the link origin. Implemented in BulletLink, SimbodyLink, ODELink, and DARTLink.

virtual void AddRelativeTorque ( const math::Vector3 & _torque )pure virtual Add a torque to the body, components are relative to the body's own frame of reference.Parameters [in] _torque Torque value to add. Implemented in BulletLink, SimbodyLink, ODELink, and DARTLink.

virtual void AddTorque ( const math::Vector3 & _torque )pure virtual Add a torque to the body.

virtual void SetForce ( const math::Vector3 & _force )pure virtual Set the force applied to the body.Parameters [in] _force Force value. Implemented in ODELink, BulletLink, DARTLink, and SimbodyLink.

virtual void SetTorque ( const math::Vector3 & _torque )pure virtual Set the torque applied to the body.Parameters [in] _torque Torque value. Implemented in ODELink, BulletLink, DARTLink, and SimbodyLink.

This issue may have some helpful context: https://bitbucket.org/osrf/gazebo/iss...