- Make `sample` procedure part of RRTBase.
- Make `cost` function part of RRTBase.
- Make `nn` procedure part of RRTBase.
+- Make `nv` procedure part of RRTBase.
## 0.3.0 - 2018-12-03
### Added
IF(TMAX)
ADD_DEFINITIONS(-DTMAX=${TMAX})
ENDIF(TMAX)
-IF(NV)
- ADD_DEFINITIONS(-DNV=${NV})
-ENDIF(NV)
IF(ST)
ADD_DEFINITIONS(-DST=${ST})
ENDIF(ST)
-IF(NVVERSION)
- ADD_DEFINITIONS(-DNVVERSION=${NVVERSION})
-ENDIF(NVVERSION)
-
find_package(OpenMP)
if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
- `Kuwata2008` - RRT with changing cost and steering to goal.
- `Karaman2011` - RRT* framework.
- `TMAX` - Specify the upper time bound in seconds.
-- `NV`
- - `nv1` - Near vertices basic DFS procedure.
- `ST`
- `st1` - Steer directly to goal.
- `st2` - Steer with maximum turning radius and direction in mind.
#include "cost.h"
#include "steer.h"
#include "nn.h"
+#include "nv.h"
extern SDL_Window* gw;
extern SDL_GLContext gc;
{
return nn4(this->iy_, rs, nullptr);
}
+
+std::vector<RRTNode *> RRTBase::nv(RRTNode *node, float dist)
+{
+ std::vector<RRTNode *> nvs;
+ unsigned int iy = IYI(node->y());
+ unsigned int iy_dist = floor(dist / IYSTEP) + 1;
+ unsigned int i = 0; // vector index
+ unsigned int j = 0; // array index
+ unsigned int jmin = 0; // minimal j index
+ unsigned int jmax = 0; // maximal j index
+ jmin = iy - iy_dist;
+ jmin = (jmin > 0) ? jmin : 0;
+ jmax = iy + iy_dist + 1;
+ jmax = (jmax < IYSIZE) ? jmax : IYSIZE;
+ #pragma omp parallel for reduction(merge: nvs)
+ for (j = jmin; j < jmax; j++) {
+ #pragma omp parallel for reduction(merge: nvs)
+ for (i = 0; i < this->iy_[j].size(); i++) {
+ if (this->cost(this->iy_[j][i], node) < dist) {
+ nvs.push_back(this->iy_[j][i]);
+ }
+ }
+ }
+ return nvs;
+}
Karaman2011::Karaman2011(RRTNode *init, RRTNode *goal):
RRTBase(init, goal),
- nv(NV),
steer(ST)
{
srand(static_cast<unsigned>(time(0)));
if (!en_add) {
delete ns;
} else {
-#if NVVERSION>2
- nvs = this->nv(
- this->iy_,
- ns,
- CO,
- MIN(
- GAMMA_RRTSTAR(
- this->nodes().size()),
- 0.2),
- '0'); // TODO const
-#elif NVVERSION>1
- nvs = this->nv(
- this->iy_,
- ns,
- CO,
- MIN(
- GAMMA_RRTSTAR(
- this->nodes().size()),
- 0.2)); // TODO const
-#else
- nvs = this->nv(
- this->root(),
- ns,
- CO,
- MIN(
- GAMMA_RRTSTAR(
+ nvs = this->nv(ns,
+ MIN(GAMMA_RRTSTAR(
this->nodes().size()),
- 0.2)); // TODO const
-#endif
+ 0.2));
this->nodes().push_back(ns);
this->add_iy(ns);
// connect
T1::T1(RRTNode *init, RRTNode *goal):
RRTBase(init, goal),
- nv(NV),
steer(ST)
{
srand(static_cast<unsigned>(time(0)));
// RRT* for first node
RRTNode *ns = steered[0];
{
-#if NVVERSION>2
- nvs = this->nv(
- this->iy_,
- ns,
- CO,
- MIN(
- GAMMA_RRTSTAR(
- this->nodes().size()),
- 0.2),
- '0'); // TODO const
-#elif NVVERSION>1
- nvs = this->nv(this->iy_, ns, CO, MIN(
- GAMMA_RRTSTAR(this->nodes().size()),
- 0.2)); // TODO const
-#else
- nvs = this->nv(this->root(), ns, CO, MIN(
- GAMMA_RRTSTAR(this->nodes().size()),
- 0.2)); // TODO const
-#endif
+ nvs = this->nv(ns, MIN(
+ GAMMA_RRTSTAR(this->nodes().size()),
+ 0.2)); // TODO const
this->nodes().push_back(ns);
this->add_iy(ns);
connected = false;
cusps++;
if (cusps > 4)
en_add = false;
-#if NVVERSION>2
- nvs = this->nv(
- this->iy_,
- ns,
- CO,
- MIN(
- GAMMA_RRTSTAR(
- this->nodes().size()),
- 0.2),
- '0'); // TODO const
-#elif NVVERSION>1
- nvs = this->nv(
- this->iy_,
- ns,
- CO,
- MIN(
- GAMMA_RRTSTAR(
- this->nodes().size()),
- 0.2)); // TODO const
-#else
nvs = this->nv(
- this->root(),
ns,
- CO,
MIN(
GAMMA_RRTSTAR(
this->nodes().size()),
0.2)); // TODO const
-#endif
this->nodes().push_back(ns);
this->add_iy(ns);
// connect
float T2::goal_cost()
{
std::vector<RRTNode *> nvs;
-#if NVVERSION>2
- nvs = this->nv(
- this->iy_,
- this->goal(),
- CO,
- MIN(
- GAMMA_RRTSTAR(
- this->nodes().size()),
- 0.2),
- '0'); // TODO const
-#elif NVVERSION>1
- nvs = this->nv(
- this->iy_,
- this->goal(),
- CO,
- 0.2);
-#else
- nvs = this->nv(
- this->root(),
- this->goal(),
- CO,
- 0.2);
-#endif
+ nvs = this->nv(this->goal(), 0.2);
for (auto nv: nvs) {
if (std::abs(this->goal()->h() - nv->h()) >=
this->GOAL_FOUND_ANGLE)
Klemm2015::Klemm2015(RRTNode *init, RRTNode *goal):
Karaman2011(init, goal),
- nv(NV),
steer(ST),
orig_root_(init),
orig_goal_(goal)
std::vector<RRTNode *> steered = this->steer(nn, rs);
RRTNode *ns = steered[1];
ns->tree(tree);
-#if NVVERSION>2
- nvs = this->nv(
- this->iy_,
- ns,
- CO,
- MIN(
- GAMMA_RRTSTAR(
- this->nodes().size()),
- 0.2),
- '0'); // TODO const
-#elif NVVERSION>1
- nvs = this->nv(
- this->iy_,
- ns,
- CO,
- MIN(
- GAMMA_RRTSTAR(
- this->nodes().size()),
- 0.2)); // TODO const
-#else
nvs = this->nv(
- this->root(),
- ns,
- CO,
- MIN(
- GAMMA_RRTSTAR(
- this->nodes().size()),
- 0.2)); // TODO const
-#endif
+ ns,
+ MIN(
+ GAMMA_RRTSTAR(
+ this->nodes().size()),
+ 0.2)); // TODO const
this->nodes().push_back(ns);
this->add_iy(ns);
// connect
if (!en_add) {
delete ns;
} else {
-#if NVVERSION>2
- nvs = this->nv(
- this->iy_,
- ns,
- CO,
- MIN(
- GAMMA_RRTSTAR(
- this->nodes().size()),
- 0.2),
- '0'); // TODO const
-#elif NVVERSION>1
- nvs = this->nv(
- this->iy_,
- ns,
- CO,
- MIN(
- GAMMA_RRTSTAR(
- this->nodes().size()),
- 0.2)); // TODO const
-#else
nvs = this->nv(
- this->root(),
ns,
- CO,
MIN(
GAMMA_RRTSTAR(
this->nodes().size()),
0.2)); // TODO const
-#endif
this->nodes().push_back(ns);
this->add_iy(ns);
// connect
#define TMAX 10
#endif
-#ifndef NV
-#define NV nv1
-#endif
-
#ifndef ST
#define ST st1
#endif
RRTNode *sample();
float cost(RRTNode *init, RRTNode *goal);
RRTNode *nn(RRTNode *rs);
+ std::vector<RRTNode *> nv(RRTNode *node, float dist);
// virtuals - implemented by child classes
virtual bool next() = 0;
Karaman2011(RRTNode *init, RRTNode *goal);
// RRT framework
- std::vector<RRTNode *> (*nv)(
-#if NVVERSION>1
- std::vector<RRTNode *> (&nodes)[IYSIZE],
-#else
- RRTNode *root,
-#endif
- RRTNode *node,
- float (*cost)(RRTNode *, RRTNode *),
- float dist
-#if NVVERSION>2
- , char tree
-#endif
- );
std::vector<RRTNode *> (*steer)(
RRTNode *init,
RRTNode *goal);
T1(RRTNode *init, RRTNode *goal);
// RRT framework
- std::vector<RRTNode *> (*nv)(
-#if NVVERSION>1
- std::vector<RRTNode *> (&nodes)[IYSIZE],
-#else
- RRTNode *root,
-#endif
- RRTNode *node,
- float (*cost)(RRTNode *, RRTNode *),
- float dist
-#if NVVERSION>2
- , char tree
-#endif
- );
std::vector<RRTNode *> (*steer)(
RRTNode *init,
RRTNode *goal);
Klemm2015(RRTNode *init, RRTNode *goal);
// RRT framework
- std::vector<RRTNode *> (*nv)(
-#if NVVERSION>1
- std::vector<RRTNode *> (&nodes)[IYSIZE],
-#else
- RRTNode *root,
-#endif
- RRTNode *node,
- float (*cost)(RRTNode *, RRTNode *),
- float dist
-#if NVVERSION>2
- , char tree
-#endif
- );
std::vector<RRTNode *> (*steer)(
RRTNode *init,
RRTNode *goal);