1 /*! \brief RRT* structure and default procedures.
10 #include <json/json.h>
18 /*! Compute elapsed time class. */
21 std::chrono::high_resolution_clock::time_point tstart_;
27 /*! Store RRT node. */
28 class RRTNode : public virtual Pose, public virtual CarMove {
32 RRTNode* p_ = nullptr;
34 /*! Get cost to parent. */
37 /*! Set cost to parent. */
40 /*! Get cumulative cost from root. */
43 /*! Get parent node. */
46 /*! Set parent node. */
49 bool operator==(RRTNode const& n);
52 class RRTGoal : public virtual RRTNode, public virtual PoseRange {
54 using PoseRange::PoseRange;
57 /*! RRT* algorithm basic class. */
62 unsigned int icnt_ = 0;
64 std::default_random_engine gen_;
65 std::vector<RRTNode> nodes_;
66 std::vector<RRTNode> steered_;
67 std::vector<RRTNode*> path_;
68 RRTNode* nn_ = nullptr;
69 std::vector<RRTNode*> nv_;
73 double last_goal_cc_ = 0.0;
74 std::vector<RRTNode> last_path_;
75 void recompute_path_cc();
76 double min_gamma_eta() const;
77 bool should_continue() const;
78 void join_steered(RRTNode* f);
82 bool goal_drivable_from(RRTNode const& f);
83 virtual void store(RRTNode n);
84 virtual double cost_build(RRTNode const& f, RRTNode const& t) const;
85 virtual double cost_search(RRTNode const& f, RRTNode const& t) const;
86 virtual void find_nn(RRTNode const& t);
87 virtual void find_nv(RRTNode const& t);
88 virtual void compute_path();
89 virtual void steer(RRTNode const& f, RRTNode const& t) = 0;
90 virtual bool collide_steered() = 0;
91 virtual RRTNode sample() = 0;
92 virtual bool should_finish() const = 0;
96 /*! Get iterations counter. */
97 unsigned int icnt() const;
99 /*! Set iterations counter. */
100 void icnt(unsigned int i);
102 /*! Return elapsed time. */
105 /*! Generate JSON output. */
106 Json::Value json() const;
108 /*! Load JSON input. */
109 void json(Json::Value jvi);
111 /*! Run next RRT* iteration. */
114 /*! Reset the algorithm. */
115 virtual void reset();
119 #endif /* RRTS_RRTS_H */