17 template <
class RoadmapArgs>
20 typedef boost::graph_traits<typename RoadmapArgs::Graph> GraphTypes;
21 typedef typename GraphTypes::vertex_descriptor Vertex;
22 typedef typename GraphTypes::edge_descriptor Edge;
46 _sampler(this->space->allocStateSampler())
50 throw std::runtime_error(
"RoadmapRGG only supports rel vector state spaces!");
51 _dim = this->space->getDimension();
52 if (0 == ompl_lemur::util::get_prime(_dim-1))
53 throw std::runtime_error(
"not enough primes hardcoded!");
57 this->
template declareParam<unsigned int>(
"num",
this,
60 this->
template declareParam<double>(
"radius",
this,
61 &RoadmapRGG::setRadius,
62 &RoadmapRGG::getRadius);
63 this->
template declareParam<unsigned int>(
"seed",
this,
65 &RoadmapRGG::getSeed);
68 void setNum(
unsigned int num)
72 if (this->initialized)
73 throw std::runtime_error(
"cannot set num, already initialized!");
77 unsigned int getNum()
const
82 void setRadius(
double radius)
84 if (radius == _radius)
86 if (this->initialized)
87 throw std::runtime_error(
"cannot set radius, already initialized!");
91 double getRadius()
const
96 void setSeed(
unsigned int seed)
98 if (_seed_set && seed == _seed)
100 if (this->initialized)
101 throw std::runtime_error(
"cannot set seed, already initialized!");
106 unsigned int getSeed()
const
113 std::vector<std::string> missings;
115 missings.push_back(
"num");
117 missings.push_back(
"radius");
119 missings.push_back(
"seed");
122 std::string str =
"Cannot initialize, parameters not set:";
123 for (
unsigned int ui=0; ui<missings.size(); ui++)
124 str +=
" " + missings[ui];
125 throw std::runtime_error(str);
128 ompl_lemur::StateSamplerSetSeed(_sampler, _seed);
130 this->initialized =
true;
135 throw std::runtime_error(
"RoadmapRGG deserialize from ser_data not supported!");
148 if (this->max_batches < this->num_batches_generated + 1)
149 throw std::runtime_error(
"this roadmap gen doesnt support that many batches!");
150 for (std::size_t v_index=num_vertices(this->g); v_index<_num; v_index++)
152 Vertex v_new = add_vertex(this->g);
154 put(this->vertex_batch_map, v_new, this->num_batches_generated);
155 put(this->is_shadow_map, v_new,
false);
158 put(this->state_map, v_new, this->space->allocState());
160 _sampler->sampleUniform(v_state);
161 this->nn->add(v_new);
164 std::vector<Vertex> vs_near;
165 this->nn->nearestR(v_new, _radius, vs_near);
166 for (
unsigned int ui=0; ui<vs_near.size(); ui++)
168 if (vs_near[ui] == v_new)
170 Edge e = add_edge(v_new, vs_near[ui], this->g).first;
172 put(this->distance_map, e, this->space->distance(v_state,vnear_state));
173 put(this->edge_batch_map, e, this->num_batches_generated);
176 this->num_batches_generated++;
181 throw std::runtime_error(
"RoadmapRGG serialize to ser_data not supported!");
void deserialize(const std::string &ser_data)
Re-constitute the internal generator state from serialized data.
Definition: RoadmapRGG.h:133
Definition: RoadmapRGG.h:18
void serialize(std::string &ser_data)
Serialize the internal generator state into the passed string.
Definition: RoadmapRGG.h:179
Interface for generating roadmaps over OMPL state spaces into Boost Graph objects.
Definition: Roadmap.h:76
double root_radius(std::size_t i_batch)
Calcuate the root radius to be used for connecting to potential root vertices.
Definition: RoadmapRGG.h:139
void generate()
Generates one additional batch.
Definition: RoadmapRGG.h:146
void initialize()
Initialize roadmap; must be called once after setting parameters.
Definition: RoadmapRGG.h:111