
Geometry : 
Subject: Re: [geometry] Rtree query nearest nodes with torus distance strategy
From: Andrew Hundt (athundt_at_[hidden])
Date: 20150404 23:58:59
Adam Wulkiewicz <adam.wulkiewicz_at_[hidden]> wrote:
<snip>
> // define a separate point for this specific arm in order to calculate the
> distance specifically for it.
> struct arm_6dof_pos { /*...*/ };
> // register the above as 6D cartesian point
>
> namespace boost { namespace geometry {
>
> double comparable_distance(arm_6dof_pos const& p1, arm_6dof_pos const& p2)
> {
> // calculate the point/point distance (above)
> }
>
> template <typename Box>
> double comparable_distance(arm_6dof_pos const& p, Box const& b)
> {
> // calculate the point/box distance
> }
>
> }} // namespace
>
> /*...*/
>
> rtree<arm_6dof_pos, ...> tree;
> /*fill the rtree*/
>
> arm_6dof_pos query_pos(/*...*/);
> tree.query(nearest(query_pos, 1), out);
>
>
> I hope that I understand your problem correctly and that the above is
> clear enough.
> Please let me know about the outcome, it's very interesting!
>
Thanks for the starter explanation! I'm trying to instantiate things as you
described, but I'm running into an issue with
NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE. I'm basically mixing the geometry
graph example with some of the rtree examples and your description. The
rtree is accelerating my graph creation process so I can eventually do a
shortest path search on it.
All the important details and the compiler error are in this gist:
https://gist.github.com/ahundt/e790bd17bfc56ae5e5a1
// use boost::array as the type we will adapt
#include <boost/geometry/geometries/adapted/boost_array.hpp>
// ...
// I instantiated the torus comparisons:
// perhaps these aren't overload correctly or the boost_array include
causes conflicts?
namespace boost { namespace geometry {
double comparable_distance(ArmPos const& p1, ArmPos const& p2 ) ;
template<typename Box>
double comparable_distance(ArmPos const& armpos, Box const& box );
}}
// I define types for the vertex and edge properties (see gist)
// I define all the types necessary to create the rtree and graph
//typedef bg::model::point<double, 3, bg::cs::cartesian> point;
typedef boost::array<double,6> ArmPos;
typedef ArmPos point_type;
typedef bg::model::box<point_type> box;
typedef bg::model::referring_segment<point_type> line_type;
//typedef bg::model::polygon<point, false, false> polygon; // ccw, open
polygon
typedef boost::adjacency_list
<
boost::vecS, boost::vecS, boost::undirectedS
, bg_vertex_property<point_type> // bundled
, bg_edge_property<line_type>
> graph_type;
typedef boost::graph_traits<graph_type>::vertex_descriptor vertex_type;
// I expected that the point_type of the pair would be seen as implemented
// I also expected that the vertex_type would simply be data not utilized,
// which I believe is true in the case of a simple <point,int> like in the
quick start
typedef std::pair<point_type, vertex_type> rtree_value;
typedef boost::geometry::index::rtree<rtree_value,bgi::rstar<16, 4> >
knn_rtree_type;
// I instantiate the rtree + graph and get a compiler error
void instantiate_rtree_and_graph(){
// comment these two lines to "fix" compiler error
graph_type graph;
knn_rtree_type rtree;
}
The key line of the error I got, which I didn't expect was:
/home/ahundt/catkin_ws/build/cs436/assignment3/boostprefix/include/boost/geometry/core/coordinate_system.hpp:42:5:
error: no matching function for call to
â€˜assertion_failed(mpl_::failed************
(boost::geometry::traits::coordinate_system<boost::array<double, 6ul>,
void>::NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE::************)(mpl_::assert_::types<boost::array<double,
6ul>, mpl_::na, mpl_::na, mpl_::na>))â€™
I expected it to work like one of the examples of default value types
<http://www.boost.org/doc/libs/1_57_0/libs/geometry/doc/html/geometry/spatial_indexes/creation_and_modification.html>
where the first item is indexed and the second is data such as:
boost::tuple<geometry::model::point<...>, int, float>
Any help you might be able to provide with getting the templates to resolve
correctly would be appreciated! I also appreciate that you find my use case
interesting :)
Cheers!
Andrew Hundt
Geometry list run by mateusz at loskot.net