namespace rrts {
+class P39 : public RRTExt2, public RRTExt8, public RRTExt10, public RRTExt14,
+ public RRTExt15, public RRTExt16, public RRTExt17,
+ public RRTExt13 {
+public:
+ Json::Value json() const
+ {
+ auto jvo = RRTExt13::json();
+ auto json15 = RRTExt15::json();
+ jvo["log_path_cost"] = json15["log_path_cost"];
+ return jvo;
+ }
+ void json(Json::Value jvi)
+ {
+ RRTExt2::json(jvi);
+ }
+ void reset()
+ {
+ RRTExt8::reset();
+ RRTExt14::reset();
+ RRTExt13::reset();
+ }
+};
+
class P38 : public RRTExt2, public RRTExt8, public RRTExt10, public RRTExt14,
public RRTExt15, public RRTExt16, public RRTExt18,
public RRTExt13 {
#include <queue>
#include "rrtext.hh"
-#include <iostream>
-using namespace std;
namespace rrts {
{
this->dn_.clear();
this->dn_.reserve(this->path_.size());
- //for (auto n: this->opath_) {
- // this->dn_.push_back(DijkstraNode(n));
- // this->dn_.back().i = this->dn_.size() - 1;
- //}
- //return;
+#if 0 // all path poses are interesting
+ for (auto n: this->opath_) {
+ this->dn_.push_back(DijkstraNode(n));
+ this->dn_.back().i = this->dn_.size() - 1;
+ }
+ return;
+#endif
+#if 1 // cusp and 1st non-drivable path poses are interesting
for (unsigned int i = 0; i < this->opath_.size() - 1; i++) {
- //unsigned int i = 0; {
+ //unsigned int i = 0; { // just for cusp, comment out drivable section
RRTNode& ni = *this->opath_[i];
this->bc_.set_pose(ni);
for (unsigned int j = i + 1; j < this->opath_.size(); j++) {
}
this->dn_.push_back(DijkstraNode(this->opath_.back()));
this->dn_.back().i = this->dn_.size() - 1;
+#endif
}
void
RRTExt13::compute_path()
{
RRTS::compute_path();
+ if (this->goal_.cc() == 0.0 || this->path_.size() == 0) {
+ return;
+ }
+#if 0 // TODO 0.59 should work for sc4-1-0 only.
+ if (this->goal_.cc() * 0.59 > this->last_goal_cc_
+ && this->last_goal_cc_ != 0.0) {
+ return;
+ }
+#endif
bool measure_time = false;
if (this->opath_.size() == 0) {
this->opath_ = this->path_;
}
this->pick_interesting();
this->dijkstra_forward();
+#if 0 // TODO Fix as the code does not always finish.
+ RRTS::compute_path();
this->pick_interesting();
this->dijkstra_backward();
+#endif
RRTS::compute_path();
if (measure_time) {
this->otime_ += this->ter_.scnt();
{
RRTS::reset();
this->opath_.clear();
- this->ogoal_cc_ = 0.0;
- this->otime_ = 0.0;
}
} // namespace rrts
}
this->icnt_ += 1;
auto rs = this->sample();
+#if 1 // anytime RRTs
+{
+ double d1 = this->cost_search(this->nodes_.front(), rs);
+ double d2 = this->cost_search(rs, this->goal_);
+ if (this->last_goal_cc_ != 0.0 && d1 + d2 > this->last_goal_cc_) {
+ this->icnt_ -= 1;
+ return this->should_continue();
+ }
+}
+#endif
this->find_nn(rs);
this->steer(this->nn(), rs);
if (this->collide_steered()) {
unsigned int ss = this->steered_.size();
this->join_steered(&this->nodes_.back());
RRTNode* just_added = &this->nodes_.back();
+ bool gf = false;
while (ss > 0 && just_added->p() != nullptr) {
- //if (!this->goal_drivable_from(*just_added)) {
- // ss--;
- // just_added = just_added->p();
- // continue;
- //}
this->steer(*just_added, this->goal_);
if (this->collide_steered()) {
ss--;
|| ncc < this->goal_.cc()) {
this->goal_.p(this->nodes_.back());
this->goal_.c(nc);
- this->compute_path();
+ gf = true;
}
}
ss--;
just_added = just_added->p();
}
-
- ////if (!this->goal_drivable_from(this->nodes_.back())) {
- //// return this->should_continue();
- ////}
- //this->steer(this->nodes_.back(), this->goal_);
- //if (this->collide_steered()) {
- // return this->should_continue();
- //}
- //this->join_steered(&this->nodes_.back());
- //bool gn = this->goal_.edist(this->nodes_.back()) < this->eta_;
- //bool gd = this->goal_drivable_from(this->nodes_.back());
- //if (gn && gd) {
- // double nc = this->cost_build(this->nodes_.back(), this->goal_);
- // double ncc = this->nodes_.back().cc() + nc;
- // if (this->goal_.p() == nullptr || ncc < this->goal_.cc()) {
- // this->goal_.p(this->nodes_.back());
- // this->goal_.c(nc);
- // this->compute_path();
- // }
- //}
+#if 1 // test if root -> just_added can be steered directly
+ this->steer(this->nodes_.front(), *just_added);
+ ss = this->steered_.size();
+ if (!this->collide_steered() && this->steered_.size() == ss) {
+ this->join_steered(&this->nodes_.front());
+ just_added->p(this->nodes_.back());
+ just_added->c(this->cost_build(this->nodes_.back(),
+ *just_added));
+ }
+#endif
+ if (gf) {
+ this->compute_path();
+ }
this->time_ = this->ter_.scnt();
return this->should_continue();
}
void
RRTS::reset()
{
+ if (this->goal_.cc() != 0.0 && this->goal_.cc() < this->last_goal_cc_) {
+ this->last_goal_cc_ = this->goal_.cc();
+ }
this->goal_ = RRTGoal(this->goal_.x(), this->goal_.y(), this->goal_.b(),
this->goal_.e());
this->path_.clear();