Skip to content

Commit 7e82adc

Browse files
SteveMacenskiazeey
andauthored
Multirobot abilities for TB3 restored (#11)
* Attempts for multirobot namespacing in GZ * expanding gazebo names * Use xacro file to plumb namespace into gz topics (#10) * Use xacro file to plumb namespace into gz topics Signed-off-by: Addisu Z. Taddese <[email protected]> * Fix linter Signed-off-by: Addisu Z. Taddese <[email protected]> --------- Signed-off-by: Addisu Z. Taddese <[email protected]> --------- Signed-off-by: Addisu Z. Taddese <[email protected]> Co-authored-by: Addisu Z. Taddese <[email protected]>
1 parent 42185fa commit 7e82adc

File tree

4 files changed

+30
-37
lines changed

4 files changed

+30
-37
lines changed
Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,44 @@
11
# replace clock_bridge
2-
- ros_topic_name: "clock"
3-
gz_topic_name: "/clock"
2+
- topic_name: "/clock"
43
ros_type_name: "rosgraph_msgs/msg/Clock"
54
gz_type_name: "gz.msgs.Clock"
65
direction: GZ_TO_ROS
76

87
# no equivalent in TB3 - add
9-
- ros_topic_name: "joint_states"
10-
gz_topic_name: "joint_states"
8+
- topic_name: "joint_states"
119
ros_type_name: "sensor_msgs/msg/JointState"
1210
gz_type_name: "gz.msgs.Model"
1311
direction: GZ_TO_ROS
1412

1513
# replace odom_bridge - check gz topic name
1614
# gz topic published by DiffDrive plugin
17-
- ros_topic_name: "odom"
18-
gz_topic_name: "/odom"
15+
- topic_name: "odom"
1916
ros_type_name: "nav_msgs/msg/Odometry"
2017
gz_type_name: "gz.msgs.Odometry"
2118
direction: GZ_TO_ROS
2219

2320
# replace odom_tf_bridge - check gz and ros topic names
2421
# gz topic published by DiffDrive plugin
2522
# prefix ros2 topic with gz
26-
- ros_topic_name: "tf"
27-
gz_topic_name: "/tf"
23+
- topic_name: "tf"
2824
ros_type_name: "tf2_msgs/msg/TFMessage"
2925
gz_type_name: "gz.msgs.Pose_V"
3026
direction: GZ_TO_ROS
3127

3228
# replace imu_bridge - check gz topic name
33-
- ros_topic_name: "imu"
34-
gz_topic_name: "/imu"
29+
- topic_name: "imu"
3530
ros_type_name: "sensor_msgs/msg/Imu"
3631
gz_type_name: "gz.msgs.IMU"
3732
direction: GZ_TO_ROS
3833

3934
# replace lidar_bridge
40-
- ros_topic_name: "scan"
41-
gz_topic_name: "/scan"
35+
- topic_name: "scan"
4236
ros_type_name: "sensor_msgs/msg/LaserScan"
4337
gz_type_name: "gz.msgs.LaserScan"
4438
direction: GZ_TO_ROS
4539

4640
# replace cmd_vel_bridge
47-
- ros_topic_name: "cmd_vel"
48-
gz_topic_name: "/cmd_vel"
41+
- topic_name: "cmd_vel"
4942
ros_type_name: "geometry_msgs/msg/Twist"
5043
gz_type_name: "gz.msgs.Twist"
5144
direction: ROS_TO_GZ

nav2_minimal_tb3_sim/launch/spawn_tb3.launch.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
import os
1717
from pathlib import Path
1818

19+
1920
from ament_index_python.packages import get_package_share_directory
2021

2122
from launch import LaunchDescription
2223
from launch.actions import AppendEnvironmentVariable
2324
from launch.actions import DeclareLaunchArgument
24-
from launch.conditions import IfCondition
2525
from launch.substitutions import LaunchConfiguration
26+
from launch.substitutions.command import Command
27+
from launch.substitutions.find_executable import FindExecutable
2628

2729
from launch_ros.actions import Node
2830

@@ -31,7 +33,6 @@ def generate_launch_description():
3133
bringup_dir = get_package_share_directory('nav2_minimal_tb3_sim')
3234

3335
namespace = LaunchConfiguration('namespace')
34-
use_simulator = LaunchConfiguration('use_simulator')
3536
robot_name = LaunchConfiguration('robot_name')
3637
robot_sdf = LaunchConfiguration('robot_sdf')
3738
pose = {'x': LaunchConfiguration('x_pose', default='-2.00'),
@@ -47,43 +48,42 @@ def generate_launch_description():
4748
default_value='',
4849
description='Top-level namespace')
4950

50-
declare_use_simulator_cmd = DeclareLaunchArgument(
51-
'use_simulator',
52-
default_value='True',
53-
description='Whether to start the simulator')
54-
5551
declare_robot_name_cmd = DeclareLaunchArgument(
5652
'robot_name',
5753
default_value='turtlebot3_waffle',
5854
description='name of the robot')
5955

6056
declare_robot_sdf_cmd = DeclareLaunchArgument(
6157
'robot_sdf',
62-
default_value=os.path.join(bringup_dir, 'urdf', 'gz_waffle.sdf'),
58+
default_value=os.path.join(bringup_dir, 'urdf', 'gz_waffle.sdf.xacro'),
6359
description='Full path to robot sdf file to spawn the robot in gazebo')
6460

6561
bridge = Node(
6662
package='ros_gz_bridge',
6763
executable='parameter_bridge',
64+
namespace=namespace,
6865
parameters=[
6966
{
7067
'config_file': os.path.join(
7168
bringup_dir, 'configs', 'turtlebot3_waffle_bridge.yaml'
7269
),
70+
'expand_gz_topic_names': True,
71+
'use_sim_time': True,
7372
}
7473
],
7574
output='screen',
7675
)
7776

7877
spawn_model = Node(
79-
condition=IfCondition(use_simulator),
8078
package='ros_gz_sim',
8179
executable='create',
8280
output='screen',
81+
namespace=namespace,
8382
arguments=[
84-
'-entity', robot_name,
85-
'-file', robot_sdf,
86-
'-robot_namespace', namespace,
83+
'-name', robot_name,
84+
'-string', Command([
85+
FindExecutable(name='xacro'), ' ', 'namespace:=',
86+
LaunchConfiguration('namespace'), ' ', robot_sdf]),
8787
'-x', pose['x'], '-y', pose['y'], '-z', pose['z'],
8888
'-R', pose['R'], '-P', pose['P'], '-Y', pose['Y']]
8989
)
@@ -99,7 +99,6 @@ def generate_launch_description():
9999
ld.add_action(declare_namespace_cmd)
100100
ld.add_action(declare_robot_name_cmd)
101101
ld.add_action(declare_robot_sdf_cmd)
102-
ld.add_action(declare_use_simulator_cmd)
103102

104103
ld.add_action(set_env_vars_resources)
105104
ld.add_action(set_env_vars_resources2)

nav2_minimal_tb3_sim/urdf/gz_waffle.sdf renamed to nav2_minimal_tb3_sim/urdf/gz_waffle.sdf.xacro

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?xml version="1.0"?>
2-
<sdf version="1.6">
2+
<sdf version="1.6" xmlns:xacro="http://www.ros.org/wiki/xacro">
3+
<xacro:arg name="namespace" default=""/>
4+
35
<model name="turtlebot3_waffle">
46
<pose>0.0 0.0 0.0 0.0 0.0 0.0</pose>
57

@@ -47,7 +49,7 @@
4749
<sensor name="tb3_imu" type="imu">
4850
<always_on>true</always_on>
4951
<update_rate>200</update_rate>
50-
<topic>imu</topic>
52+
<topic>$(arg namespace)/imu</topic>
5153
<gz_frame_id>imu_link</gz_frame_id>
5254
<imu>
5355
<angular_velocity>
@@ -136,7 +138,7 @@
136138
<visualize>true</visualize>
137139
<pose>-0.064 0 0.15 0 0 0</pose>
138140
<update_rate>5</update_rate>
139-
<topic>scan</topic>
141+
<topic>$(arg namespace)/scan</topic>
140142
<gz_frame_id>base_scan</gz_frame_id>
141143
<ray>
142144
<scan>
@@ -469,9 +471,9 @@
469471
<min_linear_velocity>-0.46</min_linear_velocity>
470472
<max_angular_velocity>1.9</max_angular_velocity>
471473
<min_angular_velocity>-1.9</min_angular_velocity>
472-
<topic>/cmd_vel</topic>
473-
<odom_topic>/odom</odom_topic>
474-
<tf_topic>tf</tf_topic>
474+
<topic>$(arg namespace)/cmd_vel</topic>
475+
<odom_topic>$(arg namespace)/odom</odom_topic>
476+
<tf_topic>$(arg namespace)/tf</tf_topic>
475477
<frame_id>odom</frame_id>
476478
<child_frame_id>base_footprint</child_frame_id>
477479
<odom_publish_frequency>30</odom_publish_frequency>
@@ -482,7 +484,7 @@
482484
name="gz::sim::systems::JointStatePublisher">
483485
<joint_name>wheel_left_joint</joint_name>
484486
<joint_name>wheel_right_joint</joint_name>
485-
<topic>joint_states</topic>
487+
<topic>$(arg namespace)/joint_states</topic>
486488
<update_rate>30</update_rate>
487489
</plugin>
488490

nav2_minimal_tb3_sim/worlds/tb3_sandbox.sdf.xacro

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,9 @@
7272
<shadows>0</shadows>
7373
</scene>
7474

75-
<physics name='1ms' type='ode'>
76-
<max_step_size>0.001</max_step_size>
75+
<physics name='3ms' type='ode'>
76+
<max_step_size>0.003</max_step_size>
7777
<real_time_factor>1</real_time_factor>
78-
<real_time_update_rate>1000.0</real_time_update_rate>
7978
</physics>
8079

8180
<model name="turtlebot3_world">

0 commit comments

Comments
 (0)