ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

Assuming you are talking about Gazebo, you can apply a force to a body using this command on the command line:

rosservice call /gazebo/apply_body_wrench '{body_name: "object_1::object_1_base_link", reference_frame: "object_1::object_1_base_link", wrench: { force: { x: 0, y: 0, z: -20.0 } }, start_time: 0, duration: -1 }'

Assuming you are talking about Gazebo, you can apply a force to a body using this command on the command line:

rosservice call /gazebo/apply_body_wrench '{body_name: "object_1::object_1_base_link", reference_frame: "object_1::object_1_base_link", wrench: { force: { x: 0, y: 0, z: -20.0 } }, start_time: 0, duration: -1 }'

Of course, you can also call the apply_body_wrench service from a program. Another alternative is probably accessing the body from a Gazebo plugin, but I can't answer how to do that.

Assuming you are talking about Gazebo, you can apply a force to a body using this command on the command line:

rosservice call /gazebo/apply_body_wrench '{body_name: "object_1::object_1_base_link", reference_frame: "object_1::object_1_base_link", wrench: { force: { x: 0, y: 0, z: -20.0 } }, start_time: 0, duration: -1 }'

Of course, you can also call the apply_body_wrench service from a program.

Another alternative is probably accessing the body from a Gazebo plugin, plugin. I haven't done that yet, but I can't answer how to do that.think it should run along these lines:

  • you get a Gazebo Model object in the constructor of your controller

  • use Model->GetBody(const std::string &name) to get the body representing your link by name

  • use Body->SetForce(const Vector3 &force) to apply the force

I also found looking at turtlebot_gazebo_plugins as an example for some of these steps very helpful.

Assuming you are talking about Gazebo, you can apply a force to a body using this command on the command line:

rosservice call /gazebo/apply_body_wrench '{body_name: "object_1::object_1_base_link", reference_frame: "object_1::object_1_base_link", wrench: { force: { x: 0, y: 0, z: -20.0 } }, start_time: 0, duration: -1 }'

Of course, you can also call the apply_body_wrench service from a program.

Edit: Another alternative is accessing the body from a Gazebo plugin. I haven't done that yet, but I think it should run along these lines:

  • you get a Gazebo Model object in the constructor of your controller

  • use Model->GetBody(const std::string &name) to get the body representing your link by name

  • use Body->SetForce(const Vector3 &force) to apply the force

I also found looking at turtlebot_gazebo_plugins as an example for some of these steps very helpful.