Re: ROS - 2D occupancy grid
Posted by jixujoy on Aug 07, 2018; 6:43pm
URL: http://official-rtab-map-forum.206.s1.nabble.com/ROS-2D-occupancy-grid-tp1204p4881.html
1.How do you subscribe to the /rtabmap/proj_map and save the grid map as a picture?
2. For rviz, I can see the grid_map displayed there, but how can I save it?
I tried all the ways listed in trying to make the GUI version of rtabmaprviz "create 2D grid map" unlocked, but I still cannot use its functionality. I am trying to write a subscriber to get the grid map. Here are the partial code I wrote. I do not know what package I can use to save the grid_map. What should I write in getGrid() function?
//Here are all the ROS required packages
#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/image_encodings.h>
//standar stream files read and write
#include <iostream>
#include <fstream>
#include <chrono>
void getGrid(const nav_msgs::OccupancyGrid & msg){
}
int main(int argc, char **argv){
ros::init(argc, argv, "grid_grabber");
ros::NodeHandle n;
ros::Subscriber sub = n.subscribe("/rtabmap/proj_map", 1, getGrid);
ros::spin();
return 0;
}