readData and writeData function for ColorOctree visualization is giving white color in RVIZ els

asked 2019-07-07 06:46:23 -0500

RSA_kustar gravatar image

Hi,

I am creating a colored octomap "ColorOcTree" and I save it using writeData function. I am calling the function writeData using the following lines:

  std::ofstream file1("map1.ot", std::ios_base::out );
  octomap_.writeData(file1)

I tired both .ot and .dat file extensions.

The function writeData is as follows:

std::ostream& writeData(std::ostream& s) const
{
    s.write((const char*)&value, sizeof(value));  // occupancy
    s.write((const char*)&color, sizeof(Color));  // color
    return s;
 }

After that, I close the simulation and I tried to read the file by calling the readData function using the following lines:

  std::ifstream s("map1.ot", std::ios_base::in );
  octomap_.readData(s) ;

The readData function is as follows:

std::istream& readData(std::istream& s)
{
     s.read((char*)&value, sizeof(value));  // occupancy
     s.read((char*)&color, sizeof(Color));  // color
     return s;
}

When I visualize the map in RVIZ, all the voxels are white. But when I tried to print the values in the terminal, I got different values than 255, 255, 255

Kindly help

edit retag flag offensive close merge delete

Comments

Did you try checking your subscribed topic in RViz? /octomap_full topic contains colors, while /octomap_binary topic displays in white by default.

TharushiDeSilva gravatar imageTharushiDeSilva ( 2019-07-07 23:12:02 -0500 )edit

@TharushiDeSilva I am using /octomap_full topic and the voxel coloring is the cell color but still all voxels are white and this is the publisher I am using fullmapPub_ = nh_.advertise<octomap_msgs::octomap>("octomap_full", 1, true);

RSA_kustar gravatar imageRSA_kustar ( 2019-07-08 06:37:47 -0500 )edit

Have you tried visualizing your .ot file using octovis? If you can see your map in Octovis as expected, then you can assure that you haven't done anything wrong when writing the code. You can visualize it easily like this:

octovis map_name.ot
TharushiDeSilva gravatar imageTharushiDeSilva ( 2019-07-08 23:36:06 -0500 )edit

@TharushiDeSilva No I can't visualize it using octovis. I got a msg "cannot open Octree file"

RSA_kustar gravatar imageRSA_kustar ( 2019-07-09 04:17:23 -0500 )edit