1 #ifndef SLAM_CTOR_ROS_OCCUPANCY_GRID_PUBLISHER_H 2 #define SLAM_CTOR_ROS_OCCUPANCY_GRID_PUBLISHER_H 5 #include <nav_msgs/OccupancyGrid.h> 7 #include "../core/states/state_data.h" 8 #include "../core/maps/grid_map.h" 10 template <
typename Gr
idMapType>
15 double publ_interval_secs = 5.0):
24 nav_msgs::OccupancyGrid map_msg;
27 map_msg.info.width = map.width();
28 map_msg.info.height = map.height();
29 map_msg.info.resolution = map.scale();
31 nav_msgs::MapMetaData &info = map_msg.info;
33 info.origin.position.
x = -info.resolution * origin.
x;
34 info.origin.position.y = -info.resolution * origin.
y;
35 info.origin.position.z = 0;
36 map_msg.data.reserve(info.height * info.width);
39 info.height) - origin;
40 for (pnt.
y = -origin.
y; pnt.
y < end_of_map.
y; ++pnt.
y) {
41 for (pnt.
x = -origin.
x; pnt.
x < end_of_map.
x; ++pnt.
x) {
42 double value = (double)map[pnt];
43 int cell_value = value == -1 ? -1 : value * 100;
44 map_msg.data.push_back(cell_value);
void publish(const boost::shared_ptr< M > &message) const
std::string _tf_map_frame_id
void on_map_update(const GridMapType &map) override
std::string tf_map_frame_id()
OccupancyGridPublisher(ros::Publisher pub, const std::string &tf_map_frame_id, double publ_interval_secs=5.0)
ros::Duration _publishing_interval