]> rtime.felk.cvut.cz Git - hubacji1/iamcar.git/commitdiff
Add random engine to RRTBase
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Wed, 6 Mar 2019 13:08:36 +0000 (14:08 +0100)
committerJiri Vlasak <hubacji1@fel.cvut.cz>
Fri, 29 Mar 2019 15:36:56 +0000 (16:36 +0100)
base/rrtbase.cc
incl/rrtbase.h

index 2331037b0c645285464c4b9b61536e438c5aba84..d074418886c802f7d62b58383005d9b74a94dc04 100644 (file)
@@ -85,7 +85,8 @@ RRTBase::~RRTBase()
 
 RRTBase::RRTBase():
         root_(new RRTNode()),
-        goal_(new RRTNode())
+        goal_(new RRTNode()),
+        gen_(std::random_device{}())
 {
         this->nodes_.reserve(NOFNODES);
         this->nodes_.push_back(this->root_);
@@ -95,7 +96,8 @@ RRTBase::RRTBase():
 
 RRTBase::RRTBase(RRTNode *init, RRTNode *goal):
         root_(init),
-        goal_(goal)
+        goal_(goal),
+        gen_(std::random_device{}())
 {
         this->nodes_.reserve(NOFNODES);
         this->nodes_.push_back(init);
index 347fbb997acb7e693ac918c9d12ae7d45043e1c1..98b4ceec731989210cb50b05a457fa2ef0e96e4e 100644 (file)
@@ -21,6 +21,7 @@ along with I am car. If not, see <http://www.gnu.org/licenses/>.
 #include <chrono>
 #include <cmath>
 #include <pthread.h>
+#include <random>
 #include <vector>
 #include "obstacle.h"
 #include "rrtnode.h"
@@ -76,6 +77,8 @@ class RRTBase {
                 std::vector<float> slog_; // seconds of trajectories
                 std::vector<std::vector<RRTNode *>> tlog_; // trajectories
                 std::vector<RRTNode *> slot_cusp_; // cusp nodes in slot
+
+                std::default_random_engine gen_;
         public:
                 const float GOAL_FOUND_DISTANCE = 0.2;
                 const float GOAL_FOUND_ANGLE = M_PI / 32;