Reference Frame for ApplyBodyWrench [closed]
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
I am also receiving this error in the terminal if it helps:
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.
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.
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).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