diff --git a/nav2_minimal_tb3_sim/configs/turtlebot3_waffle_bridge.yaml b/nav2_minimal_tb3_sim/configs/turtlebot3_waffle_bridge.yaml index 843699f..6513b7a 100644 --- a/nav2_minimal_tb3_sim/configs/turtlebot3_waffle_bridge.yaml +++ b/nav2_minimal_tb3_sim/configs/turtlebot3_waffle_bridge.yaml @@ -1,21 +1,18 @@ # replace clock_bridge -- ros_topic_name: "clock" - gz_topic_name: "/clock" +- topic_name: "/clock" ros_type_name: "rosgraph_msgs/msg/Clock" gz_type_name: "gz.msgs.Clock" direction: GZ_TO_ROS # no equivalent in TB3 - add -- ros_topic_name: "joint_states" - gz_topic_name: "joint_states" +- topic_name: "joint_states" ros_type_name: "sensor_msgs/msg/JointState" gz_type_name: "gz.msgs.Model" direction: GZ_TO_ROS # replace odom_bridge - check gz topic name # gz topic published by DiffDrive plugin -- ros_topic_name: "odom" - gz_topic_name: "/odom" +- topic_name: "odom" ros_type_name: "nav_msgs/msg/Odometry" gz_type_name: "gz.msgs.Odometry" direction: GZ_TO_ROS @@ -23,29 +20,25 @@ # replace odom_tf_bridge - check gz and ros topic names # gz topic published by DiffDrive plugin # prefix ros2 topic with gz -- ros_topic_name: "tf" - gz_topic_name: "/tf" +- topic_name: "tf" ros_type_name: "tf2_msgs/msg/TFMessage" gz_type_name: "gz.msgs.Pose_V" direction: GZ_TO_ROS # replace imu_bridge - check gz topic name -- ros_topic_name: "imu" - gz_topic_name: "/imu" +- topic_name: "imu" ros_type_name: "sensor_msgs/msg/Imu" gz_type_name: "gz.msgs.IMU" direction: GZ_TO_ROS # replace lidar_bridge -- ros_topic_name: "scan" - gz_topic_name: "/scan" +- topic_name: "scan" ros_type_name: "sensor_msgs/msg/LaserScan" gz_type_name: "gz.msgs.LaserScan" direction: GZ_TO_ROS # replace cmd_vel_bridge -- ros_topic_name: "cmd_vel" - gz_topic_name: "/cmd_vel" +- topic_name: "cmd_vel" ros_type_name: "geometry_msgs/msg/Twist" gz_type_name: "gz.msgs.Twist" direction: ROS_TO_GZ diff --git a/nav2_minimal_tb3_sim/launch/spawn_tb3.launch.py b/nav2_minimal_tb3_sim/launch/spawn_tb3.launch.py index c1fd97c..e71d362 100644 --- a/nav2_minimal_tb3_sim/launch/spawn_tb3.launch.py +++ b/nav2_minimal_tb3_sim/launch/spawn_tb3.launch.py @@ -16,13 +16,15 @@ import os from pathlib import Path + from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch.actions import AppendEnvironmentVariable from launch.actions import DeclareLaunchArgument -from launch.conditions import IfCondition from launch.substitutions import LaunchConfiguration +from launch.substitutions.command import Command +from launch.substitutions.find_executable import FindExecutable from launch_ros.actions import Node @@ -31,7 +33,6 @@ def generate_launch_description(): bringup_dir = get_package_share_directory('nav2_minimal_tb3_sim') namespace = LaunchConfiguration('namespace') - use_simulator = LaunchConfiguration('use_simulator') robot_name = LaunchConfiguration('robot_name') robot_sdf = LaunchConfiguration('robot_sdf') pose = {'x': LaunchConfiguration('x_pose', default='-2.00'), @@ -47,11 +48,6 @@ def generate_launch_description(): default_value='', description='Top-level namespace') - declare_use_simulator_cmd = DeclareLaunchArgument( - 'use_simulator', - default_value='True', - description='Whether to start the simulator') - declare_robot_name_cmd = DeclareLaunchArgument( 'robot_name', default_value='turtlebot3_waffle', @@ -59,31 +55,35 @@ def generate_launch_description(): declare_robot_sdf_cmd = DeclareLaunchArgument( 'robot_sdf', - default_value=os.path.join(bringup_dir, 'urdf', 'gz_waffle.sdf'), + default_value=os.path.join(bringup_dir, 'urdf', 'gz_waffle.sdf.xacro'), description='Full path to robot sdf file to spawn the robot in gazebo') bridge = Node( package='ros_gz_bridge', executable='parameter_bridge', + namespace=namespace, parameters=[ { 'config_file': os.path.join( bringup_dir, 'configs', 'turtlebot3_waffle_bridge.yaml' ), + 'expand_gz_topic_names': True, + 'use_sim_time': True, } ], output='screen', ) spawn_model = Node( - condition=IfCondition(use_simulator), package='ros_gz_sim', executable='create', output='screen', + namespace=namespace, arguments=[ - '-entity', robot_name, - '-file', robot_sdf, - '-robot_namespace', namespace, + '-name', robot_name, + '-string', Command([ + FindExecutable(name='xacro'), ' ', 'namespace:=', + LaunchConfiguration('namespace'), ' ', robot_sdf]), '-x', pose['x'], '-y', pose['y'], '-z', pose['z'], '-R', pose['R'], '-P', pose['P'], '-Y', pose['Y']] ) @@ -99,7 +99,6 @@ def generate_launch_description(): ld.add_action(declare_namespace_cmd) ld.add_action(declare_robot_name_cmd) ld.add_action(declare_robot_sdf_cmd) - ld.add_action(declare_use_simulator_cmd) ld.add_action(set_env_vars_resources) ld.add_action(set_env_vars_resources2) diff --git a/nav2_minimal_tb3_sim/urdf/gz_waffle.sdf b/nav2_minimal_tb3_sim/urdf/gz_waffle.sdf.xacro similarity index 97% rename from nav2_minimal_tb3_sim/urdf/gz_waffle.sdf rename to nav2_minimal_tb3_sim/urdf/gz_waffle.sdf.xacro index d379a90..af30b5e 100644 --- a/nav2_minimal_tb3_sim/urdf/gz_waffle.sdf +++ b/nav2_minimal_tb3_sim/urdf/gz_waffle.sdf.xacro @@ -1,5 +1,7 @@ - + + + 0.0 0.0 0.0 0.0 0.0 0.0 @@ -47,7 +49,7 @@ true 200 - imu + $(arg namespace)/imu imu_link @@ -136,7 +138,7 @@ true -0.064 0 0.15 0 0 0 5 - scan + $(arg namespace)/scan base_scan @@ -469,9 +471,9 @@ -0.46 1.9 -1.9 - /cmd_vel - /odom - tf + $(arg namespace)/cmd_vel + $(arg namespace)/odom + $(arg namespace)/tf odom base_footprint 30 @@ -482,7 +484,7 @@ name="gz::sim::systems::JointStatePublisher"> wheel_left_joint wheel_right_joint - joint_states + $(arg namespace)/joint_states 30 diff --git a/nav2_minimal_tb3_sim/worlds/tb3_sandbox.sdf.xacro b/nav2_minimal_tb3_sim/worlds/tb3_sandbox.sdf.xacro index d93c7fa..57196bf 100644 --- a/nav2_minimal_tb3_sim/worlds/tb3_sandbox.sdf.xacro +++ b/nav2_minimal_tb3_sim/worlds/tb3_sandbox.sdf.xacro @@ -72,10 +72,9 @@ 0 - - 0.001 + + 0.003 1 - 1000.0