ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Initializing and manipulating OctoMaps with more than just occupancy

asked 2011-10-06 02:31:38 -0600

Daniel Canelhas gravatar image

Hi, Sorry if this is too much of a C++ question, but I'm having trouble understanding how to initialize and update an octree in which the nodes can store a data value.

There is a nice example online showing how to make an octree such as

OcTree tree (0.1); //0.1 is the spatial resolution in m.

and then setting the occupancy of the nodes to true, using

tree.updateNode(point_in_3d,true)

Where point_in_3d is an octomath::Vector3.

So far so good. However, reading the documentation, I've come across an

octomap::OcTreeDataNode< T >

that I'd much rather use. With a data container of arbitrary type T in every leaf, I could presumably store additional information about the geometry there, such as the estimated surface normal, or color, or measurement uncertainty, etc.

What I'd like to know (and haven't been able to understand from the docs) is, how to create such an octree (suppose we want T to be a 3-element vector of type float), and how to update the data.

The reason I'm not using pcl octrees is because octomap provides a way of doing ray casting into the tree, and also because of octovis (neat!).

Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2011-10-06 21:00:41 -0600

AHornung gravatar image

That is indeed possible. What you need to do is define a new node type and a new octree type, as the nodes just store data and the tree handles the data manipulation. OcTree stores just occupancy but you can easily derive from OccupancyOcTreeBase with your own node type as template parameter if you want to add additional properties to the node. Note that this will not only affect leafs but also inner nodes of the tree (as all nodes are identical).

As examples to get started, there is an OcTreeStamped implementation which stores timestamps, and in the OctoMap trunk there is a ColorOcTree which stores color (not yet released, thus not yet in the ROS octomap).

edit flag offensive delete link more

Comments

Ive read the answer for a similar question: http://answers.ros.org/question/1094/augmenting-octomap-nodes-with-additional-info But I'm having trouble understanding how to actually make this derivation. Like I said, this is probably a bit of a C++ question. doxygen doesnt say much for a beginner :(
Daniel Canelhas gravatar image Daniel Canelhas  ( 2011-10-06 21:23:59 -0600 )edit
Best copy the OcTreeStamped or ColorOcTree files, rename them, and start modifying them to the behavior you want. The stamped classes probably have the least overhead in them.
AHornung gravatar image AHornung  ( 2011-10-06 21:52:00 -0600 )edit
Thanks! For a derivation of OcTreeStamped, I could work on something similar to the LogOdds, it seems.
Daniel Canelhas gravatar image Daniel Canelhas  ( 2011-10-07 00:16:38 -0600 )edit
I copied ColorOcTree.h into the include directory of a ros package and included it in my code. rosmake seems to have a problem with the linking because i get: color_tree_test.cpp:23: undefined reference to `octomap::ColorOcTree::ColorOcTree(double)' when compiling. (same happens w/ my custom nodes)
Daniel Canelhas gravatar image Daniel Canelhas  ( 2011-10-07 10:25:33 -0600 )edit
The previous example is just with an unaltered copy of color_tree_test.cpp. The same thing happens if I take OcTreeStamped and rename/modify the code related to storing/managing the timestamp.
Daniel Canelhas gravatar image Daniel Canelhas  ( 2011-10-07 10:30:09 -0600 )edit
Do you have a <depend package="octomap" /> line in your manifest? Otherwise the linker won't find octomap from your own package. You should also make sure that you rename both the files and the classes, as they will conflict otherwise.
AHornung gravatar image AHornung  ( 2011-10-09 22:10:27 -0600 )edit
Oh, I just realized: The ColorOcTree is only in OctoMap trunk (not yet released)! So if you are working in ROS you obviously won't find it. You would need to compile your own version in your copy but you shouldn't even need it because you only want is as example of node extension / derivation.
AHornung gravatar image AHornung  ( 2011-10-09 22:12:17 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2011-10-06 02:31:38 -0600

Seen: 2,644 times

Last updated: Oct 06 '11