Moveit set_to_pose tuple attribute x issue
I need help with my attempts to create a pose from my transform listener object. The tf listener is successfully delivering data but my problems begin when I try creating a pose object from the tf data, using the code below:
def __init__(self):
self.tf_buffer = tf2_ros.Buffer()
self.tf_listener = tf2_ros.TransformListener(self.tf_buffer)
rospy.sleep(5)
try:
if self.tf_buffer.can_transform('wrist_3_link', 'base_footprint', rospy.Time()) :
self.transform_stamped = self.tf_buffer.lookup_transform('wrist_3_link', 'base_footprint', rospy.Time())
pose = Pose()
pose.position = self.transform_stamped.transform.translation
pose.orientation = euler_from_quaternion((
self.transform_stamped.transform.rotation.x,
self.transform_stamped.transform.rotation.y,
self.transform_stamped.transform.rotation.z,
self.transform_stamped.transform.rotation.w
))
self.move_to_pose(pose)
except (tf2_ros.LookupException, tf2_ros.ConnectivityException, tf2_ros.ExtrapolationException) as e:
rospy.logerr(e)
def move_to_pose(self, pose):
rospy.loginfo(pose)
self.manipulator.set_pose_target(pose)
plan = self.manipulator.plan()
self.manipulator.execute(plan)
Which yields the following error:
[INFO] [1552167988.940291, 5.015000]:
position:
x: 0.816988026247
y: -0.109039832758
z: -0.00443080091744
orientation: [3.141573333853047, -0.00452701380180146, 3.140211345214987]
Traceback (most recent call last): File "/home/sisko/moveit_ws/src/ur5bot_moveit_config/nodes/moveit_goal.py", line 359, in <module>
TrackBot() File "/home/sisko/moveit_ws/src/ur5bot_moveit_config/nodes/moveit_goal.py", line 81, in __init__
self.transform() File "/home/sisko/moveit_ws/src/ur5bot_moveit_config/nodes/moveit_goal.py", line 115, in transform
self.move_to_pose(pose) File "/home/sisko/moveit_ws/src/ur5bot_moveit_config/nodes/moveit_goal.py", line 290, in move_to_pose
self.manipulator.set_pose_target(pose) File "/opt/ros/kinetic/lib/python2.7/dist-packages/moveit_commander/move_group.py", line 274, in set_pose_target
ok = self._g.set_pose_target(conversions.pose_to_list(pose), end_effector_link) File "/opt/ros/kinetic/lib/python2.7/dist-packages/moveit_commander/conversions.py", line 54, in pose_to_list
pose.append(pose_msg.orientation.x) AttributeError: 'tuple' object has no attribute 'x'
I been working at finding a solution for hours. I would appreciate the help of a fresh pair of eyes.
UPDATE: Just including an example of the data from the transform listener.
************************* Transform Data:
[INFO] [1552233229.396174, 6.727000]: header:
seq: 0
stamp:
secs: 6
nsecs: 701000000
frame_id: "wrist_3_link"
child_frame_id: "base_footprint"
transform:
translation:
x: 0.816964133008
y: -0.109003488461
z: -0.00442450622864
rotation:
x: -0.00110212544585
y: -0.999997191233
z: -1.36438458498e-05
w: 0.00209825162089
****************************************
Is
pose
a geometry_msgs/Pose? If so, theorientation
field is already aQuaternion
, so I'm unsure as to why you are usingeuler_from_quaternion(..)
.Note: a
geometry_msgs/Pose
is almost identical to a geometry_msgs/Transform.And minor comment: I don't believe calling methods on an object instance inside its own constructor is recommended/safe (ie: calling
move_to_pose(..)
from__init__(..)
).Hi @gvdhoom. Thanks for your answer. Regarding if the rotation data is already a quaternion or not, I am not sure. If a quaternion is an object, the raw rotation data does not seem to be an object.
I included a rospy.loginfo example output of my tf data in my question so you can see what I'm working with.
Thank you @gvdhoom. I understand your point - finally :-)