computeRay trouble shooting

37 views
Skip to first unread message

David Sestak

unread,
Sep 14, 2019, 7:40:44 AM9/14/19
to OctoMap developers and users discussion
Hello,

I am working on an exploration problem and trying to compute the expected information gain by using a sensor model and ray-casting as part of this effort. I am not so experienced with C++, so I hope this is not a very basic syntax or form based error.

However, when using the computeRay function, I am getting a segmentation fault that is backtraced to OcTreeBaseImpl.hxx:

#0  0x00002aaaaba084ce in std::vector<octomap::KeyRay, std::allocator<octomap::KeyRay> >::size (this=0xa0) at /usr/include/c++/5/bits/stl_vector.h:655
#1  0x00002aaaaba0789e in std::vector<octomap::KeyRay, std::allocator<octomap::KeyRay> >::_M_range_check (this=0xa0, __n=0)
    at /usr/include/c++/5/bits/stl_vector.h:802
#2  0x00002aaaaba0474f in std::vector<octomap::KeyRay, std::allocator<octomap::KeyRay> >::at (this=0xa0, __n=0) at /usr/include/c++/5/bits/stl_vector.h:824
#3  0x00002aaaaba00785 in octomap::OcTreeBaseImpl<octomap::OcTreeNode, octomap::AbstractOccupancyOcTree>::computeRay (this=0x0, origin=..., end=...,
    _ray=std::vector of length 0, capacity 0)
    at /volume/software/common/foreign_packages/octomap/1.6.6/include/octomap/OcTreeBaseImpl.hxx:538


When calling the function within my own code, I instantiate the inputs as follows:

octomath::Vector3 origin(sensor_origin.x()+rayDirection.x()*min_range,sensor_origin.y()+rayDirection.y()*min_range,sensor_origin.z()+rayDirection.z()*min_range);

octomath::Vector3 end(sensor_origin.x()+rayDirection.x()*max_range,sensor_origin.y()+rayDirection.y()*max_range,sensor_origin.z()+rayDirection.z()*max_range);

Both of these contain non-zero 3D point values.

Then I instantiate:

std::vector<octomath::Vector3> ray;

as the vector where I want all the keys of the nodes that the ray passes through are saved.

Finally calling:

octree_tmp->computeRay(origin,end,ray);

with octree_tmp instantiated as:

octomap::OcTree* octree_tmp;

it is private in my class.

The issue seems to be that "this" is seen to be as empty causing issues further down the line, and from my understanding this object is based on my input of std::vector<octomath::Vector3> ray, but I believe this should be unassigned going into the function with push_back being used inside to increase its size as needed.

I do not know what I can change on my side and would appreciate any advice in tackling this issue.

Thank you and kind regards,
David

Federico Ferri

unread,
Sep 14, 2019, 10:26:25 AM9/14/19
to oct...@googlegroups.com
Looks like octree_tmp is null (see this=0x0 in frame #3).

Cheers,
Federico Ferri
--
You received this message because you are subscribed to the Google Groups "OctoMap developers and users discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to octomap+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/octomap/753a7add-c1d4-4d95-9c25-aa8470cf999e%40googlegroups.com.

David Sestak

unread,
Sep 15, 2019, 4:55:03 AM9/15/19
to OctoMap developers and users discussion
Thank you! Of course something so simple! And thank you for the quick reply!

Kind regards,
David

On Saturday, September 14, 2019 at 4:26:25 PM UTC+2, Federico Ferri wrote:
Looks like octree_tmp is null (see this=0x0 in frame #3).

Cheers,
Federico Ferri


To unsubscribe from this group and stop receiving emails from it, send an email to oct...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages