/*! \brief Reeds & Shepp (build) and Euclidean + abs angle (search).
*
* Use Reeds & Shepp path length for building tree data structure and Euclidean
- * distance plus (abs) heading difference for searching it.
+ * distance + (abs) heading difference + 0.1 * backward-forward direction
+ * changes for searching it.
*
* \ingroup ext-cost
* \see https://doi.org/10.1109/TITS.2015.2477355
double c_ = 0.0;
double cc_ = 0.0;
RRTNode* p_ = nullptr;
+ unsigned int cusp_ = 0;
public:
/*! Get cost to parent. */
double c() const;
/*! Set parent node. */
void p(RRTNode& p);
+ /*! Get number of backward-forward direction changes. */
+ unsigned int cusp() const;
+
+ /*! Set number of backward-forward direction changes. */
+ void cusp(RRTNode const& p);
+
bool operator==(RRTNode const& n);
};
double
RRTExt10::cost_search(RRTNode const& f, RRTNode const& t) const
{
- return f.edist(t) + std::abs(t.h() - f.h());
+ return f.edist(t) + std::abs(t.h() - f.h()) + f.cusp() * 0.1;
}
} // namespace rrts
}
}
+unsigned int
+RRTNode::cusp() const
+{
+ return this->cusp_;
+}
+
+void
+RRTNode::cusp(RRTNode const& p)
+{
+ this->cusp_ = p.cusp();
+ if (this->sp() != p.sp() || this->sp() == 0.0) {
+ this->cusp_++;
+ }
+}
+
bool
RRTNode::operator==(RRTNode const& n)
{
RRTNode* t = &this->nodes_.back();
t->p(*f);
t->c(this->cost_build(*f, *t));
+ t->cusp(*f);
this->steered_.erase(this->steered_.begin());
f = t;
}
t = &this->nodes_.back();
t->p(*f);
t->c(this->cost_build(*f, *t));
+ t->cusp(*f);
this->steered_.erase(this->steered_.begin());
return true;
}