0
$\begingroup$

Rosanswers logo

Hi Everybody.

I wonder how RVIZ can display a 2d probabilistic map.

I have a 2D matrix where I store the probabilistic values of an occupancy grid map. What can I use to display this values in RVIZ?

Regards,


Originally posted by acp on ROS Answers with karma: 556 on 2012-02-06

Post score: 2

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

The rviz map plugin unfortunately currently only supports the three discrete states unknown, occupied and free. See this code snipped from visualization/rviz/src/rviz/default_plugin/map_display.cpp (starting at line 289):

  for( unsigned int pixel_index = 0; pixel_index < num_pixels_to_copy; pixel_index++ )
  {
    unsigned char val;
    if(msg->data[ pixel_index ] == 100)
      val = 0;
    else if(msg->data[ pixel_index ] == 0)
      val = 255;
    else
      val = 127;

    pixels[ pixel_index ] = val;
  }

It is thus currently not possible to use nav_msgs/OccupancyGrid.msg messages and display more than these 3 states/color values in rviz. However, one could use the existing map_display plugin as a starting point for a modified version that displays more levels of grey. Only changing the above loop would be necessary for that (if you want to keep using standard nav_msgs/OccupancyGrid messages).


Originally posted by Stefan Kohlbrecher with karma: 24361 on 2012-02-07

This answer was ACCEPTED on the original site

Post score: 4


Original comments

Comment by acp on 2012-02-07:
Hi, the content of above mentioned links are a bit confused, just wondering whether you may have a piece of code I can take a look at, thank you

Comment by Stefan Kohlbrecher on 2012-02-07:
It is possible to add the color information via the channel array in a sensor_msgs::PointCloud ( see for example http://answers.ros.org/question/563/how-to-visualize-colored-pointclouds-in-rviz). You could also use a sensor_msgs::PointCloud2. In that case, you could take kinect data as an example.

Comment by acp on 2012-02-07:
I was thinking about to somehow assign grey colours to each individual point coordinate that correspond to the probability value. I do not know if that is possible.

Comment by acp on 2012-02-07:
In advance, thank you for your replay, I have the idea to visualize the probabilistic matrix using sensor_msgs::PointCloud, and actually I can visualize the matrix in rviz, the only thing is that it does not display gray colours.

Comment by Sentinal_Bias on 2014-04-22:
probabilities are in the range [0,100], which means the occupancy grid values dont have to take discrete states. You can have a an occupancy value of 90 ie a probability of 0.9. Therefore you can use occupancy grid msg to render probability maps. Everything will just be in gray scale

$\endgroup$
0
$\begingroup$

Rosanswers logo

ROS costmaps are typically visualized using nav_msgs/GridCells. If you were to fill one of these data structures with your probabilistic map, you would be able to visualize it in Rviz in three colors (INFLATED, OCCUPIED, UNKNOWN).

What I did to visualize probabilistic maps, however, was simply to save my data structure as an image file (with OpenCV) and then view it as a sensor_msgs/Image. This is a pretty hacky solution, but I needed to save them as images anyway, so it worked for me.

EDIT:

To convert my costmap-like data structure to an OpenCV image, I simply just set each costmap cell as a pixel in an OpenCv IplImage data structure. Then, you can just cv_bridge to convert that image to a sensor_msgs/Image. This is simple to do if you know OpenCv, but you might have to do some research on the OpenCv image data structure. It's not too complex.

It should be noted that the Image in Rviz is in a separate window from the robot body. You won't be able to overlay one on the other using this method.


Originally posted by DimitriProsser with karma: 11163 on 2012-02-07

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by acp on 2012-02-07:
I want to refresh the matrix often, I mean the map hast to be dynamic, just wondering if the process of saving and uploading does not expensive.

Comment by acp on 2012-02-07:
In advance thank you for your replay, do you have some example code how to save an structure to as an image file and then send it as a sensor_msgs/Image topic.

Comment by Eric Perko on 2012-02-07:
I think that the GridCells message gets assigned a fixed color by rviz (you can choose it), whereas the OccupancyGrid uses the three different obstacle types.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.