15 /*! Compute elapsed time class. */
18 std::chrono::high_resolution_clock::time_point tstart_;
24 /*! Store RRT node. */
25 class RRTNode : public virtual Pose, public virtual CarMove {
29 RRTNode* p_ = nullptr;
31 /*! Get cost to parent. */
34 /*! Set cost to parent. */
37 /*! Get cumulative cost from root. */
40 /*! Get parent node. */
43 /*! Set parent node. */
46 bool operator==(RRTNode const& n);
49 class RRTGoal : public virtual RRTNode, public virtual PoseRange {
52 /*! RRT* algorithm basic class. */
57 unsigned int icnt_ = 0;
59 std::default_random_engine gen_;
60 std::vector<RRTNode> nodes_;
61 std::vector<RRTNode> steered_;
62 std::vector<RRTNode*> path_;
63 RRTNode* nn_ = nullptr;
64 std::vector<RRTNode*> nv_;
68 double min_gamma_eta() const;
69 bool should_continue() const;
70 void join_steered(RRTNode* f);
74 bool goal_drivable_from(RRTNode const& f);
75 virtual void store(RRTNode n);
76 virtual double cost_build(RRTNode const& f, RRTNode const& t) const;
77 virtual double cost_search(RRTNode const& f, RRTNode const& t) const;
78 virtual void find_nn(RRTNode const& t);
79 virtual void find_nv(RRTNode const& t);
80 virtual void compute_path();
81 virtual void steer(RRTNode const& f, RRTNode const& t) = 0;
82 virtual bool collide_steered() = 0;
83 virtual RRTNode sample() = 0;
84 virtual bool should_finish() const = 0;
88 /*! Get iterations counter. */
89 unsigned int icnt() const;
91 /*! Set iterations counter. */
92 void icnt(unsigned int i);
94 /*! Return elapsed time. */
97 /*! Generate JSON output. */
98 Json::Value json() const;
100 /*! Load JSON input. */
101 void json(Json::Value jvi);
103 /*! Run next RRT* iteration. */
106 /*! Reset the algorithm. */
107 virtual void reset();
111 #endif /* RRTS_RRTS_H */