]> rtime.felk.cvut.cz Git - hubacji1/iamcar.git/commitdiff
Make `nn` procedure part of RRTBase
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Mon, 10 Dec 2018 09:01:23 +0000 (10:01 +0100)
committerJiri Vlasak <hubacji1@fel.cvut.cz>
Mon, 10 Dec 2018 09:34:56 +0000 (10:34 +0100)
CHANGELOG.md
CMakeLists.txt
README.md
base/rrtbase.cc
decision_control/rrtplanner.cc
incl/compile.h
incl/rrtbase.h
incl/rrtplanner.h

index ba0e1fa6f8e83b671ab9cf8c95e25b0fa33161a1..cdea3605fce1aa82052e840592036237dffc09d5 100644 (file)
@@ -15,6 +15,7 @@ The format is based on [Keep a Changelog][] and this project adheres to
 ### Changed
 - Make `sample` procedure part of RRTBase.
 - Make `cost` function part of RRTBase.
+- Make `nn` procedure part of RRTBase.
 
 ## 0.3.0 - 2018-12-03
 ### Added
index 3f4d661ce10e021ec98075bd29279b072edeb9c7..fc164d7e09b43fc2297b840518fcd90c994dc7c3 100644 (file)
@@ -7,9 +7,6 @@ ENDIF(PLANNER)
 IF(TMAX)
         ADD_DEFINITIONS(-DTMAX=${TMAX})
 ENDIF(TMAX)
-IF(NN)
-        ADD_DEFINITIONS(-DNN=${NN})
-ENDIF(NN)
 IF(NV)
         ADD_DEFINITIONS(-DNV=${NV})
 ENDIF(NV)
@@ -17,10 +14,6 @@ IF(ST)
         ADD_DEFINITIONS(-DST=${ST})
 ENDIF(ST)
 
-IF(NNVERSION)
-        ADD_DEFINITIONS(-DNNVERSION=${NNVERSION})
-ENDIF(NNVERSION)
-
 IF(NVVERSION)
         ADD_DEFINITIONS(-DNVVERSION=${NVVERSION})
 ENDIF(NVVERSION)
index 7b18b73081c565777f749899fe407f26f8225999..0c76203e30956b6422164f43d82ae45c807034f5 100644 (file)
--- a/README.md
+++ b/README.md
@@ -33,8 +33,6 @@ The list of available macros with values:
         - `Kuwata2008` - RRT with changing cost and steering to goal.
         - `Karaman2011` - RRT* framework.
 - `TMAX` - Specify the upper time bound in seconds.
-- `NN`
-        - `nn1` - Nearest neighbour basic DFS procedure.
 - `NV`
         - `nv1` - Near vertices basic DFS procedure.
 - `ST`
index 8a05b3e0087c0570bcf4ee250184f4da5a567123..4725655e405c4077524b755f67a88fcba79b6c78 100644 (file)
@@ -29,6 +29,7 @@ along with I am car. If not, see <http://www.gnu.org/licenses/>.
 #include "sample.h"
 #include "cost.h"
 #include "steer.h"
+#include "nn.h"
 
 extern SDL_Window* gw;
 extern SDL_GLContext gc;
@@ -685,3 +686,8 @@ float RRTBase::cost(RRTNode *init, RRTNode *goal)
 {
         return co2(init, goal);
 }
+
+RRTNode *RRTBase::nn(RRTNode *rs)
+{
+        return nn4(this->iy_, rs, nullptr);
+}
index 7c3e312a3ac249218e239023cd0f06fa50cd2863..b88199ccf00e46a4d8ce390b18327c44b69ab3c1 100644 (file)
@@ -33,7 +33,6 @@ along with I am car. If not, see <http://www.gnu.org/licenses/>.
 
 LaValle1998::LaValle1998(RRTNode *init, RRTNode *goal):
         RRTBase(init, goal),
