]> rtime.felk.cvut.cz Git - hubacji1/rrts.git/commitdiff
Implement anytime rrt
authorJiri Vlasak <jiri.vlasak.2@cvut.cz>
Tue, 24 Aug 2021 07:56:29 +0000 (09:56 +0200)
committerJiri Vlasak <jiri.vlasak.2@cvut.cz>
Tue, 24 Aug 2021 08:17:25 +0000 (10:17 +0200)
incl/rrts.hh
src/rrts.cc

index 0e12a5c4dc52ce82295ddcdea3a312ac68525b41..a9ef93c7351a233aea7b288a48c22104f9705ae1 100644 (file)
@@ -70,6 +70,7 @@ protected:
        double cost_ = 0.0;
        double eta_ = 0.5;
        double time_ = 0.0;
+       double last_goal_cc_ = 0.0;
        double min_gamma_eta() const;
        bool should_continue() const;
        void join_steered(RRTNode* f);
index 100c8cc243d770b4e979a1b5aefb3b0cc61155be..2700fd7b929de5938c790d5bd5b46a7c39202ebe 100644 (file)
@@ -280,6 +280,16 @@ RRTS::next()
        }
        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()) {
@@ -349,6 +359,9 @@ RRTS::next()
 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();