1111from launch import LaunchDescription
1212from launch .actions import DeclareLaunchArgument , IncludeLaunchDescription , TimerAction
1313from launch .launch_description_sources import PythonLaunchDescriptionSource
14- from launch .substitutions import Command , FindExecutable , LaunchConfiguration , PathJoinSubstitution
14+ from launch .substitutions import Command , FindExecutable , LaunchConfiguration , PathJoinSubstitution , PythonExpression
1515from launch_ros .actions import Node
1616from launch_ros .substitutions import FindPackageShare
1717
@@ -31,6 +31,15 @@ def generate_launch_description():
3131 with_gazebo = LaunchConfiguration ("with_gazebo" )
3232 xacro_args = LaunchConfiguration ("xacro_args" )
3333
34+ # Build parameter_bridge arguments (GZ -> ROS for sensors)
35+ ns = LaunchConfiguration ('ns' )
36+ imu_topic = LaunchConfiguration ('imu_topic' )
37+ gps_topic = LaunchConfiguration ('gps_topic' )
38+ publish_static_tf = LaunchConfiguration ('publish_static_tf' )
39+ base_frame = LaunchConfiguration ('base_frame' )
40+ imu_frame = LaunchConfiguration ('imu_frame' )
41+ gps_frame = LaunchConfiguration ('gps_frame' )
42+
3443 return LaunchDescription ([
3544 # Paths / args
3645 DeclareLaunchArgument (
@@ -59,6 +68,13 @@ def generate_launch_description():
5968 DeclareLaunchArgument (
6069 "xacro_args" , default_value = "" ,
6170 ),
71+ # Launch args for the GZ - ROS2 bridge
72+ DeclareLaunchArgument ('ns' , default_value = '' , description = 'ROS namespace for the bridge' ),
73+ DeclareLaunchArgument ('imu_topic' , default_value = '/imu' , description = 'GZ/ROS topic for IMU' ),
74+ DeclareLaunchArgument ('gps_topic' , default_value = '/gps' , description = 'GZ/ROS topic for GPS/NavSat' ),
75+ DeclareLaunchArgument ('base_frame' , default_value = 'base_link' , description = 'Base frame id' ),
76+ DeclareLaunchArgument ('imu_frame' , default_value = 'imu_link' , description = 'IMU frame id (must match gz_frame_id in SDF)' ),
77+ DeclareLaunchArgument ('gps_frame' , default_value = 'gps_link' , description = 'GPS frame id (must match gz_frame_id in SDF)' ),
6278
6379 IncludeLaunchDescription (
6480 PythonLaunchDescriptionSource (PathJoinSubstitution ([
@@ -98,6 +114,18 @@ def generate_launch_description():
98114 "x" : x , "y" : y , "z" : z ,
99115 "R" : R , "P" : P , "Y" : Y
100116 }.items ()
117+ ),
118+ Node (
119+ package = 'ros_gz_bridge' ,
120+ executable = 'parameter_bridge' ,
121+ name = 'ros_gz_parameter_bridge' ,
122+ namespace = ns ,
123+ output = 'screen' ,
124+ arguments = [
125+ PythonExpression (['"' , imu_topic , '" + \' @sensor_msgs/msg/Imu[gz.msgs.IMU\' ' ]),
126+ PythonExpression (['"' , gps_topic , '" + \' @sensor_msgs/msg/NavSatFix[gz.msgs.NavSat\' ' ]),
127+ '/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock'
128+ ],
101129 )
102130 ]
103131 ),
0 commit comments