-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy nav2 launch file from rolling branch
with added headless LaunchConfiguration as this hasn't been back ported to humble - ros-navigation/navigation2#3527
- Loading branch information
Showing
3 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,6 @@ | |
# Files | ||
.dockerignore | ||
.gitignore | ||
|
||
# Python | ||
__pycache__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
# Visual Studio Code files | ||
.vscode | ||
|
||
# Python | ||
__pycache__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# Copyright (c) 2021 Samsung Research America | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import os | ||
|
||
from ament_index_python.packages import get_package_share_directory | ||
|
||
from launch import LaunchDescription | ||
from launch.actions import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescription | ||
from launch.conditions import IfCondition | ||
from launch.launch_description_sources import PythonLaunchDescriptionSource | ||
from launch.substitutions import LaunchConfiguration, PythonExpression | ||
from launch_ros.actions import Node | ||
|
||
|
||
def generate_launch_description(): | ||
warehouse_dir = get_package_share_directory('aws_robomaker_small_warehouse_world') | ||
nav2_bringup_dir = get_package_share_directory('nav2_bringup') | ||
python_commander_dir = get_package_share_directory('nav2_simple_commander') | ||
|
||
map_yaml_file = os.path.join(warehouse_dir, 'maps', '005', 'map.yaml') | ||
world = os.path.join(python_commander_dir, 'warehouse.world') | ||
|
||
# Launch configuration variables | ||
use_rviz = LaunchConfiguration('use_rviz') | ||
headless = LaunchConfiguration('headless') | ||
|
||
# Declare the launch arguments | ||
declare_use_rviz_cmd = DeclareLaunchArgument( | ||
'use_rviz', | ||
default_value='True', | ||
description='Whether to start RVIZ') | ||
|
||
declare_simulator_cmd = DeclareLaunchArgument( | ||
'headless', | ||
default_value='False', | ||
description='Whether to execute gzclient)') | ||
|
||
# start the simulation | ||
start_gazebo_server_cmd = ExecuteProcess( | ||
cmd=['gzserver', '-s', 'libgazebo_ros_factory.so', world], | ||
cwd=[warehouse_dir], output='screen') | ||
|
||
start_gazebo_client_cmd = ExecuteProcess( | ||
condition=IfCondition(PythonExpression(['not ', headless])), | ||
cmd=['gzclient'], | ||
cwd=[warehouse_dir], output='screen') | ||
|
||
urdf = os.path.join(nav2_bringup_dir, 'urdf', 'turtlebot3_waffle.urdf') | ||
start_robot_state_publisher_cmd = Node( | ||
package='robot_state_publisher', | ||
executable='robot_state_publisher', | ||
name='robot_state_publisher', | ||
output='screen', | ||
arguments=[urdf]) | ||
|
||
# start the visualization | ||
rviz_cmd = IncludeLaunchDescription( | ||
PythonLaunchDescriptionSource( | ||
os.path.join(nav2_bringup_dir, 'launch', 'rviz_launch.py')), | ||
condition=IfCondition(use_rviz), | ||
launch_arguments={'namespace': '', | ||
'use_namespace': 'False'}.items()) | ||
|
||
# start navigation | ||
bringup_cmd = IncludeLaunchDescription( | ||
PythonLaunchDescriptionSource( | ||
os.path.join(nav2_bringup_dir, 'launch', 'bringup_launch.py')), | ||
launch_arguments={'map': map_yaml_file}.items()) | ||
|
||
# start the demo autonomy task | ||
demo_cmd = Node( | ||
package='nav2_simple_commander', | ||
executable='demo_security', | ||
emulate_tty=True, | ||
output='screen') | ||
|
||
ld = LaunchDescription() | ||
ld.add_action(declare_use_rviz_cmd) | ||
ld.add_action(declare_simulator_cmd) | ||
ld.add_action(start_gazebo_server_cmd) | ||
ld.add_action(start_gazebo_client_cmd) | ||
ld.add_action(start_robot_state_publisher_cmd) | ||
ld.add_action(rviz_cmd) | ||
ld.add_action(bringup_cmd) | ||
ld.add_action(demo_cmd) | ||
return ld |