forked from zbw/yiliao2026
实现了slam负责定位,map_server实现全局地图发布,从而实现全局地图定位和导航
但是无法实现在线更新地图
This commit is contained in:
@@ -31,6 +31,7 @@ def generate_launch_description():
|
||||
pkg_dir, 'maps', 'my_map.posegraph')
|
||||
|
||||
# =============================3.slam_toolbox 定位模式(替代 AMCL)=========================================
|
||||
# 注意:slam_toolbox 的 /map 重映射到 /slam_map,避免覆盖 map_server 的全量地图
|
||||
slam_toolbox_node = Node(
|
||||
package='slam_toolbox',
|
||||
executable='localization_slam_toolbox_node',
|
||||
@@ -39,31 +40,20 @@ def generate_launch_description():
|
||||
parameters=[slam_params_file,
|
||||
{'use_sim_time': True,
|
||||
'map_file_name': posegraph_path}],
|
||||
remappings=[('/map', '/slam_map')],
|
||||
)
|
||||
|
||||
# =============================4.仅启动 nav2 navigation(不含 localization)=================================
|
||||
# 因为 slam_toolbox 已经替代了 AMCL,不需要再跑 localization_launch
|
||||
navigation_launch = IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(
|
||||
[nav2_bringup_dir, '/launch', '/navigation_launch.py']),
|
||||
launch_arguments={
|
||||
'use_sim_time': use_sim_time,
|
||||
'params_file': nav2_param_path}.items(),
|
||||
)
|
||||
|
||||
# =============================5.map_server 单独启动(提供静态地图给 costmap)===============================
|
||||
# =============================4.map_server 提供全量静态地图给 global_costmap =============================
|
||||
map_server_node = Node(
|
||||
package='nav2_map_server',
|
||||
executable='map_server',
|
||||
name='map_server',
|
||||
output='screen',
|
||||
parameters=[nav2_param_path,
|
||||
{'yaml_filename': map_yaml_path,
|
||||
parameters=[{'yaml_filename': map_yaml_path,
|
||||
'use_sim_time': True}],
|
||||
)
|
||||
|
||||
# map_server 生命周期自动管理
|
||||
map_server_lifecycle_node = Node(
|
||||
map_server_lifecycle = Node(
|
||||
package='nav2_lifecycle_manager',
|
||||
executable='lifecycle_manager',
|
||||
name='lifecycle_manager_map',
|
||||
@@ -73,7 +63,17 @@ def generate_launch_description():
|
||||
'node_names': ['map_server']}],
|
||||
)
|
||||
|
||||
# =============================6.Gazebo仿真设置==========================================================
|
||||
# =============================5.仅启动 nav2 navigation(不含 localization)=================================
|
||||
# 因为 slam_toolbox 已经替代了 AMCL,不需要再跑 localization_launch
|
||||
navigation_launch = IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(
|
||||
[nav2_bringup_dir, '/launch', '/navigation_launch.py']),
|
||||
launch_arguments={
|
||||
'use_sim_time': use_sim_time,
|
||||
'params_file': nav2_param_path}.items(),
|
||||
)
|
||||
|
||||
# =============================5.Gazebo仿真设置==========================================================
|
||||
robot_name_in_model = 'mycar'
|
||||
default_model_path = os.path.join(
|
||||
origincar_urdf_dir, "urdf", "origincar.urdf")
|
||||
@@ -109,7 +109,7 @@ def generate_launch_description():
|
||||
ld.add_action(spawn_entity_cmd)
|
||||
ld.add_action(robot_state_publisher)
|
||||
ld.add_action(map_server_node)
|
||||
ld.add_action(map_server_lifecycle_node)
|
||||
ld.add_action(map_server_lifecycle)
|
||||
ld.add_action(slam_toolbox_node)
|
||||
ld.add_action(navigation_launch)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user