Skip to content

Commit

Permalink
implement launch priority for the mapserver parameter yaml_filename
Browse files Browse the repository at this point in the history
minor fix

fix commit

reincluded rewritten function

comment remaining lines for yaml_filename

removed default_value

issue with composable node

alternative soltion to the condition param not working in composable node

remove unused import

remove comments and reorder composablenode execution

fixing commit

fixing format

fixing lint

Update nav2_bringup/params/nav2_params.yaml

Co-authored-by: Steve Macenski <[email protected]>
  • Loading branch information
stevedanomodolor and SteveMacenski committed Oct 15, 2022
1 parent c5de9b9 commit d901182
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 17 deletions.
7 changes: 2 additions & 5 deletions nav2_bringup/launch/bringup_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,10 @@ def generate_launch_description():
remappings = [('/tf', 'tf'),
('/tf_static', 'tf_static')]

# Create our own temporary YAML files that include substitutions
param_substitutions = {
'yaml_filename': map_yaml_file}

configured_params = RewrittenYaml(
source_file=params_file,
root_key=namespace,
param_rewrites=param_substitutions,
param_rewrites={},
convert_types=True)

stdout_linebuf_envvar = SetEnvironmentVariable(
Expand All @@ -83,6 +79,7 @@ def generate_launch_description():

declare_map_yaml_cmd = DeclareLaunchArgument(
'map',
default_value='',
description='Full path to map yaml file to load')

declare_use_sim_time_cmd = DeclareLaunchArgument(
Expand Down
51 changes: 44 additions & 7 deletions nav2_bringup/launch/localization_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, GroupAction, SetEnvironmentVariable
from launch.actions import DeclareLaunchArgument, GroupAction
from launch.actions import SetEnvironmentVariable
from launch.conditions import IfCondition
from launch.conditions import LaunchConfigurationEquals
from launch.conditions import LaunchConfigurationNotEquals
from launch.substitutions import LaunchConfiguration, PythonExpression
from launch_ros.actions import LoadComposableNodes, SetParameter
from launch_ros.actions import Node
Expand Down Expand Up @@ -51,14 +54,10 @@ def generate_launch_description():
remappings = [('/tf', 'tf'),
('/tf_static', 'tf_static')]

# Create our own temporary YAML files that include substitutions
param_substitutions = {
'yaml_filename': map_yaml_file}

configured_params = RewrittenYaml(
source_file=params_file,
root_key=namespace,
param_rewrites=param_substitutions,
param_rewrites={},
convert_types=True)

stdout_linebuf_envvar = SetEnvironmentVariable(
Expand All @@ -71,6 +70,7 @@ def generate_launch_description():

declare_map_yaml_cmd = DeclareLaunchArgument(
'map',
default_value='',
description='Full path to map yaml file to load')

declare_use_sim_time_cmd = DeclareLaunchArgument(
Expand Down Expand Up @@ -108,6 +108,7 @@ def generate_launch_description():
actions=[
SetParameter("use_sim_time", use_sim_time),
Node(
condition=LaunchConfigurationEquals('map', ''),
package='nav2_map_server',
executable='map_server',
name='map_server',
Expand All @@ -117,6 +118,18 @@ def generate_launch_description():
parameters=[configured_params],
arguments=['--ros-args', '--log-level', log_level],
remappings=remappings),
Node(
condition=LaunchConfigurationNotEquals('map', ''),
package='nav2_map_server',
executable='map_server',
name='map_server',
output='screen',
respawn=use_respawn,
respawn_delay=2.0,
parameters=[configured_params,
{'yaml_filename': map_yaml_file}],
arguments=['--ros-args', '--log-level', log_level],
remappings=remappings),
Node(
package='nav2_amcl',
executable='amcl',
Expand All @@ -137,20 +150,44 @@ def generate_launch_description():
{'node_names': lifecycle_nodes}])
]
)

# LoadComposableNode for map server twice depending if we should use the
# value of map from a CLI or launch default or user defined value in the
# yaml configuration file. They are separated since the conditions
# currently only work on the LoadComposableNodes commands and not on the
# ComposableNode node function itself
# See https://github.com/ros2/launch_ros/issues/328
load_composable_nodes = GroupAction(
condition=IfCondition(use_composition),
actions=[
SetParameter("use_sim_time", use_sim_time),
LoadComposableNodes(
target_container=container_name,
condition=LaunchConfigurationEquals('map', ''),
composable_node_descriptions=[
ComposableNode(
package='nav2_map_server',
plugin='nav2_map_server::MapServer',
name='map_server',
parameters=[configured_params],
remappings=remappings),
],
),
LoadComposableNodes(
target_container=container_name,
condition=LaunchConfigurationNotEquals('map', ''),
composable_node_descriptions=[
ComposableNode(
package='nav2_map_server',
plugin='nav2_map_server::MapServer',
name='map_server',
parameters=[configured_params,
{'yaml_filename': map_yaml_file}],
remappings=remappings),
],
),
LoadComposableNodes(
target_container=container_name,
composable_node_descriptions=[
ComposableNode(
package='nav2_amcl',
plugin='nav2_amcl::AmclNode',
Expand Down
11 changes: 6 additions & 5 deletions nav2_bringup/params/nav2_params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,12 @@ global_costmap:
inflation_radius: 0.55
always_send_full_costmap: True

map_server:
ros__parameters:
# Overridden in launch by the "map" launch configuration or provided default value.
# To use in yaml, remove the default "map" value in the tb3_simulation_launch.py file & provide full path to map below.
yaml_filename: ""
# The yaml_filename does not need to be specified since it going to be set by defaults in launch.
# If you'd rather set it in the yaml, remove the default "map" value in the tb3_simulation_launch.py
# file & provide full path to map below. If CLI map configuration or launch default is provided, that will be used.
# map_server:
# ros__parameters:
# yaml_filename: ""

map_saver:
ros__parameters:
Expand Down

0 comments on commit d901182

Please sign in to comment.