This commit is contained in:
Your Name 2025-01-14 09:35:16 +01:00
parent 5dd8b2c27b
commit 4bea3eb5c6

View File

@ -19,14 +19,18 @@ def odom_callback(msg):
orientation.x, orientation.y, orientation.z, orientation.w orientation.x, orientation.y, orientation.z, orientation.w
) )
# Get frame IDs from the message
parent_frame_id = msg.header.frame_id if msg.header.frame_id else "odom"
child_frame_id = msg.child_frame_id if msg.child_frame_id else "base_link"
# Broadcast the transformation # Broadcast the transformation
br = tf.TransformBroadcaster() br = tf.TransformBroadcaster()
br.sendTransform( br.sendTransform(
(position.x, position.y, position.z), # Translation (position.x, position.y, position.z), # Translation
(qx, qy, qz, qw), # Normalized rotation (quaternion) (qx, qy, qz, qw), # Normalized rotation (quaternion)
rospy.Time.now(), # Timestamp rospy.Time.now(), # Timestamp
msg.child_frame_id if msg.child_frame_id else "base_link", # Child frame ID child_frame_id, # Child frame ID
msg.header.frame_id if msg.header.frame_id else "odom" # Parent frame ID parent_frame_id # Parent frame ID
) )
def main(): def main():