readData and writeData function for ColorOctree visualization is giving white color in RVIZ els
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
Did you try checking your subscribed topic in RViz?
/octomap_full
topic contains colors, while/octomap_binary
topic displays in white by default.@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);
Have you tried visualizing your
.ot
file usingoctovis
? 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:@TharushiDeSilva No I can't visualize it using octovis. I got a msg "cannot open Octree file"