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
Asked by RSA_kustar on 2019-07-07 06:46:23 UTC
Comments
Did you try checking your subscribed topic in RViz?
/octomap_full
topic contains colors, while/octomap_binary
topic displays in white by default.Asked by TharushiDeSilva on 2019-07-07 23:12:02 UTC
@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_full", 1, true);
Asked by RSA_kustar on 2019-07-08 06:37:47 UTC
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:Asked by TharushiDeSilva on 2019-07-08 23:36:06 UTC
@TharushiDeSilva No I can't visualize it using octovis. I got a msg "cannot open Octree file"
Asked by RSA_kustar on 2019-07-09 04:17:23 UTC