From 4bea3eb5c6c0d98366b5527d0426402e7c10be73 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 14 Jan 2025 09:35:16 +0100 Subject: [PATCH] update --- nodes/odom_publisher_python.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nodes/odom_publisher_python.py b/nodes/odom_publisher_python.py index 2d88f06..56f78ed 100644 --- a/nodes/odom_publisher_python.py +++ b/nodes/odom_publisher_python.py @@ -19,14 +19,18 @@ def odom_callback(msg): 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 br = tf.TransformBroadcaster() br.sendTransform( (position.x, position.y, position.z), # Translation (qx, qy, qz, qw), # Normalized rotation (quaternion) rospy.Time.now(), # Timestamp - msg.child_frame_id if msg.child_frame_id else "base_link", # Child frame ID - msg.header.frame_id if msg.header.frame_id else "odom" # Parent frame ID + child_frame_id, # Child frame ID + parent_frame_id # Parent frame ID ) def main():