紧急通知:禁止一切关于政治&VPN翻墙等话题,发现相关帖子会立马删除封号
小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
ROS2 NAV2 获取全局地图接口不能指定获取位置
-
nav2 提供的service 话题/global_costmap/global_costmap定义:
nav2_msgs/CostmapMetaData specs builtin_interfaces/Time map_load_time int32 sec uint32 nanosec builtin_interfaces/Time update_time int32 sec uint32 nanosec string layer float32 resolution uint32 size_x uint32 size_y geometry_msgs/Pose origin Point position float64 x float64 y float64 z Quaternion orientation float64 x 0 float64 y 0 float64 z 0 float64 w 1
从接口定义来看入参支持设置获取的地图位置和大小,但实际测试无论参数填什么都会传回整张地图
查看了源码:void Costmap2DPublisher::costmap_service_callback( const std::shared_ptr<rmw_request_id_t>/*request_header*/, const std::shared_ptr<nav2_msgs::srv::GetCostmap::Request>/*request*/, const std::shared_ptr<nav2_msgs::srv::GetCostmap::Response> response) { RCLCPP_DEBUG(logger_, "Received costmap service request"); // TODO(bpwilcox): Grab correct orientation information tf2::Quaternion quaternion; quaternion.setRPY(0.0, 0.0, 0.0); auto size_x = costmap_->getSizeInCellsX(); auto size_y = costmap_->getSizeInCellsY(); auto data_length = size_x * size_y; unsigned char * data = costmap_->getCharMap(); auto current_time = clock_->now(); response->map.header.stamp = current_time; response->map.header.frame_id = global_frame_; response->map.metadata.size_x = size_x; response->map.metadata.size_y = size_y; response->map.metadata.resolution = costmap_->getResolution(); response->map.metadata.layer = "master"; response->map.metadata.map_load_time = current_time; response->map.metadata.update_time = current_time; response->map.metadata.origin.position.x = costmap_->getOriginX(); response->map.metadata.origin.position.y = costmap_->getOriginY(); response->map.metadata.origin.position.z = 0.0; response->map.metadata.origin.orientation = tf2::toMsg(quaternion); response->map.data.resize(data_length); response->map.data.assign(data, data + data_length); }
确实是没用使用用户填入的参数,是接口功能没实现完整吗?或者有什么接口能获取到指定位置的地图?