Reference Frame for ApplyBodyWrench [closed]

asked 2016-10-30 12:38:11 -0500

wishzz gravatar image

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
edit retag flag offensive reopen merge delete

Closed for the following reason Gazebo Question: The Gazebo community prefers to answer questions at: http://answers.gazebosim.org by gvdhoorn
close date 2017-02-06 02:50:54.997670

Comments

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

wishzz gravatar image wishzz  ( 2016-10-30 13:49:39 -0500 )edit

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.

JoshMarino gravatar image JoshMarino  ( 2016-10-30 21:50:07 -0500 )edit

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.

wishzz gravatar image wishzz  ( 2016-10-30 22:32:46 -0500 )edit

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).

gvdhoorn gravatar image gvdhoorn  ( 2017-02-06 02:51:30 -0500 )edit

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

Vianne gravatar image Vianne  ( 2020-04-28 07:06:42 -0500 )edit