Skip to content

Commit 75e22a3

Browse files
kaiaaiclaude
andcommitted
navigation.launch.py: auto_localize seeds AMCL to skip the manual pose estimate
AMCL (navigation.yaml set_initial_pose: false) waits for a manual RViz "2D Pose Estimate" before it publishes map->odom, so the map frame never connects to TF even though the map loads -- which blocks anything wanting the map frame (e.g. bump_map wall-segment estimation). Add an auto_localize option that seeds AMCL at a known start pose via the existing oomwoo_sim_support initialpose_pub node (publishes /initialpose, exits when AMCL converges). Only in localization mode (slam=False), and by default only in sim (auto_localize=sim) so real-robot bringup stays manual. x_pose / y_pose / yaw default to the oomwoo_gazebo world.launch.py spawn (-2.0, -0.5, 0); AMCL converges from a rough pose so they need only be close. Adds the in-tree oomwoo_sim_support exec_depend (check_rosdeps now resolves workspace-local packages). Verified: ament lints + check_rosdeps pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent ccd179b commit 75e22a3

2 files changed

Lines changed: 45 additions & 2 deletions

File tree

src/oomwoo_bringup/launch/navigation.launch.py

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,16 @@
2727
from launch.substitutions import LaunchConfiguration
2828

2929
from launch_ros.actions import Node
30+
from launch_ros.parameter_descriptions import ParameterValue
3031

3132

3233
def make_nodes(context: LaunchContext, robot_model, map_arg, use_sim_time,
33-
slam):
34+
slam, x_pose, y_pose, yaw, auto_localize):
3435
robot_model_str = context.perform_substitution(robot_model)
3536
map_path_str = context.perform_substitution(map_arg)
3637
use_sim_time_str = context.perform_substitution(use_sim_time)
3738
slam_str = context.perform_substitution(slam)
39+
auto_str = context.perform_substitution(auto_localize)
3840

3941
if len(robot_model_str) == 0:
4042
robot_model_str = config.get_var('robot.model')
@@ -55,7 +57,7 @@ def make_nodes(context: LaunchContext, robot_model, map_arg, use_sim_time,
5557
print('Nav2 config : {}'.format(nav_config_path))
5658
print('Map : {}'.format(map_path_str))
5759

58-
return [
60+
nodes = [
5961
IncludeLaunchDescription(
6062
PythonLaunchDescriptionSource([
6163
os.path.join(get_package_share_path('nav2_bringup'), 'launch'),
@@ -77,6 +79,24 @@ def make_nodes(context: LaunchContext, robot_model, map_arg, use_sim_time,
7779
)
7880
]
7981

82+
# Seed AMCL at the known start pose so map->odom appears WITHOUT the manual
83+
# RViz "2D Pose Estimate". Only in localization mode (slam=False), and by
84+
# default only in sim (auto_localize=sim); real-robot bringup stays manual.
85+
# AMCL converges from a rough pose, so x_pose/y_pose/yaw need only be close.
86+
localizing = slam_str.strip().lower() in ('false', '0')
87+
auto = auto_str == 'true' or (
88+
auto_str == 'sim' and use_sim_time_str.lower() == 'true')
89+
if localizing and auto:
90+
nodes.append(Node(
91+
package='oomwoo_sim_support', executable='initialpose_pub',
92+
name='initialpose_pub', output='screen',
93+
parameters=[{
94+
'use_sim_time': use_sim_time_str.lower() == 'true',
95+
'x': ParameterValue(x_pose, value_type=float),
96+
'y': ParameterValue(y_pose, value_type=float),
97+
'yaw': ParameterValue(yaw, value_type=float)}]))
98+
return nodes
99+
80100

81101
def generate_launch_description():
82102
return LaunchDescription([
@@ -105,10 +125,32 @@ def generate_launch_description():
105125
choices=['True', 'False'],
106126
description='Navigate while creating a new map'
107127
),
128+
# Auto-localization: seed AMCL at the known start pose to skip the manual
129+
# RViz "2D Pose Estimate". Defaults match oomwoo_gazebo world.launch.py.
130+
DeclareLaunchArgument(
131+
'auto_localize', default_value='sim',
132+
choices=['true', 'false', 'sim'],
133+
description="Seed AMCL at (x_pose,y_pose,yaw) so map->odom appears "
134+
"without the manual 2D Pose Estimate. 'sim' = only when "
135+
'use_sim_time:=true; real-robot bringup stays manual.'
136+
),
137+
DeclareLaunchArgument(
138+
'x_pose', default_value='-2.0',
139+
description='Known start x for auto_localize (m)'),
140+
DeclareLaunchArgument(
141+
'y_pose', default_value='-0.5',
142+
description='Known start y for auto_localize (m)'),
143+
DeclareLaunchArgument(
144+
'yaw', default_value='0.0',
145+
description='Known start yaw for auto_localize (rad)'),
108146
OpaqueFunction(function=make_nodes, args=[
109147
LaunchConfiguration('robot_model'),
110148
LaunchConfiguration('map'),
111149
LaunchConfiguration('use_sim_time'),
112150
LaunchConfiguration('slam'),
151+
LaunchConfiguration('x_pose'),
152+
LaunchConfiguration('y_pose'),
153+
LaunchConfiguration('yaw'),
154+
LaunchConfiguration('auto_localize'),
113155
]),
114156
])

src/oomwoo_bringup/package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<exec_depend>xacro</exec_depend>
3434
<exec_depend>cartographer_ros</exec_depend>
3535
<exec_depend>nav2_bringup</exec_depend>
36+
<exec_depend>oomwoo_sim_support</exec_depend>
3637

3738
<test_depend>ament_lint_auto</test_depend>
3839
<test_depend>ament_lint_common</test_depend>

0 commit comments

Comments
 (0)