According to the tutorial Using rviz with the navigation stack: http://www.ros.org/wiki/navigation/Tutorials/Using%20rviz%20with%20the%20Navigation%20Stack
The map should be displayed by the nav_msgs::GetMap service. However, the message displayed by the map service in rviz with the configuration I am running is nav_msgs::OccupancyGrid. This message is published by the map_server node.
I don't really think this is a problem however. The map is still displayed in rviz and the move_base node identifies it and accepts it.
Another conflict I had at the beginning was that running gmapping during the process caused the current laser's view to be displayed instead of the .png map. I couldn't stop running this node since it is in charge of the map-odom transform. My solution to the problem was to eliminate the scan:=base_scan parameter from my launch file.
Now, the .png map is being displayed.
I would like to extract the information of obstacles by ROS. This is my code:
ResponderEliminar#include "ros/ros.h"
//#include "std_msgs/String.h"
#include "nav_msgs/GridCells.h"
void chatterCallback(const nav_msgs::GridCells::ConstPtr& msg)
{
ROS_INFO("width: [%f]", msg->cell_width);
ROS_INFO("height: [%f]", msg->cell_height);
ROS_INFO("size: [%f]", msg->cells.size());
ROS_INFO("pos_x: [%f]", msg->cells[0].x); // segmentation fault if there are not obstacle's
ROS_INFO("pos_y: [%f]", msg->cells[0].y);
ROS_INFO("pos_z: [%f]", msg->cells[0].z);
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "listener");
ros::NodeHandle n;
ros::Subscriber sub = n.subscribe("/move_base_node/local_costmap/obstacles", 1000, chatterCallback);
ros::spin();
return 0;
}
The Problem is: if there are not obstacles:
- return segmentation fault
- width = 0.05 height =0.05 size =0.0000
how can I know the size of the array cells[] ?
I would like to know if there are obstacles and where are it ?
Thank you very much.