ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I solved it by publishing my goal_pose as a tf_broadcaster:

br = tf2_ros.TransformBroadcaster()

t.header.stamp = rospy.Time.now()
t.header.frame_id = "world"
t.child_frame_id = "object"
t.transform.translation.x = pose_goal.position.x
t.transform.translation.y = pose_goal.position.y
t.transform.rotation.z = pose_goal.position.z
t.transform.rotation.x = pose_goal.orientation.x
t.transform.rotation.y = pose_goal.orientation.y
t.transform.rotation.z = pose_goal.orientation.z
t.transform.rotation.w = pose_goal.orientation.w

After my goal_pose is broadcasted I could lookup and do the transform:

   #lookup transform
tfBuffer = tf2_ros.Buffer()
listener = tf2_ros.TransformListener(tfBuffer)

try:
    transform = tfBuffer.lookup_transform('world', 'object', rospy.Time(), rospy.Duration(1.0))
#except (tf2_ros.LookupException, tf2_ros.ConnectivityException, tf2_ros.ExtrapolationException):
except Exception as e:
    print("transform failed")
    print(e)

initial_pose = PoseStamped()
initial_pose.pose.position.z = 0.1
translated_pose = tf2_geometry_msgs.do_transform_pose(initial_pose, transform)

The result is my translated_pose.

It turned out pretty easy with a tf_broadcaster, it's not very intiutive to me that you can't (or at least I didn't figure out how) transform without doing a broadcast.