Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with deleteNode when deleting all nodes #307

Open
marcelino-pensa opened this issue Oct 8, 2020 · 6 comments
Open

Issue with deleteNode when deleting all nodes #307

marcelino-pensa opened this issue Oct 8, 2020 · 6 comments
Labels

Comments

@marcelino-pensa
Copy link

marcelino-pensa commented Oct 8, 2020

I have implemented a procedure for a fading memory octomap, meaning that it will forget things that it saw very long ago by deleting those nodes using deleteNode.
If I end up deleting all nodes from the octree, I noticed that the root node remains alive, and that the octree is saying that my whole volume is occupied.
After I delete all nodes from the octree, only one node remains, and that one is the one whose size is equal to tree.getResolution() * pow(2.0, 16.0) (i.e., the root). This node cannot be deleted, as deleteNodeRecurs does not delete a node if node != this->root.

My questions are:

  • Is there any reason why my octomap reverts back to the root as I delete all nodes? Is this the expected behavior? Why not deleting the root as well? Maybe it can't delete the root because deleteNodeRecurs does not delete the root...
  • Why can't we delete the root in deleteNodeRecurs?
@marcelino-pensa
Copy link
Author

marcelino-pensa commented Oct 8, 2020

If my question isn't clear, this is what I mean by deleting all nodes:

    for (octomap::OcTree::leaf_iterator it = tree_.begin_leafs(),
                                       end = tree_.end_leafs();
                                       it != end; ++it) {
        octomap::OcTreeKey key = it.getKey();
        tree_.deleteNode(key, it.getDepth());
    }

If we delete all nodes using the method above, there will be one remaining node in the tree that is impossible to delete (the root)

@ahornung
Copy link
Member

ahornung commented Nov 2, 2020

Yes, this seems like an omission that should be fixed. Looking at the implementation of clear, there's no reason not to delete the root as well.

@ahornung ahornung self-assigned this Nov 2, 2020
@ahornung ahornung added the bug label Nov 2, 2020
@ahornung ahornung removed their assignment Nov 2, 2020
@ahornung ahornung added bug and removed bug labels Nov 2, 2020
@ahornung
Copy link
Member

ahornung commented Nov 2, 2020

I haven't tested it yet, but PR #288 should fix this as well. Does that work for you?

@ahornung
Copy link
Member

Looking back at the changelog, this issue was fixed long ago with #11 (v1.6.0) and it's probably a regression.

@marcelino-pensa
Copy link
Author

I am running on v1.9.0, and the problem still exists

@xiaofengguorui
Copy link

I have the same issu, and when I delete all nodes, I try to updateNode failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants