From: Jiri Vlasak Date: Thu, 17 Jan 2019 09:51:01 +0000 (+0100) Subject: Stop when nodes().size() overflow X-Git-Tag: v0.5.0~3^2~4 X-Git-Url: https://rtime.felk.cvut.cz/gitweb/hubacji1/iamcar.git/commitdiff_plain/3687612ab68117cc6d7903231a6d59bcb09ab6e9 Stop when nodes().size() overflow --- diff --git a/base/main.cc b/base/main.cc index 1442d4a..b364173 100644 --- a/base/main.cc +++ b/base/main.cc @@ -197,7 +197,9 @@ int main() p.p_goal_.tstart(); pthread_create(&rt, NULL, &next_run, (void *) &ra); pthread_create(>, 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++) { diff --git a/base/rrtbase.cc b/base/rrtbase.cc index 0cabc23..6e0cc4c 100644 --- a/base/rrtbase.cc +++ b/base/rrtbase.cc @@ -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); diff --git a/incl/rrtbase.h b/incl/rrtbase.h index 2799d84..7a5c932 100644 --- a/incl/rrtbase.h +++ b/incl/rrtbase.h @@ -26,6 +26,8 @@ along with I am car. If not, see . #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); \