Ask Your Question
2

Apply a body wrench in a local frame in a link

asked 2016-03-04 07:17:02 -0500

Femer gravatar image

Hi everybody,

I am trying to apply a body wrench to a simple gazebo model written in SDF. I am running Ubuntu 14.4, with Gazebo 6 and ROS indigo.

I am applying this wrench by calling the rosservice /gazebo/apply_body_wrench as explained in http://answers.ros.org/question/11047... . I'd like to express the wrench in a local frame, defined within a link for example, and not in the world frame of Gazebo. So to test this, I made a MWE you can see below (model in SDF, correctly spawned in Gazebo):

<?xml version="1.0"?>
<sdf version="1.4">
<model name="my_robot_bw">

  <pose>0 0 1 0 0 0</pose> 

  <link name="base">

    <gravity>false</gravity>

    <frame name="frame1">
      <pose>0 0 0 0 0 0.785398163</pose> 
    </frame> 

    <visual name="visual">
      <geometry>
        <box>
            <size>1 1 1</size>
        </box>
      </geometry>
    </visual>

    <collision name="collision">
      <geometry>
        <box>
            <size>1 1 1</size>
        </box>
      </geometry>
    </visual>

  </link>

</model>
</sdf>

A box is placed in the origin of the world frame on the ground (no gravity to see the apply force easily). Then I defined a local frame, named "frame1", in the link called "base" that is rotated by 45 degrees on the Z axis respect the wolrd frame. My goal is to apply a wrench to the base link always expressed in this "frame1", so in this case I'd like to apply a force in the frame1::X_axis and see the box moving at 45 degrees respect to gazebo world X and Y axes. So, once I started gazebo with rosrun and correctly spawned this simple model, I was able to call the rosservice with:

rosservice call /gazebo/apply_body_wrench '{body_name: "my_robot_bw::base", reference_frame: "my_robot_bw::base", reference_point: { x: 0, y: 0, z: 0 }, wrench: { force: { x: 1, y: 0, z: 0 }, torque: { x: 0, y: 0, z: 0 } }, start_time: 0, duration: -1 }'

Here two issues arise:

1) I get the error

[ERROR] [1457096195.411824276, 7.968000000]: wrench defined as [base]:[1.000000 0.000000 0.000000, 0.000000 0.000000 0.000000] --> applied as [base]:[1.000000 0.000000 0.000000, 0.000000 0.000000 0.000000]

which seems "normal", according to http://answers.ros.org/question/65077... when you set a reference frame other than empty, map, or world. It's something strange, but it's not a big problem I guess, as long as the service works.

2) The force is applied as expressed in the world frame, so the box starts moving along the world frame X axes, instead of the frame1 X axes. This is the main problem I am having. So, finally, is there something I am doing wrong? Or should I just always use wrench expressed in the world frame and rotate it by "myself" to make it behaves like if it were expressed in the local frame "frame1" ?

Thanks, Marco.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-08-10 20:58:28 -0500

princeward gravatar image

I have exactly the same problem as you. Anyone knows the solution?

The "apply_body_wrench" service just ignores the reference_frame I specified, and only applies wrench in the world frame.

edit flag offensive delete link more

Comments

1

Hi, at the moment I haven't solved this problem yet, but there are two "workaround":

1) Rotate the wrench in the world frame, by getting the state of the link and using it to rotate the wrench, and the apply it using 'apply_body_wrench'

Femer gravatar image Femer  ( 2016-08-11 02:03:16 -0500 )edit

2) Write a Gazebo plugin and use 'AddRelativeForce' and 'AddRelativeTorque', you can find more information here

Femer gravatar image Femer  ( 2016-08-11 02:04:41 -0500 )edit
1

Hi, thanks! I think your comments should work, and I'll try it later myself to see how it goes.

Just curious about why the native "gazebo/apply_body_wrench" service is buggy. This seems not to be a hard thing to fix.

princeward gravatar image princeward  ( 2016-08-11 08:54:27 -0500 )edit

This is still a problem! :(

Vianne gravatar image Vianne  ( 2020-04-28 07:08:19 -0500 )edit

Having the same problem still.

fahadrazakhan gravatar image fahadrazakhan  ( 2021-01-01 03:20:01 -0500 )edit

I am using ROS Melodic with Gazebo 11, and I also have this issue.

It makes it kind of hard to "drive" a robot joint if you can't apply a torque in the relative frame. If you convert the torque to the global frame the answer is only good for the exact instance it is applied. As soon as the robot start to move the global torque is wrong and it needs to be recomputed and reapplied.

Dr. Roboto gravatar image Dr. Roboto  ( 2021-01-11 11:35:13 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

3 followers

Stats

Asked: 2016-03-04 07:17:02 -0500

Seen: 1,522 times

Last updated: Mar 04 '16