ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

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 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).

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 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 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).