Robotics StackExchange | Archived questions

Reference Frame for ApplyBodyWrench

I am trying to apply torque to a unit box in Gazebo using a Python script that uses the ApplyBodyWrench service. When I apply this torque in the +x direction, it seems that the program is applying the torque on the box in the world coordinates. Instead, I am trying to make it such that it applies the torque with respective to the reference frame of the box.

I set the reference frame to "abox::link" but it doesn't seem to work as intended. Also, is "abox::link" the right parameter for model_name?

Thanks in advance!

#!/usr/bin/env python


import math
import roslib

import sys, unittest
import os, os.path, time
import rospy
from std_msgs.msg import String
from geometry_msgs.msg import Pose, Quaternion, Point, PoseStamped, PoseWithCovariance, TwistWithCovariance, Twist, Vector3, Wrench
from gazebo_msgs.srv import ApplyBodyWrench
import tf.transformations as tft
from numpy import float64

#initialize ros node
rospy.init_node("torque_node", anonymous=True)
rospy.wait_for_service('/gazebo/apply_body_wrench')
apply_body_wrench = rospy.ServiceProxy('/gazebo/apply_body_wrench', ApplyBodyWrench)

wrench = Wrench()
wrench.force.x = 0
wrench.force.y = 0
wrench.force.z = 0
wrench.torque.x = 6
wrench.torque.y = 0
wrench.torque.z = 0

try:
    print apply_body_wrench(body_name = "abox::link",
                 reference_frame = "abox::link",
                 wrench = wrench,
                 duration = rospy.Duration(.5))
    print "done"
except rospy.ServiceException as e:
    print e

Asked by wishzz on 2016-10-30 12:38:11 UTC

Comments

I am also receiving this error in the terminal if it helps:

[ERROR] [1477853264.244545836, 62.667000000]: wrench defined as [link]:[0.000000 0.000000 0.000000, 6.000000 0.000000 0.000000] --> applied as [link]:[0.000000 0.000000 0.000000, 6.000000 0.000000 0.000000]

Asked by wishzz on 2016-10-30 13:49:39 UTC

Here is the documentation of the service if that helps. Yes, abox::link is the correct format. If the axes are aligned with world frame, it won't be any different than if left empty.

Asked by JoshMarino on 2016-10-30 21:50:07 UTC

Yep, I have looked into the documentation. And yes, if the axes are aligned with world frame, the torque application would be the same.

Let's say that I turn the box 90 degrees in the z plane. If I now apply the torque, the torque is applied around the world frame's x-axis NOT the box's x-axis.

Asked by wishzz on 2016-10-30 22:32:46 UTC

A bit harsh maybe, but this is also a Gazebo-specific question. I would advise you to ask it over at answers.gazebosim.org (if you haven't already in the meantime).

Asked by gvdhoorn on 2017-02-06 03:51:30 UTC

Hi! Any luck with this problem yet? I'm running into the same problem and I'm having trouble finding an answer. Also looked on answers.gazebosim.org but couldn't find anything there either

Asked by Vianne on 2020-04-28 07:06:42 UTC

Answers