OcTree is Null after dynamic_cast from AbstractOcTree
Hi!
I am trying to read an Octomap
published by /octomap_full
as octomap_msgs::Octomap
type. My requirement is reading nodes of the octree and do further operations on the data. I have the following cpp
function as explained in every documentation and source.
void octomap_callback(const octomap_msgs::Octomap::ConstPtr& msg){
ROS_INFO("Octomap resolution: [%f]", msg->resolution);
AbstractOcTree* tree = octomap_msgs::msgToMap(*msg);
OcTree* octree = dynamic_cast<OcTree*>(tree);
ROS_INFO("Resolution of octree: [%f]" , octree->getResolution());
}
The program is compiled normally without any warning. But when I run it I get the following result.
[ INFO] [1558769545.208112901]: Octomap resolution: [0.020000]
Segmentation fault (core dumped)
As I checked with the condition: if(octree){ },
the octree seem to be NULL
.
What am I doing wrong here?
How can I dynamic_cast
the AbstractOcTree
to OcTree
correctly?
Thanks in advance.