- Nearest neighbour `nn3` procedure based on indexing over `y` axis.
- Near vertices `nv2` procedure based on indexing over `y` axis.
- OpenMP parallelization of nearest neighbour and near vertices procedures.
+- Rebase method that changes (rebases) RRT root to another RRT node.
### Changed
- Build with Ninja.
return false;
}
+bool RRTBase::rebase(RRTNode *nr)
+{
+ std::vector<RRTNode *> s; // DFS stack
+ RRTNode *tmp;
+ unsigned int i = 0;
+ unsigned int to_del = 0;
+ int iy = 0;
+ s.push_back(this->root_);
+ while (s.size() > 0) {
+ tmp = s.back();
+ s.pop_back();
+ for (auto ch: tmp->children()) {
+ if (ch != nr)
+ s.push_back(ch);
+ }
+ to_del = this->nodes_.size();
+ #pragma omp parallel for reduction(min: to_del)
+ for (i = 0; i < this->nodes_.size(); i++) {
+ if (this->nodes_[i] == tmp)
+ to_del = i;
+ }
+ if (to_del < this->nodes_.size())
+ this->nodes_.erase(this->nodes_.begin() + to_del);
+ to_del = this->samples_.size();
+ #pragma omp parallel for reduction(min: to_del)
+ for (i = 0; i < this->samples_.size(); i++) {
+ if (this->samples_[i] == tmp)
+ to_del = i;
+ }
+ if (to_del < this->samples_.size())
+ this->samples_.erase(this->nodes_.begin() + to_del);
+ iy = floor(tmp->y() / IYSTEP) + floor(IYSIZE / 2);
+ to_del = this->iy_[iy].size();
+ #pragma omp parallel for reduction(min: to_del)
+ for (i = 0; i < this->iy_[iy].size(); i++) {
+ if (this->iy_[iy][i] == tmp)
+ to_del = i;
+ }
+ if (to_del < this->iy_[iy].size())
+ this->iy_[iy].erase(this->iy_[iy].begin() + to_del);
+ this->dnodes().push_back(tmp);
+ }
+ this->root_ = nr;
+ this->root_->parent(nullptr);
+ return true;
+}
+
std::vector<RRTNode *> RRTBase::findt()
{
return this->findt(this->goal_);
RRTNode *node,
float (*cost)(RRTNode *, RRTNode *));
bool collide(RRTNode *init, RRTNode *goal);
+ bool rebase(RRTNode *nr);
std::vector<RRTNode *> findt();
std::vector<RRTNode *> findt(RRTNode *n);