Skip to content

Commit

Permalink
changed slam launch file according to the comments for the PR #4211
Browse files Browse the repository at this point in the history
Signed-off-by: Ibrahim Özcan <[email protected]>
  • Loading branch information
Ibrahim Özcan committed Apr 12, 2024
1 parent 5bf14fc commit 0442db6
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions nav2_bringup/launch/slam_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, GroupAction, IncludeLaunchDescription
from launch.actions import DeclareLaunchArgument, GroupAction, IncludeLaunchDescription, LogInfo
from launch.conditions import IfCondition, UnlessCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node, SetParameter
from launch_ros.actions import Node, SetParameter, SetRemap
from launch_ros.descriptions import ParameterFile
from nav2_common.launch import HasNodeParams, RewrittenYaml

Expand Down Expand Up @@ -87,8 +87,9 @@ def generate_launch_description():
'log_level', default_value='info', description='log level'
)

# Nodes launching commands


# Nodes launching commands
start_map_server = GroupAction(
actions=[
SetParameter('use_sim_time', use_sim_time),
Expand Down Expand Up @@ -119,21 +120,31 @@ def generate_launch_description():
source_file=params_file, node_name='slam_toolbox'
)

start_slam_toolbox_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(slam_launch_file),
launch_arguments={'use_sim_time': use_sim_time}.items(),
condition=UnlessCondition(has_slam_toolbox_params),
)
start_slam_toolbox_cmd = GroupAction(

start_slam_toolbox_cmd_with_params = IncludeLaunchDescription(
PythonLaunchDescriptionSource(slam_launch_file),
launch_arguments={
'use_sim_time': use_sim_time,
'slam_params_file': params_file,
}.items(),
condition=IfCondition(has_slam_toolbox_params),
actions=[
#Remapping required to have a slam session subscribe & publish in optional namespaces B#
SetRemap(src= '/scan', dst= 'scan'),
SetRemap(src='/tf', dst='tf'),
SetRemap(src='/tf_static', dst='tf_static'),
SetRemap(src='/map', dst='map'),

IncludeLaunchDescription(
PythonLaunchDescriptionSource(slam_launch_file),
launch_arguments={'use_sim_time': use_sim_time}.items(),
condition=UnlessCondition(has_slam_toolbox_params),
),

IncludeLaunchDescription(
PythonLaunchDescriptionSource(slam_launch_file),
launch_arguments={'use_sim_time': use_sim_time,
'slam_params_file': params_file,}.items(),
condition=IfCondition(has_slam_toolbox_params),
)
]
)


ld = LaunchDescription()

# Declare the launch options
Expand All @@ -149,6 +160,5 @@ def generate_launch_description():

# Running SLAM Toolbox (Only one of them will be run)
ld.add_action(start_slam_toolbox_cmd)
ld.add_action(start_slam_toolbox_cmd_with_params)

return ld

0 comments on commit 0442db6

Please sign in to comment.