ROS2 机器人在静止下地图无法保存,需在移动时才能保存地图
-
大佬 你们好
版本 20.04 foxy
在使用gmapping建好地图后,使用 map_saver无法正常保存地图,显示结果图下日志如下
ros2 run nav2_map_server map_saver_cli [INFO] [1676945889.284354723] [map_saver]: map_saver lifecycle node launched. Waiting on external lifecycle transitions to activate See https://design.ros2.org/articles/node_lifecycle.html for more information. [INFO] [1676945889.284500481] [map_saver]: Creating [INFO] [1676945889.284764118] [map_saver]: Saving map from 'map' topic to '' file [WARN] [1676945889.284791241] [map_saver]: Free threshold unspecified. Setting it to default value: 0.250000 [WARN] [1676945889.284822450] [map_saver]: Occupied threshold unspecified. Setting it to default value: 0.650000 [ERROR] [1676945891.288356825] [map_saver]: Failed to save the map: timeout [INFO] [1676945891.288500232] [map_saver]: Destroying
在移动时地图就能正常保存
另附上我的tf树
-
我似乎是找到了原因,可能是Qos没有相匹配,导致信息不能相互传输。但是具体修改哪个东西的qos我不是很懂,因为map不是gmapping自己发布的嘛,那他这个要和什么相匹配呢。
这是rviz上的日志:ros2 run nav2_map_server map_saver_cli [INFO] [1677118775.546330774] [map_saver]: map_saver lifecycle node launched. Waiting on external lifecycle transitions to activate See https://design.ros2.org/articles/node_lifecycle.html for more information. [INFO] [1677118775.546418351] [map_saver]: Creating [INFO] [1677118775.546718313] [map_saver]: Saving map from 'map' topic to '' file [WARN] [1677118775.546743987] [map_saver]: Free threshold unspecified. Setting it to default value: 0.250000 [WARN] [1677118775.546763269] [map_saver]: Occupied threshold unspecified. Setting it to default value: 0.650000 [WARN] [1677118775.547629798] [map_saver]: New publisher discovered on topic '/map', offering incompatible QoS. No messages will be sent to it. Last incompatible policy: DURABILITY_QOS_POLICY [ERROR] [1677118777.547682744] [map_saver]: Failed to spin map subscription [INFO] [1677118777.548951015] [map_saver]: Destroying
这是gmapping报错部分:
[slam_gmapping-6] [WARN] [1677118742.381892406] [slam_gmapping]: New subscription discovered on topic '/map', requesting incompatible QoS. No messages will be sent to it. Last incompatible policy: DURABILITY_QOS_POLICY
-
@1157354382 ros2 topic info /mqp -v 可以查看详细的QOS
-
@小鱼 感谢小鱼儿的帮助。我将 gmapping的 Durability 修改成了 transient_local ,map_saver保持一致了,也能进行保存工作。困扰了快一个星期了,感谢帮助。
-
我这里用ros2 eloquent也是gmapping建图,建好图之后直接执行
ros2 run nav2_map_server map_saver
就可以直接保存了
-
@1157354382 我在ros2 galactic中也遇到了和你一样的问题,想问下你是怎么修改gmapping的Durabiliy的呢
-
@374870361
void SlamGmapping::startLiveSlam() 里面的内容,好像是这一块,好久没搞了// sst_ = this->create_publisher<nav_msgs::msg::OccupancyGrid>("map", rclcpp::SystemDefaultsQoS()); sstm_ = this->create_publisher<nav_msgs::msg::MapMetaData>("map_metadata", rclcpp::SystemDefaultsQoS()); scan_filter_sub_ = std::make_shared<message_filters::Subscriber<sensor_msgs::msg::LaserScan>> (node_, "scan", rclcpp::SensorDataQoS().get_rmw_qos_profile()); sst_ = this->create_publisher<nav_msgs::msg::OccupancyGrid>("map", rclcpp::QoS(rclcpp::QoSInitialization::from_rmw(rmw_qos_profile_system_privated), rmw_qos_profile_system_privated)); // sub_ = this->create_subscription<sensor_msgs::msg::LaserScan>( // "scan", rclcpp::SensorDataQoS(), // std::bind(&SlamGmapping::laserCallback, this, std::placeholders::_1));
我现在是使用 cartographer 来建图了,感觉也挺不错的