Skip to content

Commit ebe60dc

Browse files
SteveMacenskiahcordeazeey
authored
Migrate TB3 to nav2 minimal turtlebot repository & add the TB4 bringup option for modern gazebo (ros-navigation#4401)
* Initial support to the new Gazebo Signed-off-by: Alejandro Hernández Cordero <[email protected]> * Added feedback Signed-off-by: Alejandro Hernández Cordero <[email protected]> * Fixed build Signed-off-by: Alejandro Hernández Cordero <[email protected]> * Added feeback Signed-off-by: Alejandro Hernández Cordero <[email protected]> * Fixed physics tag Signed-off-by: Alejandro Hernández Cordero <[email protected]> * Fixed physics tag Signed-off-by: Alejandro Hernández Cordero <[email protected]> * Fix copyright and urdf Signed-off-by: Alejandro Hernández Cordero <[email protected]> * min range cannot be zero Signed-off-by: Alejandro Hernández Cordero <[email protected]> * Simplify files Signed-off-by: Alejandro Hernández Cordero <[email protected]> * Added feedback Signed-off-by: Alejandro Hernández Cordero <[email protected]> * Added feedback Signed-off-by: Alejandro Hernández Cordero <[email protected]> * Fix Signed-off-by: Alejandro Hernández Cordero <[email protected]> * Try to reduce load Signed-off-by: Alejandro Hernández Cordero <[email protected]> * Removed cast shadows Signed-off-by: Alejandro Hernández Cordero <[email protected]> * Use Gazebo plugins instead of gz_ros2_control Signed-off-by: Alejandro Hernández Cordero <[email protected]> * update dependency Signed-off-by: Alejandro Hernández Cordero <[email protected]> * Removed dependency Signed-off-by: Alejandro Hernández Cordero <[email protected]> * Removed ros2_control and use ogre Signed-off-by: Alejandro Hernández Cordero <[email protected]> * Use param file to configure bridge Signed-off-by: Alejandro Hernández Cordero <[email protected]> * Use sdf model and change to ogre instead of ogre2 for sensors Signed-off-by: Addisu Z. Taddese <[email protected]> * Support Garden and later, performance improvements Signed-off-by: Addisu Z. Taddese <[email protected]> * Use xacro for world file (#2) Signed-off-by: Addisu Z. Taddese <[email protected]> * Reviewer feedback Signed-off-by: Addisu Z. Taddese <[email protected]> * Add comment explaining temp file Signed-off-by: Addisu Z. Taddese <[email protected]> * Fix linter Signed-off-by: Addisu Z. Taddese <[email protected]> * Update nav2_bringup/worlds/gz_world_only.sdf.xacro Co-authored-by: Addisu Z. Taddese <[email protected]> Signed-off-by: Steve Macenski <[email protected]> * port GZ Classic launch changes to modern GZ and remove GZ Classic launch file * adding changes * changes done for TB4 * tb3 sim prototype * fix missing ref * linting * fix branch name * remove assets * removing refs to turtlebot3_gazebo * update map * add new depot map * Update Nav2 side of multirobot launch files * linting --------- Signed-off-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Addisu Z. Taddese <[email protected]> Signed-off-by: Addisu Z. Taddese <[email protected]> Signed-off-by: Steve Macenski <[email protected]> Co-authored-by: Alejandro Hernández Cordero <[email protected]> Co-authored-by: Addisu Z. Taddese <[email protected]> Co-authored-by: Addisu Z. Taddese <[email protected]>
1 parent bc6e3b2 commit ebe60dc

28 files changed

+173
-1764
lines changed

.circleci/config.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ _commands:
8282
- run:
8383
name: Install Dependencies | << parameters.workspace >>
8484
working_directory: << parameters.workspace >>
85-
# Remove/Replace turtlebot3_gazebo and gazebo_ros_pkgs from --skip-keys after https://github.com/ros-navigation/navigation2/pull/3634
8685
command: |
8786
. << parameters.underlay >>/install/setup.sh
8887
AMENT_PREFIX_PATH=$(echo "$AMENT_PREFIX_PATH" | \
@@ -105,7 +104,6 @@ _commands:
105104
--ignore-src \
106105
--skip-keys " \
107106
slam_toolbox \
108-
turtlebot3_gazebo \
109107
" \
110108
--verbose | \
111109
awk '$1 ~ /^resolution\:/' | \

Dockerfile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,11 @@ ENV OVERLAY_WS $OVERLAY_WS
9797
WORKDIR $OVERLAY_WS
9898
COPY --from=cacher /tmp/$OVERLAY_WS ./
9999

100-
# Remove/Replace turtlebot3_gazebo and gazebo_ros_pkgs from --skip-keys after https://github.com/ros-navigation/navigation2/pull/3634
101100
RUN . $UNDERLAY_WS/install/setup.sh && \
102101
apt-get update && rosdep install -q -y \
103102
--from-paths src \
104103
--skip-keys " \
105104
slam_toolbox \
106-
turtlebot3_gazebo \
107105
"\
108106
--ignore-src \
109107
&& rm -rf /var/lib/apt/lists/*
@@ -170,9 +168,7 @@ RUN mkdir -p $ROOT_SRV
170168

171169
# install demo dependencies
172170
RUN apt-get update && apt-get install -y \
173-
ros-$ROS_DISTRO-aws-robomaker-small-warehouse-world \
174171
ros-$ROS_DISTRO-rviz2 \
175-
ros-$ROS_DISTRO-turtlebot3-simulations
176172

177173
# install gzweb dependacies
178174
RUN apt-get install -y --no-install-recommends \

nav2_bringup/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ nav2_package()
1010
install(DIRECTORY launch DESTINATION share/${PROJECT_NAME})
1111
install(DIRECTORY maps DESTINATION share/${PROJECT_NAME})
1212
install(DIRECTORY rviz DESTINATION share/${PROJECT_NAME})
13-
install(DIRECTORY worlds DESTINATION share/${PROJECT_NAME})
1413
install(DIRECTORY params DESTINATION share/${PROJECT_NAME})
15-
install(DIRECTORY urdf DESTINATION share/${PROJECT_NAME})
1614

1715
if(BUILD_TESTING)
1816
find_package(ament_lint_auto REQUIRED)

nav2_bringup/launch/cloned_multi_tb3_simulation_launch.py

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright (c) 2023 LG Electronics.
2+
# Copyright (c) 2024 Open Navigation LLC
23
#
34
# Licensed under the Apache License, Version 2.0 (the "License");
45
# you may not use this file except in compliance with the License.
@@ -14,17 +15,23 @@
1415

1516

1617
import os
18+
from pathlib import Path
19+
import tempfile
1720

1821
from ament_index_python.packages import get_package_share_directory
1922
from launch import LaunchDescription
2023
from launch.actions import (
24+
AppendEnvironmentVariable,
2125
DeclareLaunchArgument,
2226
ExecuteProcess,
2327
GroupAction,
2428
IncludeLaunchDescription,
2529
LogInfo,
30+
OpaqueFunction,
31+
RegisterEventHandler,
2632
)
2733
from launch.conditions import IfCondition
34+
from launch.event_handlers import OnShutdown
2835
from launch.launch_description_sources import PythonLaunchDescriptionSource
2936
from launch.substitutions import LaunchConfiguration, TextSubstitution
3037
from nav2_common.launch import ParseMultiRobotPose
@@ -43,10 +50,10 @@ def generate_launch_description():
4350
# Get the launch directory
4451
bringup_dir = get_package_share_directory('nav2_bringup')
4552
launch_dir = os.path.join(bringup_dir, 'launch')
53+
sim_dir = get_package_share_directory('nav2_minimal_tb3_sim')
4654

4755
# Simulation settings
4856
world = LaunchConfiguration('world')
49-
simulator = LaunchConfiguration('simulator')
5057

5158
# On this example all robots are launched with the same settings
5259
map_yaml_file = LaunchConfiguration('map')
@@ -60,19 +67,13 @@ def generate_launch_description():
6067
# Declare the launch arguments
6168
declare_world_cmd = DeclareLaunchArgument(
6269
'world',
63-
default_value=os.path.join(bringup_dir, 'worlds', 'world_only.model'),
70+
default_value=os.path.join(sim_dir, 'worlds', 'tb3_sandbox.sdf.xacro'),
6471
description='Full path to world file to load',
6572
)
6673

67-
declare_simulator_cmd = DeclareLaunchArgument(
68-
'simulator',
69-
default_value='gazebo',
70-
description='The simulator to use (gazebo or gzserver)',
71-
)
72-
7374
declare_map_yaml_cmd = DeclareLaunchArgument(
7475
'map',
75-
default_value=os.path.join(bringup_dir, 'maps', 'turtlebot3_world.yaml'),
76+
default_value=os.path.join(bringup_dir, 'maps', 'tb3_sandbox.yaml'),
7677
description='Full path to map file to load',
7778
)
7879

@@ -107,18 +108,19 @@ def generate_launch_description():
107108
)
108109

109110
# Start Gazebo with plugin providing the robot spawning service
110-
start_gazebo_cmd = ExecuteProcess(
111-
cmd=[
112-
simulator,
113-
'--verbose',
114-
'-s',
115-
'libgazebo_ros_init.so',
116-
'-s',
117-
'libgazebo_ros_factory.so',
118-
world,
119-
],
120-
output='screen',
121-
)
111+
world_sdf = tempfile.mktemp(prefix='nav2_', suffix='.sdf')
112+
world_sdf_xacro = ExecuteProcess(
113+
cmd=['xacro', '-o', world_sdf, ['headless:=', 'False'], world])
114+
start_gazebo_cmd = IncludeLaunchDescription(
115+
PythonLaunchDescriptionSource(
116+
os.path.join(get_package_share_directory('ros_gz_sim'), 'launch',
117+
'gz_sim.launch.py')),
118+
launch_arguments={'gz_args': ['-r -s ', world_sdf]}.items())
119+
120+
remove_temp_sdf_file = RegisterEventHandler(event_handler=OnShutdown(
121+
on_shutdown=[
122+
OpaqueFunction(function=lambda _: os.remove(world_sdf))
123+
]))
122124

123125
robots_list = ParseMultiRobotPose('robots').value()
124126

@@ -176,11 +178,18 @@ def generate_launch_description():
176178

177179
bringup_cmd_group.append(group)
178180

181+
set_env_vars_resources = AppendEnvironmentVariable(
182+
'GZ_SIM_RESOURCE_PATH', os.path.join(sim_dir, 'models'))
183+
set_env_vars_resources2 = AppendEnvironmentVariable(
184+
'GZ_SIM_RESOURCE_PATH',
185+
str(Path(os.path.join(sim_dir)).parent.resolve()))
186+
179187
# Create the launch description and populate
180188
ld = LaunchDescription()
189+
ld.add_action(set_env_vars_resources)
190+
ld.add_action(set_env_vars_resources2)
181191

182192
# Declare the launch options
183-
ld.add_action(declare_simulator_cmd)
184193
ld.add_action(declare_world_cmd)
185194
ld.add_action(declare_map_yaml_cmd)
186195
ld.add_action(declare_params_file_cmd)
@@ -190,7 +199,9 @@ def generate_launch_description():
190199
ld.add_action(declare_use_robot_state_pub_cmd)
191200

192201
# Add the actions to start gazebo, robots and simulations
202+
ld.add_action(world_sdf_xacro)
193203
ld.add_action(start_gazebo_cmd)
204+
ld.add_action(remove_temp_sdf_file)
194205

195206
ld.add_action(LogInfo(msg=['number_of_robots=', str(len(robots_list))]))
196207

nav2_bringup/launch/tb3_gz_robot_launch.py

Lines changed: 0 additions & 106 deletions
This file was deleted.

0 commit comments

Comments
 (0)