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;
29 unsigned int _num_per_batch;
47 _sampler(this->space->allocStateSampler())
51 throw std::runtime_error(
"NewRoadmapRGGDens only supports rel vector state spaces!");
52 _dim = this->space->getDimension();
53 if (0 == ompl_lemur::util::get_prime(_dim-1))
54 throw std::runtime_error(
"not enough primes hardcoded!");
58 this->
template declareParam<unsigned int>(
"num_per_batch",
this,
61 this->
template declareParam<double>(
"radius",
this,
62 &RoadmapRGGDensConst::setRadius,
63 &RoadmapRGGDensConst::getRadius);
64 this->
template declareParam<unsigned int>(
"seed",
this,
65 &RoadmapRGGDensConst::setSeed,
66 &RoadmapRGGDensConst::getSeed);
69 void setNumPerBatch(
unsigned int num_per_batch)
71 if (num_per_batch == _num_per_batch)
73 if (this->initialized)
74 throw std::runtime_error(
"cannot set num_per_batch, already initialized!");
75 _num_per_batch = num_per_batch;
78 unsigned int getNumPerBatch()
const
80 return _num_per_batch;
83 void setRadius(
double radius)
85 if (radius == _radius)
87 if (this->initialized)
88 throw std::runtime_error(
"cannot set radius, already initialized!");
92 double getRadius()
const
97 void setSeed(
unsigned int seed)
99 if (_seed_set && seed == _seed)
101 if (this->initialized)
102 throw std::runtime_error(
"cannot set seed, already initialized!");
107 unsigned int getSeed()
const
114 std::vector<std::string> missings;
115 if (_num_per_batch == 0)
116 missings.push_back(
"num_per_batch");
118 missings.push_back(
"radius");
120 missings.push_back(
"seed");
123 std::string str =
"Cannot initialize, parameters not set:";
124 for (
unsigned int ui=0; ui<missings.size(); ui++)
125 str +=
" " + missings[ui];
126 throw std::runtime_error(str);
129 ompl_lemur::StateSamplerSetSeed(_sampler, _seed);
131 this->initialized =
true;
136 throw std::runtime_error(
"RoadmapRGGDensConst deserialize from ser_data not supported!");
150 std::size_t n = (this->num_batches_generated+1) * _num_per_batch;
151 for (std::size_t v_index=num_vertices(this->g); v_index<n; v_index++)
153 Vertex v_new = add_vertex(this->g);
155 put(this->vertex_batch_map, v_new, this->num_batches_generated);
156 put(this->is_shadow_map, v_new,
false);
159 put(this->state_map, v_new, this->space->allocState());
161 _sampler->sampleUniform(v_state);
162 this->nn->add(v_new);
165 std::vector<Vertex> vs_near;
166 this->nn->nearestR(v_new, _radius, vs_near);
167 for (
unsigned int ui=0; ui<vs_near.size(); ui++)
169 if (vs_near[ui] == v_new)
171 Edge e = add_edge(v_new, vs_near[ui], this->g).first;
173 put(this->distance_map, e, this->space->distance(v_state,vnear_state));
174 put(this->edge_batch_map, e, this->num_batches_generated);
177 this->num_batches_generated++;
182 throw std::runtime_error(
"RoadmapRGGDensConst serialize to ser_data not supported!");
Definition: RoadmapRGGDensConst.h:18
void initialize()
Initialize roadmap; must be called once after setting parameters.
Definition: RoadmapRGGDensConst.h:112
void deserialize(const std::string &ser_data)
Re-constitute the internal generator state from serialized data.
Definition: RoadmapRGGDensConst.h:134
void serialize(std::string &ser_data)
Serialize the internal generator state into the passed string.
Definition: RoadmapRGGDensConst.h:180
Interface for generating roadmaps over OMPL state spaces into Boost Graph objects.
Definition: Roadmap.h:76
void generate()
Generates one additional batch.
Definition: RoadmapRGGDensConst.h:147
double root_radius(std::size_t i_batch)
Calcuate the root radius to be used for connecting to potential root vertices.
Definition: RoadmapRGGDensConst.h:140