-        nn(NN),
         steer(ST)
 {
         srand(static_cast<unsigned>(time(0)));
@@ -51,13 +50,7 @@ bool LaValle1998::next()
         rs = this->sample();
 #endif
         this->samples().push_back(rs);
-#if NNVERSION>2
-        RRTNode *nn = this->nn(this->iy_, rs, this->cost, '0');
-#elif NNVERSION>1
-        RRTNode *nn = this->nn(this->iy_, rs, &this->cost);
-#else
-        RRTNode *nn = this->nn(this->nodes(), rs, this->cost);
-#endif
+        RRTNode *nn = this->nn(rs);
         RRTNode *pn = nn;
         bool en_add = true;
         for (auto ns: this->steer(nn, rs)) {
@@ -87,7 +80,6 @@ bool LaValle1998::next()
 
 Kuwata2008::Kuwata2008(RRTNode *init, RRTNode *goal):
         RRTBase(init, goal),
-        nn(NN),
         steer(ST)
 {
         srand(static_cast<unsigned>(time(0)));
@@ -114,13 +106,7 @@ bool Kuwata2008::next()
                 else
                         {}//this->cost = &KUWATA2008_DCOST;
         }
-#if NNVERSION>2
-        RRTNode *nn = this->nn(this->iy_, rs, this->cost, '0');
-#elif NNVERSION>1
-        RRTNode *nn = this->nn(this->iy_, rs, this->cost);
-#else
-        RRTNode *nn = this->nn(this->nodes(), rs, this->cost);
-#endif
+        RRTNode *nn = this->nn(rs);
         RRTNode *pn = nn;
         std::vector<RRTNode *> newly_added;
         bool en_add = true;
@@ -181,7 +167,6 @@ bool Kuwata2008::next()
 
 Karaman2011::Karaman2011(RRTNode *init, RRTNode *goal):
         RRTBase(init, goal),
-        nn(NN),
         nv(NV),
         steer(ST)
 {
@@ -200,13 +185,7 @@ bool Karaman2011::next()
         rs = this->sample();
 #endif
         this->samples().push_back(rs);
-#if NNVERSION>2
-        RRTNode *nn = this->nn(this->iy_, rs, this->cost, '0');
-#elif NNVERSION>1
-        RRTNode *nn = this->nn(this->iy_, rs, this->cost);
-#else
-        RRTNode *nn = this->nn(this->nodes(), rs, this->cost);
-#endif
+        RRTNode *nn = this->nn(rs);
         RRTNode *pn = nn;
         std::vector<RRTNode *> nvs;
         bool en_add = true;
@@ -332,7 +311,6 @@ bool Karaman2011::rewire(std::vector<RRTNode *> nvs, RRTNode *ns)
 
 T1::T1(RRTNode *init, RRTNode *goal):
         RRTBase(init, goal),
-        nn(NN),
         nv(NV),
         steer(ST)
 {
@@ -347,13 +325,7 @@ bool T1::next()
         else
                 rs = this->sample();
         this->samples().push_back(rs);
-#if NNVERSION>2
-        RRTNode *nn = this->nn(this->iy_, rs, this->cost, '0');
-#elif NNVERSION>1
-        RRTNode *nn = this->nn(this->iy_, rs, this->cost);
-#else
-        RRTNode *nn = this->nn(this->nodes(), rs, this->cost);
-#endif
+        RRTNode *nn = this->nn(rs);
         RRTNode *pn = nn;
         std::vector<RRTNode *> nvs;
         bool connected;
@@ -467,13 +439,7 @@ bool T2::next()
         rs = this->sample();
 #endif
         this->samples().push_back(rs);
-#if NNVERSION>2
-        RRTNode *nn = this->nn(this->iy_, rs, this->cost, '0');
-#elif NNVERSION>1
-        RRTNode *nn = this->nn(this->iy_, rs, this->cost);
-#else
-        RRTNode *nn = this->nn(this->nodes(), rs, this->cost);
-#endif
+        RRTNode *nn = this->nn(rs);
         if (!nn)
                 return false;
         RRTNode *pn = nn;
@@ -705,7 +671,6 @@ bool T3::overlaptrees(RRTNode **ron, RRTNode **gon)
 
 Klemm2015::Klemm2015(RRTNode *init, RRTNode *goal):
         Karaman2011(init, goal),
-        nn(NN),
         nv(NV),
         steer(ST),
         orig_root_(init),
@@ -779,13 +744,7 @@ int Klemm2015::extendstar1(RRTNode *rs, RRTNode **xn)
         //                std::cerr << std::endl;
         //        }
         //}
-#if NNVERSION>2
-        RRTNode *nn = this->nn(this->iy_, rs, this->cost, tree);
-#elif NNVERSION>1
-        RRTNode *nn = this->nn(this->iy_, rs, this->cost);
-#else
-        RRTNode *nn = this->nn(this->nodes(), rs, this->cost);
-#endif
+        RRTNode *nn = this->nn(rs);
         //std::cerr << "  - nn: " << nn->x() << ", " << nn->y() << std::endl;
         std::vector<RRTNode *> nvs;
         std::vector<RRTNode *> steered = this->steer(nn, rs);
@@ -847,13 +806,7 @@ int Klemm2015::extendstarC(RRTNode *rs)
         //std::cerr << "extend*C" << std::endl;
         //std::cerr << "- tree is " << tree << std::endl;
         //std::cerr << "  - rs: " << rs->x() << ", " << rs->y() << std::endl;
-#if NNVERSION>2
-        RRTNode *nn = this->nn(this->iy_, rs, this->cost, tree);
-#elif NNVERSION>1
-        RRTNode *nn = this->nn(this->iy_, rs, this->cost);
-#else
-        RRTNode *nn = this->nn(this->nodes(), rs, this->cost);
-#endif
+        RRTNode *nn = this->nn(rs);
         RRTNode *pn = nn;
         std::vector<RRTNode *> nvs;
         bool en_add = true;
index e5f2b1d969f58155e462d2e0e60f1c32b87cad4f..75444b9f344fb16866aa441285ca3c81ded31ea6 100644 (file)
@@ -26,10 +26,6 @@ along with I am car. If not, see <http://www.gnu.org/licenses/>.
 #define TMAX 10
 #endif
 
-#ifndef NN
-#define NN nn1
-#endif
-
 #ifndef NV
 #define NV nv1
 #endif
index a1ee10c0604c91b79b5f943ef023f0cfa0cefd15..7d82a58ec0d12ab40e85d05d103f75534026c726 100644 (file)
@@ -103,6 +103,7 @@ class RRTBase {
                 // RRT Framework
                 RRTNode *sample();
                 float cost(RRTNode *init, RRTNode *goal);
+                RRTNode *nn(RRTNode *rs);
 
                 // virtuals - implemented by child classes
                 virtual bool next() = 0;
index 53195dbdf55fb6d516fe9ffff0497dd27b734d55..25854e4f53034d15ac2296260b3a802dd317a16a 100644 (file)
@@ -30,18 +30,6 @@ class LaValle1998: public RRTBase {
                 LaValle1998(RRTNode *init, RRTNode *goal);
 
                 // RRT framework
-                RRTNode *(*nn)(
-#if NNVERSION>1
-                                std::vector<RRTNode *> (&nodes)[IYSIZE],
-#else
-                                std::vector<RRTNode *> &nodes,
-#endif
-                                RRTNode *node,
-                                float (*cost)(RRTNode *, RRTNode *)
-#if NNVERSION>2
-                                , char tree
-#endif
-                                );
                 std::vector<RRTNode *> (*steer)(
                                 RRTNode *init,
                                 RRTNode *goal);
@@ -53,18 +41,6 @@ class Kuwata2008: public RRTBase {
                 Kuwata2008(RRTNode *init, RRTNode *goal);
 
                 // RRT framework
-                RRTNode *(*nn)(
-#if NNVERSION>1
-                                std::vector<RRTNode *> (&nodes)[IYSIZE],
-#else
-                                std::vector<RRTNode *> &nodes,
-#endif
-                                RRTNode *node,
-                                float (*cost)(RRTNode *, RRTNode *)
-#if NNVERSION>2
-                                , char tree
-#endif
-                                );
                 std::vector<RRTNode *> (*steer)(
                                 RRTNode *init,
                                 RRTNode *goal);
@@ -82,18 +58,6 @@ class Karaman2011: public RRTBase {
                 Karaman2011(RRTNode *init, RRTNode *goal);
 
                 // RRT framework
-                RRTNode *(*nn)(
-#if NNVERSION>1
-                                std::vector<RRTNode *> (&nodes)[IYSIZE],
-#else
-                                std::vector<RRTNode *> &nodes,
-#endif
-                                RRTNode *node,
-                                float (*cost)(RRTNode *, RRTNode *)
-#if NNVERSION>2
-                                , char tree
-#endif
-                                );
                 std::vector<RRTNode *> (*nv)(
 #if NVVERSION>1
                                 std::vector<RRTNode *> (&nodes)[IYSIZE],
@@ -118,18 +82,6 @@ class T1: public RRTBase {
                 T1(RRTNode *init, RRTNode *goal);
 
                 // RRT framework
-                RRTNode *(*nn)(
-#if NNVERSION>1
-                                std::vector<RRTNode *> (&nodes)[IYSIZE],
-#else
-                                std::vector<RRTNode *> &nodes,
-#endif
-                                RRTNode *node,
-                                float (*cost)(RRTNode *, RRTNode *)
-#if NNVERSION>2
-                                , char tree
-#endif
-                                );
                 std::vector<RRTNode *> (*nv)(
 #if NVVERSION>1
                                 std::vector<RRTNode *> (&nodes)[IYSIZE],
@@ -184,18 +136,6 @@ class Klemm2015: public Karaman2011 {
                 Klemm2015(RRTNode *init, RRTNode *goal);
 
                 // RRT framework
-                RRTNode *(*nn)(
-#if NNVERSION>1
-                                std::vector<RRTNode *> (&nodes)[IYSIZE],
-#else
-                                std::vector<RRTNode *> &nodes,
-#endif
-                                RRTNode *node,
-                                float (*cost)(RRTNode *, RRTNode *)
-#if NNVERSION>2
-                                , char tree
-#endif
-                                );
                 std::vector<RRTNode *> (*nv)(
 #if NVVERSION>1
                                 std::vector<RRTNode *> (&nodes)[IYSIZE],