ROS Answers: Open Source Q&A Forum - RSS feedhttps://answers.ros.org/questions/Open source question and answer forum written in Python and DjangoenROS Answers is licensed under Creative Commons Attribution 3.0Fri, 23 Aug 2019 11:52:43 -0500Does octomap calcNumNodes() give total number of occupied+free voxels?https://answers.ros.org/question/330961/does-octomap-calcnumnodes-give-total-number-of-occupiedfree-voxels/ Hello i am working with ros octomap library. Octomap function `calcNumNodes()` returns with `size`. Function is defined like [this](https://octomap.github.io/octomap/doc/classoctomap_1_1OcTreeBaseImpl.html#a9d998205d42dfeecfa2a359de8b38f63):
octomap::OcTreeBaseImpl< NODE, I >::calcNumNodes() const
> Traverses the tree to calculate the total number of nodes.
Does it mean this return total number of occupied + free voxels?
Actually i want to find how many voxels has been explored in a cubic volume and i am using this function but from the numbers i feel like its much lesser than how many there should be.
For an alternate there can be a way that i iterate all over the occupied and free voxels and count them, but should i be doing that or not? Pls enlighten me if there is better alternate?
P.S. I tried searching about this but couldn't find a clear answer. If there is an explanation somewhere i will be happy to read that as well.
Thanks. Sun, 18 Aug 2019 09:24:09 -0500https://answers.ros.org/question/330961/does-octomap-calcnumnodes-give-total-number-of-occupiedfree-voxels/Comment by usamamaq for <p>Hello i am working with ros octomap library. Octomap function <code>calcNumNodes()</code> returns with <code>size</code>. Function is defined like <a href="https://octomap.github.io/octomap/doc/classoctomap_1_1OcTreeBaseImpl.html#a9d998205d42dfeecfa2a359de8b38f63">this</a>:</p>
<pre><code>octomap::OcTreeBaseImpl< NODE, I >::calcNumNodes() const
</code></pre>
<blockquote>
<p>Traverses the tree to calculate the total number of nodes. </p>
</blockquote>
<p>Does it mean this return total number of occupied + free voxels? </p>
<p>Actually i want to find how many voxels has been explored in a cubic volume and i am using this function but from the numbers i feel like its much lesser than how many there should be. </p>
<p>For an alternate there can be a way that i iterate all over the occupied and free voxels and count them, but should i be doing that or not? Pls enlighten me if there is better alternate?</p>
<p>P.S. I tried searching about this but couldn't find a clear answer. If there is an explanation somewhere i will be happy to read that as well.</p>
<p>Thanks. </p>
https://answers.ros.org/question/330961/does-octomap-calcnumnodes-give-total-number-of-occupiedfree-voxels/?comment=331477#post-id-331477So up till now what i have underatood is that everytime `updatenode()` is done with occupied or free cells it prune the voxels having same status into one node. So `calcNumNodes()` will not tell number of occupied+free cells at given resolution but total initiated nodes either free or occupied. So i am using `expand()` first to divide all nodes at given resolution and then `calcNumNodes()`.
Still open for suggestion from community if anyone has any.Fri, 23 Aug 2019 11:52:43 -0500https://answers.ros.org/question/330961/does-octomap-calcnumnodes-give-total-number-of-occupiedfree-voxels/?comment=331477#post-id-331477