22 template <
typename node_pose_t,
typename world_limits_t,
typename tree_t>
40 double max_veh_radius = 0.;
43 gl_veh_shape->appendLine(
50 gl_veh_shape->appendLineStrip(
56 const int NUM_VERTICES = 10;
58 for (
int i = 0; i <= NUM_VERTICES; i++)
60 const size_t idx = i % NUM_VERTICES;
61 const size_t idxn = (i + 1) % NUM_VERTICES;
62 const double ang = idx * 2 *
M_PI / (NUM_VERTICES - 1);
63 const double angn = idxn * 2 *
M_PI / (NUM_VERTICES - 1);
64 gl_veh_shape->appendLine(
65 R * cos(ang),
R * sin(ang), 0,
R * cos(angn),
R * sin(angn),
71 xyzcorners_scale = max_veh_radius * 0.5;
93 string m_name =
"X_rand";
95 obj->enableShowName();
105 string m_name =
"X_near";
106 obj->setName(m_name);
107 obj->enableShowName();
114 typename tree_t::path_t best_path;
120 std::set<const typename tree_t::edge_t*> edges_best_path,
121 edges_best_path_decim;
122 if (!best_path.empty())
124 auto it_end = best_path.end();
125 auto it_end_1 = best_path.end();
126 std::advance(it_end_1, -1);
128 for (
auto it = best_path.begin(); it != it_end; ++it)
129 if (it->edge_to_parent) edges_best_path.insert(it->edge_to_parent);
133 for (
auto it = best_path.begin(); it != it_end;)
135 if (it->edge_to_parent)
136 edges_best_path_decim.insert(it->edge_to_parent);
137 if (it == it_end_1)
break;
140 if (it == it_end || it == it_end_1)
break;
153 vehShape->setPose(shapePose);
159 const typename tree_t::node_map_t& lstNodes =
162 for (
auto itNode = lstNodes.begin(); itNode != lstNodes.end(); ++itNode)
164 const typename tree_t::node_t& node = itNode->second;
169 parent_state = lstNodes.find(node.parent_id)->second.state;
173 const bool is_new_one = (itNode == (lstNodes.end() - 1));
174 const bool is_best_path =
175 edges_best_path.count(node.edge_to_parent) != 0;
176 const bool is_best_path_and_draw_shape =
177 edges_best_path_decim.count(node.edge_to_parent) != 0;
181 const float corner_scale =
182 xyzcorners_scale * (is_new_one ? 1.5f : 1.0f);
190 if (is_best_path_and_draw_shape)
196 vehShape->setPose(shapePose);
207 m_PTGs[node.edge_to_parent->ptg_index].get();
220 node.edge_to_parent->ptg_K, *obj, 0.25f ,
221 node.edge_to_parent->ptg_dist );
251 string m_name =
"X_new";
252 obj->setName(m_name);
253 obj->enableShowName();
294 obj->setName(
"START");
295 obj->enableShowName();
305 string m_name =
"GOAL";
306 obj->setName(m_name);
307 obj->enableShowName();
mrpt::img::TColor color_normal_edge
mrpt::img::TColor color_last_edge
double vehicle_shape_z
(Default=0.01) Height (Z coordinate) for the vehicle shapes.
virtual void renderPathAsSimpleLine(const uint16_t k, mrpt::opengl::CSetOfLines &gl_obj, const double decimate_distance=0.1, const double max_path_distance=-1.0) const
Returns the representation of one trajectory of this PTG as a 3D OpenGL object (a simple curved line)...
const mrpt::maps::CPointsMap * local_obs_from_nearest_pose
const mrpt::poses::CPose2D * x_rand_pose
mrpt::math::TPoint3D log_msg_position
double xyzcorners_scale
A scale factor to all XYZ corners (default=0, means auto determien from vehicle shape) ...
bool highlight_last_added_edge
(Default=false)
static Ptr Create(Args &&... args)
mrpt::img::TColor color_start
START indication color.
double robot_shape_circular_radius
The radius of a circular-shape-model of the robot shape.
#define ASSERT_(f)
Defines an assertion mechanism.
mrpt::img::TColor color_obstacles
obstacles color
This is the base class for any user-defined PTG.
mrpt::nav::TListPTGPtr m_PTGs
mrpt::img::TColor color_goal
END indication color.
Options for renderMoveTree()
double vehicle_line_width
Robot line width for visualization - default 2.0.
static Ptr Create(Args &&... args)
mrpt::img::TColor color_ground_xy_grid
double ground_xy_grid_frequency
(Default=10 meters) Set to 0 to disable
void keep_max(T &var, const K test_val)
If the second argument is above the first one, set the first argument to this higher value...
const mrpt::poses::CPose2D * x_nearest_pose
bool draw_obstacles
(Default=true)
RRTAlgorithmParams params
Parameters specific to this path solver algorithm.
int point_size_local_obstacles
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
const mrpt::poses::CPose2D * new_state
CSetOfObjects::Ptr CornerXYZ(float scale=1.0)
Returns three arrows representing a X,Y,Z 3D corner.
CSetOfObjects::Ptr CornerXYZSimple(float scale=1.0, float lineWidth=1.0)
Returns three arrows representing a X,Y,Z 3D corner (just thick lines instead of complex arrows for f...
#define ASSERT_ABOVE_(__A, __B)
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
This class allows the user to create, load, save, and render 3D scenes using OpenGL primitives...
mrpt::img::TColor color_vehicle
Robot color.
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's loaded from the config file/text as a single 2xN...
mrpt::graphs::TNodeID highlight_path_to_node_id
Highlight the path from root towards this node (usually, the target)
void renderMoveTree(mrpt::opengl::COpenGLScene &scene, const TPlannerInputTempl< node_pose_t, world_limits_t > &pi, const TPlannerResultTempl< tree_t > &result, const TRenderPlannedPathOptions &options)
A set of independent lines (or segments), one line with its own start and end positions (X...
void insert(const CRenderizable::Ptr &newObject, const std::string &viewportName=std::string("main"))
Insert a new object into the scene, in the given viewport (by default, into the "main" viewport)...
static Ptr Create(Args &&... args)
static Ptr Create(Args &&... args)
mrpt::img::TColor color_local_obstacles
local obstacles color
mrpt::img::TColor color_optimal_edge
tree_t move_tree
The generated motion tree that explores free space starting at "start".