]> rtime.felk.cvut.cz Git - hubacji1/iamcar.git/commitdiff
Stop when nodes().size() overflow
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Thu, 17 Jan 2019 09:51:01 +0000 (10:51 +0100)
committerJiri Vlasak <hubacji1@fel.cvut.cz>
Fri, 18 Jan 2019 09:22:03 +0000 (10:22 +0100)
base/main.cc
base/rrtbase.cc
incl/rrtbase.h

index 1442d4a0da3183bed719ce8bcd948876019c46c9..b364173b14c0ed5caa4ebb3fd3be8652732e1704 100644 (file)
@@ -197,7 +197,9 @@ int main()
         p.p_goal_.tstart();
         pthread_create(&rt, NULL, &next_run, (void *) &ra);
         pthread_create(&gt, NULL, &next_run, (void *) &ga);
-        while (!gf && p.elapsed() < TMAX) {
+        while (!gf && p.elapsed() < TMAX &&
+                        p.p_root_.nodes().size() < NOFNODES &&
+                        p.p_goal_.nodes().size() < NOFNODES) {
                 // overlap trees
                 for (int i = 0; i < IXSIZE; i++) {
                 for (int j = 0; j < IYSIZE; j++) {
index 0cabc238b81ab76b4e16ac2791e8749c21f27513..6e0cc4c2a20963eca81d8fdd60eeccf858219288 100644 (file)
@@ -87,7 +87,7 @@ RRTBase::RRTBase():
         root_(new RRTNode()),
         goal_(new RRTNode())
 {
-        this->nodes_.reserve(20000);
+        this->nodes_.reserve(NOFNODES);
         this->nodes_.push_back(this->root_);
         this->add_iy(this->root_);
         this->add_ixy(this->root_);
@@ -97,7 +97,7 @@ RRTBase::RRTBase(RRTNode *init, RRTNode *goal):
         root_(init),
         goal_(goal)
 {
-        this->nodes_.reserve(20000);
+        this->nodes_.reserve(NOFNODES);
         this->nodes_.push_back(init);
         this->add_iy(init);
         this->add_ixy(init);
index 2799d84691f11cb2d629b4776eda9ac49570260a..7a5c9323bea93d6c12b8eaf630bf774cd543e084 100644 (file)
@@ -26,6 +26,8 @@ along with I am car. If not, see <http://www.gnu.org/licenses/>.
 #include "rrtnode.h"
 #include "sample.h"
 
+#define NOFNODES 20000
+
 #define IXSIZE 100
 #define IXSTEP (1.0 * ((VMAX) - (VMIN)) / IXSIZE)
 #define IXI(x) ({ __typeof__ (x) _x = (x); \