Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 84 additions & 6 deletions launch/navigation_neo.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, GroupAction, GroupAction, IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.conditions import IfCondition
from launch.conditions import IfCondition, UnlessCondition
from launch.substitutions import LaunchConfiguration, PythonExpression
from launch_ros.actions import Node, SetParameter
from launch_ros.descriptions import ParameterFile
Expand All @@ -37,12 +37,16 @@ def generate_launch_description():
params_file = LaunchConfiguration('params_file')
use_multi_robots = LaunchConfiguration('use_multi_robots')
use_rviz = LaunchConfiguration('use_rviz')
graph_filepath = LaunchConfiguration('graph_filepath')
use_route = LaunchConfiguration('use_route')

lifecycle_nodes = ['controller_server',
'planner_server',
'behavior_server',
'bt_navigator',
'waypoint_follower']
lifecycle_nodes_with_route = lifecycle_nodes + ['smoother_server',
'route_server']

remappings = [('/tf', 'tf'),
('/tf_static', 'tf_static')]
Expand Down Expand Up @@ -81,13 +85,32 @@ def generate_launch_description():
declare_use_multi_robots_cmd = DeclareLaunchArgument(
'use_multi_robots', default_value='False',
description='A flag to remove the remappings')

declare_use_rviz_cmd = DeclareLaunchArgument(
'use_rviz', default_value='True',
description='Launch RViz for visualization'
)

declare_graph_filepath_cmd = DeclareLaunchArgument(
'graph_filepath', default_value='',
description='Full path to the graph file for route planning'
)

declare_use_route_cmd = DeclareLaunchArgument(
'use_route', default_value='False',
description='Launch route-specific nodes like smoother and route server'
)

route_rviz_config = os.path.join(bringup_dir, 'rviz', 'route_server.rviz')
single_robot_rviz_config = os.path.join(bringup_dir, 'rviz', 'single_robot.rviz')
rviz_config = PythonExpression([
'"', route_rviz_config, '" if "',
use_route, '".lower() == "true" else "',
single_robot_rviz_config, '"'
])

load_nodes = GroupAction(
condition=IfCondition(PythonExpression(['not ', use_multi_robots])),
condition=UnlessCondition(use_multi_robots),
actions=[
SetParameter('use_sim_time', use_sim_time),
Node(
Expand Down Expand Up @@ -124,14 +147,41 @@ def generate_launch_description():
output='screen',
parameters=[configured_params],
remappings=remappings),
Node(
package='nav2_smoother',
executable='smoother_server',
name='smoother_server',
output='screen',
parameters=[configured_params],
remappings=remappings,
condition=IfCondition(use_route)),
Node(
package='nav2_route',
executable='route_server',
name='route_server',
output='screen',
parameters=[configured_params,
{'graph_filepath': graph_filepath}],
remappings=remappings,
condition=IfCondition(use_route)),
Node(
package='nav2_lifecycle_manager',
executable='lifecycle_manager',
name='lifecycle_manager_navigation',
output='screen',
parameters=[{'use_sim_time': use_sim_time},
{'autostart': autostart},
{'node_names': lifecycle_nodes}]),
{'node_names': lifecycle_nodes_with_route}],
condition=IfCondition(use_route)),
Node(
package='nav2_lifecycle_manager',
executable='lifecycle_manager',
name='lifecycle_manager_navigation',
output='screen',
parameters=[{'use_sim_time': use_sim_time},
{'autostart': autostart},
{'node_names': lifecycle_nodes}],
condition=UnlessCondition(use_route)),
]
)

Expand Down Expand Up @@ -168,18 +218,43 @@ def generate_launch_description():
name='waypoint_follower',
output='screen',
parameters=[configured_params]),
Node(
package='nav2_smoother',
executable='smoother_server',
name='smoother_server',
output='screen',
parameters=[configured_params],
condition=IfCondition(use_route)),
Node(
package='nav2_route',
executable='route_server',
name='route_server',
output='screen',
parameters=[configured_params,
{'graph_filepath': graph_filepath}],
condition=IfCondition(use_route)),
Node(
package='nav2_lifecycle_manager',
executable='lifecycle_manager',
name='lifecycle_manager_navigation',
output='screen',
parameters=[{'use_sim_time': use_sim_time},
{'autostart': autostart},
{'node_names': lifecycle_nodes_with_route}],
condition=IfCondition(use_route)),
Node(
package='nav2_lifecycle_manager',
executable='lifecycle_manager',
name='lifecycle_manager_navigation',
output='screen',
parameters=[{'use_sim_time': use_sim_time},
{'autostart': autostart},
{'node_names': lifecycle_nodes}]),
{'node_names': lifecycle_nodes}],
condition=UnlessCondition(use_route)),
]
)

# Start RViz if use_rviz is True
# Start RViz with the chosen config
start_rviz = IncludeLaunchDescription(
condition=IfCondition(use_rviz),
launch_description_source=PythonLaunchDescriptionSource(
Expand All @@ -189,6 +264,7 @@ def generate_launch_description():
'use_namespace': use_multi_robots,
'use_sim_time': use_sim_time,
'rviz_output': 'log',
'rviz_config': rviz_config,
}.items(),
)
# Create the launch description and populate
Expand All @@ -201,6 +277,8 @@ def generate_launch_description():
ld.add_action(declare_autostart_cmd)
ld.add_action(declare_use_multi_robots_cmd)
ld.add_action(declare_use_rviz_cmd)
ld.add_action(declare_use_route_cmd)
ld.add_action(declare_graph_filepath_cmd)
# Add the actions to launch all of the navigation nodes
ld.add_action(load_nodes)
ld.add_action(load_nodes_multi_robot)
Expand Down
5 changes: 5 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
<depend>nav2_common</depend>
<depend>slam_toolbox</depend>

<exec_depend>rclpy</exec_depend>
<exec_depend>geometry_msgs</exec_depend>
<exec_depend>std_msgs</exec_depend>
<exec_depend>nav2_simple_commander</exec_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
Expand Down
Loading