/*! Set if the parent node is cusp (direction changed from parent). */
void p_is_cusp(bool isit);
+ /*! Return true if p would be cusp if set as parent of this. */
+ bool would_be_cusp_if_parent(RRTNode const& p) const;
+
bool operator==(RRTNode const& n);
};
if (this != &p) {
this->_p = &p;
}
+ this->p_is_cusp(this->would_be_cusp_if_parent(p));
+ this->cusp_cnt(p);
}
unsigned int
this->_p_is_cusp = isit;
}
+bool
+RRTNode::would_be_cusp_if_parent(RRTNode const& p) const
+{
+ if (p.sp() == 0) {
+ assert(this->sp() != 0);
+ if (p.p()) {
+ if (sgn(p.p()->sp()) != sgn(this->sp())) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return true; // only root has no parent and it is cusp
+ }
+ } else {
+ if (this->sp() == 0) {
+ return false; // this is cusp, not the parent
+ } else if (sgn(p.sp()) != sgn(this->sp())) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+}
+
bool
RRTNode::operator==(RRTNode const& n)
{
RRTNode* t = &this->_nodes.back();
t->p(*f);
t->c(this->cost_build(*f, *t));
- t->cusp_cnt(*f);
this->_steered.erase(this->_steered.begin());
f = t;
}
assert(std::abs(t->x() - f->x()) < 1e-3);
assert(std::abs(t->y() - f->x()) < 1e-3);
assert(std::abs(t->h() - f->x()) < 1e-3);
- // When f and t has different directions, the node (f == t) is cusp:
- // TODO
this->_steered.erase(this->_steered.begin());
t = &this->_steered.front();
#if USE_RRTS
t = &this->_nodes.back();
t->p(*f);
t->c(this->cost_build(*f, *t));
- t->cusp_cnt(*f);
this->_steered.erase(this->_steered.begin());
return true;
}