Main MRPT website > C++ reference for MRPT 1.9.9
PlannerRRT_common.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #pragma once
11 
15 #include <mrpt/utils/CTimeLogger.h>
17 #include <string>
18 #include <cstdlib> // size_t
19 
20 namespace mrpt
21 {
22 namespace nav
23 {
24 /** \addtogroup nav_planners Path planning
25 * \ingroup mrpt_nav_grp
26 * @{ */
27 
28 template <typename node_pose_t, typename world_limits_t>
30 {
31  node_pose_t start_pose, goal_pose;
32  /** Bounding box of the world, used to draw uniform random pose samples */
33  world_limits_t world_bbox_min, world_bbox_max;
34  /** World obstacles, as a point cloud */
36 };
37 
38 template <typename tree_t>
40 {
41  /** Whether the target was reached or not */
42  bool success;
43  /** Time spent (in secs) */
45  /** Distance from best found path to goal */
46  double goal_distance;
47  /** Total cost of the best found path (cost ~~ Euclidean distance) */
48  double path_cost;
49  /** The ID of the best target node in the tree */
51  /** The set of target nodes within an acceptable distance to target
52  * (including `best_goal_node_id` and others) */
53  std::set<mrpt::utils::TNodeID> acceptable_goal_node_ids;
54  /** The generated motion tree that explores free space starting at "start"
55  */
56  tree_t move_tree;
57 
59  : success(false),
61  goal_distance(std::numeric_limits<double>::max()),
62  path_cost(std::numeric_limits<double>::max()),
64  {
65  }
66 };
67 
69 {
70  /** Maximum distance from a pose to target to accept it as a valid solution
71  * (meters). (Both acceptedDistToTarget & acceptedAngToTarget must be
72  * satisfied) */
74  /** Maximum angle from a pose to target to accept it as a valid solution
75  * (rad). (Both acceptedDistToTarget & acceptedAngToTarget must be
76  * satisfied) */
78 
79  /** In seconds. 0 means no limit until a solution is found. */
81  /** In seconds. 0 means the first valid path will be returned. Otherwise,
82  * the algorithm will try to refine and find a better one. */
84 
86  : acceptedDistToTarget(0.1),
87  acceptedAngToTarget(mrpt::utils::DEG2RAD(180)),
88  maxComputationTime(0.0),
90  {
91  }
92 };
93 
95 {
96  /** The robot shape used when computing collisions; it's loaded from the
97  * config file/text as a single 2xN matrix in MATLAB format, first row are
98  * Xs, second are Ys, e.g:
99  * \code
100  * robot_shape = [-0.2 0.2 0.2 -0.2; -0.1 -0.1 0.1 0.1]
101  * \endcode
102  * \note PTGs will use only one of either `robot_shape` or
103  * `robot_shape_circular_radius`
104  */
106  /** The radius of a circular-shape-model of the robot shape.
107  * \note PTGs will use only one of either `robot_shape` or
108  * `robot_shape_circular_radius`
109  */
111 
112  /** (Default: ".") */
114 
115  /** Probabily of picking the goal as random target (in [0,1], default=0.05)
116  */
117  double goalBias;
118  /** (Very sensitive parameter!) Max length of each edge path (in meters,
119  * default=1.0) */
120  double maxLength;
121  /** Minimum distance [meters] to nearest node to accept creating a new one
122  * (default=0.10). (Any of minDistanceBetweenNewNodes and
123  * minAngBetweenNewNodes must be satisfied) */
125  /** Minimum angle [rad] to nearest node to accept creating a new one
126  * (default=15 deg) (Any of minDistanceBetweenNewNodes and
127  * minAngBetweenNewNodes must be satisfied) */
129  /** Display PTG construction info (default=true) */
131 
132  /** Frequency (in iters) of saving tree state to debug log files viewable in
133  * SceneViewer3D (default=0, disabled) */
135 
137 };
138 
139 /** Virtual base class for TP-Space-based path planners */
141 {
142  public:
144  /** Parameters specific to this path solver algorithm */
146 
147  /** ctor */
149 
151  const mrpt::nav::TListPTGPtr& getPTGs() const { return m_PTGs; }
152  /** Options for renderMoveTree() */
154  {
155  /** Highlight the path from root towards this node (usually, the target)
156  */
158  /** (Default=1) Draw one out of N vehicle shapes along the highlighted
159  * path */
161 
166 
167  /** A scale factor to all XYZ corners (default=0, means auto determien
168  * from vehicle shape) */
170  /** (Default=false) */
172  /** (Default=10 meters) Set to 0 to disable */
174 
175  /** Robot color */
177  /** obstacles color */
179  /** local obstacles color */
181  /** START indication color */
183  /** END indication color */
194 
195  /** (Default=0.01) Height (Z coordinate) for the vehicle shapes. Helps
196  * making it in the "first plane" */
198  /** Robot line width for visualization - default 2.0 */
200  /** (Default=true) */
202 
206 
210  x_rand_pose(NULL),
211  x_nearest_pose(NULL),
213  new_state(NULL),
214  xyzcorners_scale(0),
217  color_vehicle(0xFF, 0x00, 0x00, 0xFF),
218  color_obstacles(0x00, 0x00, 0xFF, 0x40),
219  color_local_obstacles(0x00, 0x00, 0xFF),
220  color_start(0x00, 0x00, 0x00, 0x00),
221  color_goal(0x00, 0x00, 0x00, 0x00),
222  color_ground_xy_grid(0xFF, 0xFF, 0xFF),
223  color_normal_edge(0x22, 0x22, 0x22, 0x40),
224  color_last_edge(0xff, 0xff, 0x00),
225  color_optimal_edge(0x00, 0x00, 0x00),
226  width_last_edge(3.f),
227  width_normal_edge(1.f),
228  width_optimal_edge(4.f),
231  vehicle_shape_z(0.01),
232  vehicle_line_width(2.0),
233  draw_obstacles(true),
234  log_msg_position(0, 0, 0),
235  log_msg_scale(0.2)
236  {
237  }
238 
240  };
241 
242  template <typename node_pose_t, typename world_limits_t, typename tree_t>
243  void renderMoveTree(
246  const TPlannerResultTempl<tree_t>& result,
247  const TRenderPlannedPathOptions& options);
248 
249  protected:
253  mrpt::maps::CSimplePointsMap m_local_obs; // Temporary map. Defined as a
254  // member to save realloc time
255  // between calls
256 
257  /** Load all PTG params from a config file source */
259  const mrpt::utils::CConfigFileBase& cfgSource,
260  const std::string& sSectionName = std::string("PTG_CONFIG"));
261 
262  /** Must be called after setting all params (see
263  * `internal_loadConfig_PTG()`) and before calling `solve()` */
265 
267  const mrpt::maps::CPointsMap& in_map, mrpt::maps::CPointsMap& out_map,
268  const mrpt::poses::CPose2D& asSeenFrom, const double MAX_DIST_XY);
269 
270  void spaceTransformer(
271  const mrpt::maps::CSimplePointsMap& in_obstacles,
273  const double MAX_DIST, std::vector<double>& out_TPObstacles);
274 
276  const int tp_space_k_direction,
277  const mrpt::maps::CSimplePointsMap& in_obstacles,
279  const double MAX_DIST, double& out_TPObstacle_k);
280 
281 }; // end class PlannerTPS_VirtualBase
282 /** @} */
283 }
284 }
285 
286 // Impl of renderMoveTree<>
287 #include "impl_renderMoveTree.h"
mrpt::utils::TColor color_goal
END indication color.
double minComputationTime
In seconds.
double vehicle_shape_z
(Default=0.01) Height (Z coordinate) for the vehicle shapes.
double minDistanceBetweenNewNodes
Minimum distance [meters] to nearest node to accept creating a new one (default=0.10).
std::set< mrpt::utils::TNodeID > acceptable_goal_node_ids
The set of target nodes within an acceptable distance to target (including best_goal_node_id and othe...
void internal_loadConfig_PTG(const mrpt::utils::CConfigFileBase &cfgSource, const std::string &sSectionName=std::string("PTG_CONFIG"))
Load all PTG params from a config file source.
double maxLength
(Very sensitive parameter!) Max length of each edge path (in meters, default=1.0) ...
double minAngBetweenNewNodes
Minimum angle [rad] to nearest node to accept creating a new one (default=15 deg) (Any of minDistance...
void spaceTransformerOneDirectionOnly(const int tp_space_k_direction, const mrpt::maps::CSimplePointsMap &in_obstacles, const mrpt::nav::CParameterizedTrajectoryGenerator *in_PTG, const double MAX_DIST, double &out_TPObstacle_k)
void spaceTransformer(const mrpt::maps::CSimplePointsMap &in_obstacles, const mrpt::nav::CParameterizedTrajectoryGenerator *in_PTG, const double MAX_DIST, std::vector< double > &out_TPObstacles)
world_limits_t world_bbox_min
Bounding box of the world, used to draw uniform random pose samples.
#define INVALID_NODEID
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans. ...
STL namespace.
mrpt::utils::CTimeLogger & getProfiler()
mrpt::utils::TNodeID highlight_path_to_node_id
Highlight the path from root towards this node (usually, the target)
size_t save_3d_log_freq
Frequency (in iters) of saving tree state to debug log files viewable in SceneViewer3D (default=0...
double xyzcorners_scale
A scale factor to all XYZ corners (default=0, means auto determien from vehicle shape) ...
double acceptedAngToTarget
Maximum angle from a pose to target to accept it as a valid solution (rad).
This class allows loading and storing values and vectors of different types from a configuration text...
#define MAX_DIST(s)
Definition: deflate.h:285
double robot_shape_circular_radius
The radius of a circular-shape-model of the robot shape.
std::vector< mrpt::nav::CParameterizedTrajectoryGenerator::Ptr > TListPTGPtr
A list of PTGs (smart pointers)
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans or other sensors...
Definition: CPointsMap.h:63
This is the base class for any user-defined PTG.
uint64_t TNodeID
The type for node IDs in graphs of different types.
bool success
Whether the target was reached or not.
Virtual base class for TP-Space-based path planners.
A RGB color - 8bit.
Definition: TColor.h:25
double vehicle_line_width
Robot line width for visualization - default 2.0.
const mrpt::nav::TListPTGPtr & getPTGs() const
double acceptedDistToTarget
Maximum distance from a pose to target to accept it as a valid solution (meters). ...
#define DEG2RAD
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::utils::TNodeID best_goal_node_id
The ID of the best target node in the tree.
double ground_xy_grid_frequency
(Default=10 meters) Set to 0 to disable
double path_cost
Total cost of the best found path (cost ~~ Euclidean distance)
void internal_initialize_PTG()
Must be called after setting all params (see internal_loadConfig_PTG()) and before calling solve() ...
double maxComputationTime
In seconds.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
mrpt::maps::CSimplePointsMap obstacles_points
World obstacles, as a point cloud.
RRTAlgorithmParams params
Parameters specific to this path solver algorithm.
double goal_distance
Distance from best found path to goal.
double computation_time
Time spent (in secs)
static void transformPointcloudWithSquareClipping(const mrpt::maps::CPointsMap &in_map, mrpt::maps::CPointsMap &out_map, const mrpt::poses::CPose2D &asSeenFrom, const double MAX_DIST_XY)
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
Definition: CPose2D.h:40
mrpt::maps::CSimplePointsMap m_local_obs
bool ptg_verbose
Display PTG construction info (default=true)
This class allows the user to create, load, save, and render 3D scenes using OpenGL primitives...
Definition: COpenGLScene.h:60
A versatile "profiler" that logs the time spent within each pair of calls to enter(X)-leave(X), among other stats.
Definition: CTimeLogger.h:45
size_t draw_shape_decimation
(Default=1) Draw one out of N vehicle shapes along the highlighted path
mrpt::math::TPolygon2D robot_shape
The robot shape used when computing collisions; it&#39;s loaded from the config file/text as a single 2xN...
double goalBias
Probabily of picking the goal as random target (in [0,1], default=0.05)
mrpt::utils::TColor color_start
START indication color.
void renderMoveTree(mrpt::opengl::COpenGLScene &scene, const TPlannerInputTempl< node_pose_t, world_limits_t > &pi, const TPlannerResultTempl< tree_t > &result, const TRenderPlannedPathOptions &options)
Lightweight 3D point.
std::string ptg_cache_files_directory
(Default: ".")
2D polygon, inheriting from std::vector<TPoint2D>.
mrpt::utils::TColor color_local_obstacles
local obstacles color
mrpt::utils::CTimeLogger m_timelogger
tree_t move_tree
The generated motion tree that explores free space starting at "start".



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019