24 template <
typename node_pose_t,
typename world_limits_t,
typename tree_t>
35 mrpt::make_aligned_shared<mrpt::opengl::CSetOfLines>();
42 double max_veh_radius = 0.;
43 if (!
params.robot_shape.empty())
45 gl_veh_shape->appendLine(
48 for (
size_t i = 2; i <=
params.robot_shape.size(); i++)
50 const size_t idx = i %
params.robot_shape.size();
52 max_veh_radius,
params.robot_shape[idx].norm());
53 gl_veh_shape->appendLineStrip(
54 params.robot_shape[idx].x,
params.robot_shape[idx].y, 0);
57 else if (
params.robot_shape_circular_radius > 0)
59 const int NUM_VERTICES = 10;
60 const double R =
params.robot_shape_circular_radius;
61 for (
int i = 0; i <= NUM_VERTICES; i++)
63 const size_t idx = i % NUM_VERTICES;
64 const size_t idxn = (i + 1) % NUM_VERTICES;
65 const double ang = idx * 2 *
M_PI / (NUM_VERTICES - 1);
66 const double angn = idxn * 2 *
M_PI / (NUM_VERTICES - 1);
67 gl_veh_shape->appendLine(
68 R * cos(ang),
R * sin(ang), 0,
R * cos(angn),
R * sin(angn),
74 xyzcorners_scale = max_veh_radius * 0.5;
84 mrpt::make_aligned_shared<mrpt::opengl::CGridPlaneXY>(
96 string m_name =
"X_rand";
98 obj->enableShowName();
108 string m_name =
"X_near";
109 obj->setName(m_name);
110 obj->enableShowName();
117 typename tree_t::path_t best_path;
123 std::set<const typename tree_t::edge_t *> edges_best_path,
124 edges_best_path_decim;
125 if (!best_path.empty())
129 std::advance(it_end_1, -1);
133 if (it->edge_to_parent) edges_best_path.insert(it->edge_to_parent);
140 if (it->edge_to_parent)
141 edges_best_path_decim.insert(it->edge_to_parent);
142 if (it == it_end_1)
break;
145 if (it == it_end || it == it_end_1)
break;
158 vehShape->setPose(shapePose);
164 const typename tree_t::node_map_t& lstNodes =
169 itNode != lstNodes.end(); ++itNode)
171 const typename tree_t::node_t& node = itNode->second;
176 parent_state = lstNodes.find(node.parent_id)->second.state;
180 const bool is_new_one = (itNode == (lstNodes.end() - 1));
181 const bool is_best_path =
182 edges_best_path.count(node.edge_to_parent) != 0;
183 const bool is_best_path_and_draw_shape =
184 edges_best_path_decim.count(node.edge_to_parent) != 0;
188 const float corner_scale =
189 xyzcorners_scale * (is_new_one ? 1.5f : 1.0f);
197 if (is_best_path_and_draw_shape)
204 vehShape->setPose(shapePose);
215 m_PTGs[node.edge_to_parent->ptg_index].get();
219 mrpt::make_aligned_shared<mrpt::opengl::CSetOfLines>();
228 node.edge_to_parent->ptg_K, *
obj, 0.25f ,
229 node.edge_to_parent->ptg_dist );
259 string m_name =
"X_new";
260 obj->setName(m_name);
261 obj->enableShowName();
270 mrpt::make_aligned_shared<mrpt::opengl::CPointCloud>();
289 mrpt::make_aligned_shared<mrpt::opengl::CPointCloud>();
304 obj->setName(
"START");
305 obj->enableShowName();
315 string m_name =
"GOAL";
316 obj->setName(m_name);
317 obj->enableShowName();
327 mrpt::make_aligned_shared<mrpt::opengl::CText3D>(
This is the base class for any user-defined PTG.
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)...
mrpt::nav::TListPTGPtr m_PTGs
void renderMoveTree(mrpt::opengl::COpenGLScene &scene, const TPlannerInputTempl< node_pose_t, world_limits_t > &pi, const TPlannerResultTempl< tree_t > &result, const TRenderPlannedPathOptions &options)
std::shared_ptr< CGridPlaneXY > Ptr
This class allows the user to create, load, save, and render 3D scenes using OpenGL primitives.
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).
std::shared_ptr< CPointCloud > Ptr
A set of independent lines (or segments), one line with its own start and end positions (X,...
std::shared_ptr< CSetOfLines > Ptr
std::shared_ptr< CSetOfObjects > Ptr
std::shared_ptr< CText3D > Ptr
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 Scalar * const_iterator
GLsizei GLsizei GLuint * obj
GLenum const GLfloat * params
GLsizei const GLchar ** string
#define ASSERT_ABOVE_(__A, __B)
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...
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.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
Options for renderMoveTree()
mrpt::utils::TColor color_local_obstacles
local obstacles color
mrpt::utils::TNodeID highlight_path_to_node_id
Highlight the path from root towards this node (usually, the target)
double xyzcorners_scale
A scale factor to all XYZ corners (default=0, means auto determien from vehicle shape)
double ground_xy_grid_frequency
(Default=10 meters) Set to 0 to disable
mrpt::utils::TColor color_normal_edge
const mrpt::maps::CPointsMap * local_obs_from_nearest_pose
mrpt::utils::TColor color_ground_xy_grid
int point_size_local_obstacles
double vehicle_shape_z
(Default=0.01) Height (Z coordinate) for the vehicle shapes.
const mrpt::poses::CPose2D * x_rand_pose
double vehicle_line_width
Robot line width for visualization - default 2.0.
mrpt::math::TPoint3D log_msg_position
mrpt::utils::TColor color_optimal_edge
const mrpt::poses::CPose2D * new_state
bool highlight_last_added_edge
(Default=false)
bool draw_obstacles
(Default=true)
mrpt::utils::TColor color_start
START indication color
size_t draw_shape_decimation
(Default=1) Draw one out of N vehicle shapes along the highlighted path
mrpt::utils::TColor color_vehicle
Robot color
const mrpt::poses::CPose2D * x_nearest_pose
mrpt::utils::TColor color_obstacles
obstacles color
mrpt::utils::TColor color_last_edge
mrpt::utils::TColor color_goal
END indication color
tree_t move_tree
The generated motion tree that explores free space starting at "start".