Thanks, I can reproduce now.
The issue seems to be that the dynamic_cast is failing, "octree" is
holding a null pointer. It looks like you are casting to the wrong type,
for the freiburg1_360 for example you'd want "ColorOcTree" instead of
"OcTree". You can get the type of the tree as string with the
getTreeType() method, see the example below.
#include <iostream>
#include <stdlib.h>
#include <octomap/OcTree.h>
int main( int argc, char** argv ){
octomap::AbstractOcTree* tree =
octomap::AbstractOcTree::read("/home/sprunkc/Downloads/freiburg1_360.ot");
if (tree){
std::cout << "Loaded tree of type " << tree->getTreeType() <<
std::endl;
const octomap::OcTree* octree = dynamic_cast<octomap::OcTree*>(tree);
if(octree == nullptr){
std::cout << "Dynamic cast failed, octree is nullptr, expect
crash" << std::endl;
}
std::cout << "If octree is nullptr next line will yield an invalid
read of size 8 and segfault." << std::endl;
octomap::OcTree::iterator it_end = octree->end();
std::cout << "Done" << std::endl;
}
return 0;
}
On 02.07.20 03:40, Mayar Attawiya wrote:
> Hello, thanks for replying.
> I now know that the error emerges from the ( end=octree->end_leafs() )
> part. Looks like the end_leafs() isn't returning anything.
> My octomap was generated by rtabmap and I will add a link of it (i will
> also add its .bt format)
> I also tried the code on one of the octomaps from the dataset here (
>
http://ais.informatik.uni-freiburg.de/projects/datasets/octomap/ ), the
> one i tried is freiburg1_360.ot.gz
> <
http://ais.informatik.uni-freiburg.de/projects/datasets/octomap/freiburg1_360.ot.gz>
> > an email to
oct...@googlegroups.com <javascript:>
> > <mailto:
oct...@googlegroups.com <javascript:>>.
> <
https://groups.google.com/d/msgid/octomap/2e677be3-be43-46be-a4f6-67a4694649b1o%40googlegroups.com?utm_medium=email&utm_source=footer
> <
https://groups.google.com/d/msgid/octomap/2e677be3-be43-46be-a4f6-67a4694649b1o%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "OctoMap developers and users discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
octomap+u...@googlegroups.com
> <mailto:
octomap+u...@googlegroups.com>.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/octomap/7fb62d3f-2edb-49e5-a6f6-71bd4aba8332o%40googlegroups.com
> <
https://groups.google.com/d/msgid/octomap/7fb62d3f-2edb-49e5-a6f6-71bd4aba8332o%40googlegroups.com?utm_medium=email&utm_source=footer>.