10 template <
class RoadmapArgs>
13 typedef boost::graph_traits<typename RoadmapArgs::Graph> GraphTypes;
14 typedef typename GraphTypes::vertex_descriptor Vertex;
15 typedef typename GraphTypes::edge_descriptor Edge;
35 throw std::runtime_error(
"RoadmapHalton only supports rel vector state spaces!");
36 _dim = this->space->getDimension();
37 if (0 == ompl_lemur::util::get_prime(_dim-1))
38 throw std::runtime_error(
"not enough primes hardcoded!");
42 this->
template declareParam<unsigned int>(
"num",
this,
45 this->
template declareParam<double>(
"radius",
this,
46 &RoadmapHalton::setRadius,
47 &RoadmapHalton::getRadius);
50 void setNum(
unsigned int num)
54 if (this->initialized)
55 throw std::runtime_error(
"cannot set num, already initialized!");
59 unsigned int getNum()
const
64 void setRadius(
double radius)
66 if (radius == _radius)
68 if (this->initialized)
69 throw std::runtime_error(
"cannot set radius, already initialized!");
73 double getRadius()
const
80 std::vector<std::string> missings;
82 missings.push_back(
"num");
84 missings.push_back(
"radius");
87 std::string str =
"Cannot initialize, parameters not set:";
88 for (
unsigned int ui=0; ui<missings.size(); ui++)
89 str +=
" " + missings[ui];
90 throw std::runtime_error(str);
92 this->initialized =
true;
97 throw std::runtime_error(
"RoadmapHalton deserialize from ser_data not supported!");
110 if (this->max_batches < this->num_batches_generated + 1)
111 throw std::runtime_error(
"this roadmap gen doesnt support that many batches!");
112 for (std::size_t v_index=num_vertices(this->g); v_index<_num; v_index++)
114 Vertex v_new = add_vertex(this->g);
116 put(this->vertex_batch_map, v_new, this->num_batches_generated);
117 put(this->is_shadow_map, v_new,
false);
120 put(this->state_map, v_new, this->space->allocState());
123 for (
unsigned int ui=0; ui<_dim; ui++)
125 values[ui] = _bounds.
low[ui] + (_bounds.
high[ui] - _bounds.
low[ui])
126 * ompl_lemur::util::halton(
127 ompl_lemur::util::get_prime(ui), v_index);
129 this->nn->add(v_new);
132 std::vector<Vertex> vs_near;
133 this->nn->nearestR(v_new, _radius, vs_near);
134 for (
unsigned int ui=0; ui<vs_near.size(); ui++)
136 if (vs_near[ui] == v_new)
138 Edge e = add_edge(v_new, vs_near[ui], this->g).first;
140 put(this->distance_map, e, this->space->distance(v_state,vnear_state));
141 put(this->edge_batch_map, e, this->num_batches_generated);
144 this->num_batches_generated++;
149 throw std::runtime_error(
"RoadmapHalton serialize to ser_data not supported!");
double root_radius(std::size_t i_batch)
Calcuate the root radius to be used for connecting to potential root vertices.
Definition: RoadmapHalton.h:101
std::vector< double > low
void generate()
Generates one additional batch.
Definition: RoadmapHalton.h:108
Interface for generating roadmaps over OMPL state spaces into Boost Graph objects.
Definition: Roadmap.h:76
void serialize(std::string &ser_data)
Serialize the internal generator state into the passed string.
Definition: RoadmapHalton.h:147
std::vector< double > high
void initialize()
Initialize roadmap; must be called once after setting parameters.
Definition: RoadmapHalton.h:78
void deserialize(const std::string &ser_data)
Re-constitute the internal generator state from serialized data.
Definition: RoadmapHalton.h:95
Definition: RoadmapHalton.h:11