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