Quad-SDK
Loading...
Searching...
No Matches
rrt.h
1#ifndef RRT_H
2#define RRT_H
3
4#include <chrono>
5
6#include "global_body_planner/planner_class.h"
7
8#define TRAPPED 0
9#define ADVANCED 1
10#define REACHED 2
11
12using namespace planning_utils;
13
15
19class RRT {
20 public:
25 RRT();
26
30 ~RRT();
31
44 int attemptConnect(const State &s_existing, const State &s, double t_s,
45 StateActionResult &result,
46 const PlannerConfig &planner_config, int direction);
47
57 int attemptConnect(const State &s_existing, const State &s,
58 StateActionResult &result,
59 const PlannerConfig &planner_config, int direction);
60
68 virtual int extend(PlannerClass &T, const State &s,
69 const PlannerConfig &planner_config, int direction,
70 ros::Publisher &tree_pub);
71
79 std::vector<int> pathFromStart(PlannerClass &T, int idx);
80
86 void printPath(PlannerClass &T, std::vector<int> path);
87
97 void getStatistics(double &plan_time, int &vertices_generated,
98 double &plan_length, double &path_duration,
99 double &dist_to_goal);
100
112 bool newConfig(State s, State s_near, StateActionResult &result,
113 const PlannerConfig &planner_config, int direction,
114 ros::Publisher &tree_pub);
115
122 std::vector<State> getStateSequence(PlannerClass &T, std::vector<int> path);
123
131 std::vector<Action> getActionSequence(PlannerClass &T, std::vector<int> path);
132
133 protected:
135 const double prob_goal_thresh = 0.05;
136
138 bool goal_found = false;
139
141 std::chrono::duration<double> elapsed_total_;
142
143 // Total time elapsed until the first solve
144 std::chrono::duration<double> elapsed_to_first_;
145
147 int success_ = 0;
148
151
154
157
160
162 visualization_msgs::MarkerArray tree_viz_msg_;
163};
164
165#endif
Definition planner_class.h:17
A class that implements RRT sampling-based planning.
Definition rrt.h:19
RRT()
Constructor for RRT.
Definition rrt.cpp:5
int attemptConnect(const State &s_existing, const State &s, double t_s, StateActionResult &result, const PlannerConfig &planner_config, int direction)
Definition rrt.cpp:93
double path_length_
Path quality in meters.
Definition rrt.h:153
std::vector< int > pathFromStart(PlannerClass &T, int idx)
Get the path from the root vertex to the specified one.
Definition rrt.cpp:183
double path_duration_
The duration of the path in seconds.
Definition rrt.h:156
double dist_to_goal_
Distance from the final state to the goal (m)
Definition rrt.h:159
visualization_msgs::MarkerArray tree_viz_msg_
Message for tree visualization.
Definition rrt.h:162
const double prob_goal_thresh
Probability with which the goal is sampled (if running vanilla RRT)
Definition rrt.h:135
bool goal_found
Boolean for if the goal has been reached.
Definition rrt.h:138
int success_
Integer checking if a solution was computed in 5 seconds.
Definition rrt.h:147
std::vector< Action > getActionSequence(PlannerClass &T, std::vector< int > path)
Get the actions along the specified path of vertex indices (assumes that actions are synched with the...
Definition rrt.cpp:204
std::chrono::duration< double > elapsed_total_
Total time elapsed in this planner call.
Definition rrt.h:141
std::vector< State > getStateSequence(PlannerClass &T, std::vector< int > path)
Get the states along the specified path of vertex indices.
Definition rrt.cpp:195
bool newConfig(State s, State s_near, StateActionResult &result, const PlannerConfig &planner_config, int direction, ros::Publisher &tree_pub)
Generate a new state that can be connected to the tree and is as close as possible to the specified s...
Definition rrt.cpp:11
void printPath(PlannerClass &T, std::vector< int > path)
Print the states in the specified path via stdout.
Definition rrt.cpp:214
~RRT()
Destructor for RRT.
Definition rrt.cpp:7
void getStatistics(double &plan_time, int &vertices_generated, double &plan_length, double &path_duration, double &dist_to_goal)
Get the statistics for the planner solve.
Definition rrt.cpp:225
int num_vertices_
Number of vertices in the tree.
Definition rrt.h:150
virtual int extend(PlannerClass &T, const State &s, const PlannerConfig &planner_config, int direction, ros::Publisher &tree_pub)
Definition rrt.cpp:164
Planner Configuration.
Definition planning_utils.h:36
Definition planning_utils.h:228
Define state with Eigen data.
Definition planning_utils.h:184