]> rtime.felk.cvut.cz Git - hubacji1/iamcar.git/commitdiff
Use sampling info for setting up the sampling
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Tue, 11 Jun 2019 14:30:54 +0000 (16:30 +0200)
committerJiri Vlasak <hubacji1@fel.cvut.cz>
Tue, 11 Jun 2019 14:30:55 +0000 (16:30 +0200)
But comment it for now as the values used in sampling info don't
correspond to needed values.

base/main.cc
base/rrtbase.cc
incl/rrtbase.h

index 614709ac2eaea262ae89dc2667d8d635d99125d7..3b1751d88e3a0ce7b324209cb2a4575cd5767be3 100644 (file)
@@ -196,8 +196,7 @@ int main()
 #endif
         if (ps.slot().bnodes().size() > 0) {
                 ps.setAll();
-                p.samplingInfo_ = ps.getSamplingInfo();
-                p.useSamplingInfo_ = true;
+                //p.setSamplingInfo(ps.getSamplingInfo());
         }
         if (ps.cusp().size() > 0) {
                 p.goal(ps.getMidd());
index ed41b9185db661f3cdd4897b8591c81fa9678508..9600bb42db98097971ff5a8c969787cb37d4d0b5 100644 (file)
@@ -990,28 +990,19 @@ std::vector<RRTNode *> RRTBase::findt(RRTNode *n)
 }
 
 // RRT Framework
+void RRTBase::setSamplingInfo(SamplingInfo si)
+{
+        this->ndx_ = std::normal_distribution<float>(si.x0, si.x);
+        this->ndy_ = std::normal_distribution<float>(si.y0, si.y);
+        this->ndh_ = std::normal_distribution<float>(si.h0, si.h);
+}
+
 RRTNode *RRTBase::sample()
 {
-        if (this->useSamplingInfo_ && this->nodes().size() % 2 == 0) {
-                float x = static_cast<float>(rand());
-                x /= static_cast<float>(RAND_MAX / this->samplingInfo_.x);
-                x -= this->samplingInfo_.x / 2;
-                x += this->samplingInfo_.x0;
-                float y = static_cast<float>(rand());
-                y /= static_cast<float>(RAND_MAX / this->samplingInfo_.y);
-                y -= this->samplingInfo_.y / 2;
-                y += this->samplingInfo_.y0;
-                float h = static_cast<float>(rand());
-                h /= static_cast<float>(RAND_MAX / this->samplingInfo_.h);
-                h -= this->samplingInfo_.h / 2;
-                h += this->samplingInfo_.h0;
-                return new RRTNode(x, y, h);
-        } else {
-                float x = this->ndx_(this->gen_);
-                float y = this->ndy_(this->gen_);
-                float h = this->ndh_(this->gen_);
-                return new RRTNode(x, y, h);
-        }
+        float x = this->ndx_(this->gen_);
+        float y = this->ndy_(this->gen_);
+        float h = this->ndh_(this->gen_);
+        return new RRTNode(x, y, h);
 }
 
 float RRTBase::cost(RRTNode *init, RRTNode *goal)
index f83be79cfaa4751a91145969a047bdf1906d1fe1..023a55053e6f20c4bb82887fde3ba9100098df77 100644 (file)
@@ -158,8 +158,7 @@ class RRTBase {
                 std::vector<RRTNode *> findt(RRTNode *n);
 
                 // RRT Framework
-                SamplingInfo samplingInfo_;
-                bool useSamplingInfo_ = false;
+                void setSamplingInfo(SamplingInfo si);
                 RRTNode *sample();
                 float cost(RRTNode *init, RRTNode *goal);
                 RRTNode *nn(RRTNode *rs);