3 void RRTExt4::Cell::nn(RRTNode *t, RRTNode **nn, RRTS *p)
5 double cost = p->cost_search(**nn, *t);
6 for (auto f: this->nodes()) {
7 if (p->cost_search(*f, *t) < cost) {
9 cost = p->cost_search(*f, *t);
14 void RRTExt4::Cell::store_node(RRTNode *n)
16 this->nodes_.push_back(n);
17 this->changed_ = true;
24 unsigned int RRTExt4::xi(RRTNode n)
26 if (n.x() >= this->x_max_)
28 if (n.x() <= this->x_min_)
30 return (unsigned int) (floor(n.x() - this->x_min_) / ETA);
33 unsigned int RRTExt4::yi(RRTNode n)
35 if (n.y() > this->y_max_)
37 if (n.y() <= this->y_min_)
39 return (unsigned int) (floor(n.y() - this->y_min_) / ETA);
45 this->x_min_ = this->nodes().back().x() - 50 * ETA;
46 this->x_max_ = this->nodes().back().x() + 50 * ETA;
47 this->y_min_ = this->nodes().back().y() - 50 * ETA;
48 this->y_max_ = this->nodes().back().y() + 50 * ETA;
51 void RRTExt4::store_node(RRTNode n)
54 RRTNode *sn = &this->nodes().back();
55 this->grid_[this->xi(n)][this->yi(n)].store_node(sn);
58 RRTNode *RRTExt4::nn(RRTNode &t)
60 RRTNode *nn = &this->nodes().front();
61 unsigned int txi = this->xi(t);
62 unsigned int tyi = this->yi(t);
64 while (this->cost_search(*nn, t) > l * ETA) {
77 for (int xi = xi_min; xi <= xi_max; xi++) {
78 this->grid_[xi][yi_max].nn(&t, &nn, this);
80 for (int xi = xi_min; xi <= xi_max; xi++) {
81 this->grid_[xi][yi_min].nn(&t, &nn, this);
83 for (int yi = yi_min + 1; yi <= yi_max - 1; yi++) {
84 this->grid_[xi_min][yi].nn(&t, &nn, this);
86 for (int yi = yi_min + 1; yi <= yi_max - 1; yi++) {
87 this->grid_[xi_max][yi].nn(&t, &nn, this);
94 std::vector<RRTNode *> RRTExt4::nv(RRTNode &t)
96 std::vector<RRTNode *> nv;
97 unsigned int txi = this->xi(t);
98 unsigned int tyi = this->yi(t);
100 double cost = std::min(GAMMA(this->nodes().size()), ETA);
101 for (auto f: this->grid_[txi][tyi].nodes())
102 if (this->cost_search(*f, t) < cost)