Open jontromanab opened 7 years ago
@jontromanab I am aware that this is an extremely old question, but for whoever faces this problem in the future, I can safely confirm this solution:
octomap::OcTree* octTree = new octomap::OcTree(0.1);
octomap::AbstractOcTree* tree = octomap_msgs::fullMsgToMap(*msg);
octTree = dynamic_cast<octomap::OcTree*>(tree);
@jontromanab I am aware that this is an extremely old question, but for whoever faces this problem in the future, I can safely confirm this solution:
octomap::OcTree* octTree = new octomap::OcTree(0.1); octomap::AbstractOcTree* tree = octomap_msgs::fullMsgToMap(*msg); octTree = dynamic_cast<octomap::OcTree*>(tree);
thank you very much for your answer. You solved the problem that bothered me for a long time!!!!!
Hello,
When I was trying to build the package, I got this error:
_/src/OctomapClientInterface.cpp:129:12: error: invalid conversion from ‘octomap::AbstractOcTree’ to ‘octomap::OcTree_’ [-fpermissive]**
The line is: 129. m_octree = octomap_msgs::binaryMsgToMap(m_octomapMsg.response.map);
where m_octree is a octomap::OcTree, but found out the binaryMsgToMap() returns a octomap::AbstractOcTree I have changed the code like this:
octomap::AbstractOcTree tree = octomap_msgs::binaryMsgToMap(m_octomapMsg.response.map); m_octree = (octomap::OcTree)tree;
which is building fine. Is this casting right?
Thank you.
I was facing troubles because of the dynamic casting actually and for some reason, the regular casting works fine. I know that makes no sense but it's worth mentioning if someone has some memory leaks because of memory management!
Hello,
When I was trying to build the package, I got this error:
/src/OctomapClientInterface.cpp:129:12: error: invalid conversion from ‘octomap::AbstractOcTree’ to ‘octomap::OcTree’ [-fpermissive]
The line is:
where m_octree is a octomap::OcTree, but found out the binaryMsgToMap() returns a octomap::AbstractOcTree I have changed the code like this:
octomap::AbstractOcTree tree = octomap_msgs::binaryMsgToMap(m_octomapMsg.response.map); m_octree = (octomap::OcTree)tree;
which is building fine. Is this casting right?
Thank you.