From: Jiri Vlasak Date: Wed, 9 Oct 2019 11:31:12 +0000 (+0200) Subject: Add ext3 skeleton X-Git-Tag: v0.3.0~8^2~9 X-Git-Url: https://rtime.felk.cvut.cz/gitweb/hubacji1/rrts.git/commitdiff_plain/8e5536a67ca3d042782901d52baac5c4cb9626dc Add ext3 skeleton --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 74c03ee..d9ca708 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/api) add_library(rrts SHARED src/rrts.cc + src/rrtext3.cc src/rrtext2.cc src/rrtext1.cc src/reeds_shepp.cpp diff --git a/README.md b/README.md index 96cd471..ca07590 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ and upgrades to RRT, *extensions* are declared in `rrtext.h` and implemented in ## Implemented extensions There is a list of implemented extensions and what they include: +- `rrtext3.cc`: Dijkstra algorithm for path optimization, - `rrtext2.cc`: [cute c2][] for collision detection, - `rrtext1.cc`: different cost for building and searching. diff --git a/api/rrtext.h b/api/rrtext.h index 170f8e8..7f5a092 100644 --- a/api/rrtext.h +++ b/api/rrtext.h @@ -6,6 +6,19 @@ // ext2 #include "cute_c2.h" +/*! \brief Use Dijkstra algorithm to find the shorter path. +*/ +class RRTExt3 : public virtual RRTS { + private: + std::vector orig_path_; + public: + std::vector &orig_path() + { + return this->orig_path_; + }; + std::vector path(); +}; + /*! \brief Use cute_c2 for collision detection. \see https://github.com/RandyGaul/cute_headers/blob/master/cute_c2.h diff --git a/api/rrts.h b/api/rrts.h index f2f02f6..3ff74a5 100644 --- a/api/rrts.h +++ b/api/rrts.h @@ -127,7 +127,7 @@ class RRTS { virtual void deinit(); /*! \brief Return path found by RRT*. */ - std::vector path(); + virtual std::vector path(); /*! \brief Run next RRT* iteration. */ bool next(); diff --git a/src/rrtext3.cc b/src/rrtext3.cc new file mode 100644 index 0000000..e9a9a53 --- /dev/null +++ b/src/rrtext3.cc @@ -0,0 +1,10 @@ +#include "rrtext.h" + +std::vector RRTExt3::path() +{ + if (this->orig_path().size() == 0) { + this->orig_path_ = RRTS::path(); + } + std::vector path; + return path; +}