小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
关于ros2 humble版本的规划器从nav2_navfn_planner替换nav2_smac_planner问题
-
标题:关于ros2 humble版本的规划器从nav2_navfn_planner替换nav2_smac_planner失败的问题
问题描述:
根据nav2文档教程中提到,nav2中默认使用的规划器为nav2_navfn_planner,目前我想替换为nav2_smac_planner去使用优化的A*算法来导航,根据教程中,将nav2_params.yaml文件的planner_server:部分修改为配置教程中部分后并不能正确配置。planner_server: ros__parameters: planner_plugins: ["GridBased"] use_sim_time: True GridBased: plugin: "nav2_smac_planner/SmacPlanner2D" tolerance: 0.125 # tolerance for planning if unable to reach exact pose, in meters downsample_costmap: false # whether or not to downsample the map downsampling_factor: 1 # multiplier for the resolution of the costmap layer (e.g. 2 on a 5cm costmap would be 10cm) allow_unknown: true # allow traveling in unknown space max_iterations: 1000000 # maximum total iterations to search for before failing (in case unreachable), set to -1 to disable max_on_approach_iterations: 1000 # maximum number of iterations to attempt to reach goal once in tolerance max_planning_time: 2.0 # max time in s for planner to plan, smooth cost_travel_multiplier: 2.0 # Cost multiplier to apply to search to steer away from high cost areas. Larger values will place in the center of aisles more exactly (if non-`FREE` cost potential field exists) but take slightly longer to compute. To optimize for speed, a value of 1.0 is reasonable. A reasonable tradeoff value is 2.0. A value of 0.0 effective disables steering away from obstacles and acts like a naive binary search A*. use_final_approach_orientation: false # Whether to set the final path pose at the goal's orientation to the requested orientation (false) or in line with the approach angle so the robot doesn't rotate to heading (true) smoother: max_iterations: 1000 w_smooth: 0.3 w_data: 0.2 tolerance: 1e-10
出现的问题终端有报错:
[component_container_isolated-6] [ERROR] [1723894069.032391537] [planner_server]: Caught exception in callback for transition 10 [component_container_isolated-6] [ERROR] [1723894069.032673442] [planner_server]: Original error: parameter 'GridBased.smoother.tolerance' has invalid type: Wrong parameter type, parameter {GridBased.smoother.tolerance} is of type {double}, setting it to {string} is not allowed. [component_container_isolated-6] [WARN] [1723894069.032926659] [planner_server]: Error occurred while doing error handling. [component_container_isolated-6] [FATAL] [1723894069.033246119] [planner_server]: Lifecycle node planner_server does not have error state implemented [component_container_isolated-6] [ERROR] [1723894069.034150291] [lifecycle_manager_navigation]: Failed to change state for node: planner_server [component_container_isolated-6] [ERROR] [1723894069.034172836] [lifecycle_manager_navigation]: Failed to bring up all requested nodes. Aborting bringup.
除此之外,rivz端的Global Costmap状态显示 :NO map received,图片如下,也就是说更改了nav2_smac_planne规划器后,代价地图配置不上。
尝试过的解决方法:
查阅过许多资料,并没有查出怎么去修改。所以请大家帮我看看,谢谢。 -
从你描述的问题来看,主要存在两个主要问题:
-
参数类型错误:错误提示表明
GridBased.smoother.tolerance
参数的类型被错误地设置为字符串(string),而它应该是双精度浮点数(double)。这通常是由于YAML文件格式错误或编辑时的误输入导致的。 -
地图未接收到:这通常意味着地图服务器(如
map_server
)没有正确运行,或者地图数据没有正确加载。这也可能由于配置错误或文件路径问题导致。
解决步骤
1. 修复参数类型错误
首先,确保
nav2_params.yaml
文件中GridBased.smoother.tolerance
的值是一个有效的数字,而不是被错误地引用或格式化为字符串。你的配置应该类似于:planner_server: ros__parameters: planner_plugins: ["GridBased"] use_sim_time: True GridBased: plugin: "nav2_smac_planner/SmacPlanner2D" tolerance: 0.125 downsample_costmap: false downsampling_factor: 1 allow_unknown: true max_iterations: 1000000 max_on_approach_iterations: 1000 max_planning_time: 2.0 cost_travel_multiplier: 2.0 use_final_approach_orientation: false smoother: max_iterations: 1000 w_smooth: 0.3 w_data: 0.2 tolerance: 1e-10 # 确保这里是一个数字
2. 检查地图服务器
确保你的地图服务器(如
map_server
)正在运行,并且正确加载了地图文件。检查以下几个方面:- 地图文件路径:确保在
map_server
的配置中指定的地图文件路径是正确的。 - 地图服务器配置:检查
map_server
的YAML配置文件,确认所有参数都设置正确。 - ROS2服务状态:使用
ros2 service list
查看是否有map_server
的服务,并使用ros2 topic list
查看是否发布了/map
和/map_metadata
等话题。
3. 重新启动所有节点
在修改配置后,确保重新启动所有相关的ROS2节点,包括
map_server
、planner_server
等。4. 检查依赖和版本
确保你使用的
nav2_smac_planner
与你的ROS2版本(Humble)兼容。如果可能,尝试更新或重新安装相关包。5. 查看日志和调试
使用
ros2 topic echo
和ros2 bag record
等工具来查看和记录话题数据,以帮助诊断问题。6. 查阅文档和社区
如果问题仍未解决,查阅最新的Nav2文档或搜索ROS2社区和论坛,看看是否有其他人遇到并解决了类似的问题。
通过这些步骤,你应该能够解决配置
nav2_smac_planner
时遇到的问题,并确保地图正确加载和显示。
以上为生成回答,仅供参考~
-
-
此回复已被删除! -
@2939227899 在 关于ros2 humble版本的规划器从nav2_navfn_planner替换nav2_smac_planner问题 中说:
[component_container_isolated-6] [ERROR] [1723894069.032391537] [planner_server]: Caught exception in callback for transition 10
[component_container_isolated-6] [ERROR] [1723894069.032673442] [planner_server]: Original error: parameter 'GridBased.smoother.tolerance' has inval参数异常导致启动失败,建议从这个日志检查
-
@小鱼 好了,谢谢大佬