PointCloud.cpp
Go to the documentation of this file.
1 /*+-------------------------------------------------------------------------+
2  | MultiVehicle simulator (libmvsim) |
3  | |
4  | Copyright (C) 2014-2023 Jose Luis Blanco Claraco |
5  | Copyright (C) 2017 Borys Tymchenko (Odessa Polytechnic University) |
6  | Distributed under 3-clause BSD License |
7  | See COPYING |
8  +-------------------------------------------------------------------------+ */
9 
10 #include <mrpt/maps/CSimplePointsMap.h>
11 #include <mrpt/opengl/COpenGLScene.h>
12 #include <mvsim/World.h>
14 
15 #include <rapidxml.hpp>
16 
17 #include "xml_utils.h"
18 
19 using namespace rapidxml;
20 using namespace mvsim;
21 using namespace std;
22 
23 PointCloud::PointCloud(World* parent, const rapidxml::xml_node<char>* root)
24  : WorldElementBase(parent)
25 {
26  doLoadConfigFrom(root);
27 }
28 
30 
32 {
33  gui_uptodate_ = false;
34 
35  if (auto x2d = root->first_node("file_txt_2d"); x2d && x2d->value())
36  {
37  const string sFile = world_->local_to_abs_path(x2d->value());
38 
39  points_ = mrpt::maps::CSimplePointsMap::Create();
40  points_->load2D_from_text_file(sFile);
41  }
42  else if (auto x3d = root->first_node("file_txt_3d"); x3d && x3d->value())
43  {
44  const string sFile = world_->local_to_abs_path(x3d->value());
45 
46  points_ = mrpt::maps::CSimplePointsMap::Create();
47  points_->load3D_from_text_file(sFile);
48  }
49  else
50  {
51  THROW_EXCEPTION("Error: No valid <file_*></file_*> XML tag was found");
52  }
53 
54  {
55  // Other general params:
57  ps["points_size"] = TParamEntry("%lf", &render_points_size_);
58  ps["pose_3d"] = TParamEntry("%pose3d", &pointcloud_pose_);
60  *root, ps, world_->user_defined_variables());
61  }
62 
63  points_->renderOptions.point_size = render_points_size_;
64 
65  gui_uptodate_ = false;
66 }
67 
69  const mrpt::optional_ref<mrpt::opengl::COpenGLScene>& viz,
70  const mrpt::optional_ref<mrpt::opengl::COpenGLScene>& physical,
71  [[maybe_unused]] bool childrenOnly)
72 {
73  using namespace mrpt::math;
74 
75  // 1st time call?? -> Create objects
76  if (!gl_points_ && viz && physical)
77  {
78  gl_points_ = mrpt::opengl::CSetOfObjects::Create();
79  gl_points_->setName("PointCloud");
80  gl_points_->setPose(pointcloud_pose_);
81  viz->get().insert(gl_points_);
82  physical->get().insert(gl_points_);
83  }
84 
85  // 1st call OR gridmap changed?
86  if (!gui_uptodate_ && points_)
87  {
88  points_->getVisualizationInto(*gl_points_);
89  gui_uptodate_ = true;
90  }
91 }
92 
94  [[maybe_unused]] const TSimulContext& context)
95 {
96 }
This file contains rapidxml parser and DOM implementation.
virtual void simul_pre_timestep(const TSimulContext &context) override
Definition: PointCloud.cpp:93
mrpt::poses::CPose3D pointcloud_pose_
Definition: PointCloud.h:54
std::map< std::string, TParamEntry > TParameterDefinitions
void parse_xmlnode_children_as_param(const rapidxml::xml_node< char > &xml_node, const TParameterDefinitions &params, const std::map< std::string, std::string > &variableNamesValues={}, const char *functionNameContext="", mrpt::system::COutputLogger *logger=nullptr)
Definition: xml_utils.cpp:224
virtual void internalGuiUpdate(const mrpt::optional_ref< mrpt::opengl::COpenGLScene > &viz, const mrpt::optional_ref< mrpt::opengl::COpenGLScene > &physical, bool childrenOnly) override
Definition: PointCloud.cpp:68
mrpt::maps::CPointsMap::Ptr points_
Definition: PointCloud.h:46
xml_node< Ch > * first_node(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
Definition: rapidxml.hpp:936
mrpt::opengl::CSetOfObjects::Ptr gl_points_
Definition: PointCloud.h:51
const std::map< std::string, std::string > & user_defined_variables() const
Definition: World.h:391
void doLoadConfigFrom(const rapidxml::xml_node< char > *root)
Definition: PointCloud.cpp:31
Ch * value() const
Definition: rapidxml.hpp:692
std::string local_to_abs_path(const std::string &in_path) const
Definition: World.cpp:252
virtual ~PointCloud()
Definition: PointCloud.cpp:29
double render_points_size_
Definition: PointCloud.h:53


mvsim
Author(s):
autogenerated on Tue Jul 4 2023 03:08:21