39 void CColouredOctoMap::TMapDefinition::loadFromConfigFile_map_specific(
45 sectionNamePrefix +
string(
"_creationOpts");
48 insertionOpts.loadFromConfigFile(
49 source, sectionNamePrefix +
string(
"_insertOpts"));
50 likelihoodOpts.loadFromConfigFile(
51 source, sectionNamePrefix +
string(
"_likelihoodOpts"));
54 void CColouredOctoMap::TMapDefinition::dumpToTextStream_map_specific(
59 this->insertionOpts.dumpToTextStream(out);
60 this->likelihoodOpts.dumpToTextStream(out);
81 :
COctoMapBase<octomap::ColorOcTree, octomap::ColorOcTreeNode>(resolution),
82 m_colour_method(INTEGRATE)
89 CColouredOctoMap::~CColouredOctoMap() {}
95 void CColouredOctoMap::writeToStream(
103 this->renderingOptions.writeToStream(out);
104 out << genericMapParams;
108 const_cast<octomap::ColorOcTree*
>(&m_octomap)->writeBinary(tmpFil);
129 if (version >= 1) this->renderingOptions.readFromStream(
in);
130 if (version >= 2)
in >> genericMapParams;
142 m_octomap.readBinary(tmpFil);
155 bool CColouredOctoMap::internal_insertObservation(
158 octomap::point3d sensorPt;
159 octomap::Pointcloud scan;
163 robotPose3D = (*robotPose);
180 octomap::point3d(sensorPose.
x(), sensorPose.
y(), sensorPose.z());
184 const size_t nPts = scanPts->
size();
190 for (
size_t i = 0; i < nPts; i++)
200 scan.push_back(gx, gy, gz);
204 m_octomap.insertPointCloud(
205 scan, sensorPt, insertionOptions.maxrange,
206 insertionOptions.pruning);
222 mrpt::make_aligned_shared<mrpt::opengl::CPointCloudColoured>();
233 octomap::point3d(sensorPose.
x(), sensorPose.
y(), sensorPose.z());
235 const size_t sizeRangeScan = pts->size();
236 scan.reserve(sizeRangeScan);
238 for (
size_t i = 0; i < sizeRangeScan; i++)
244 if (pt.
x != 0 || pt.
y != 0 || pt.
z != 0)
245 scan.push_back(pt.
x, pt.
y, pt.
z);
249 octomap::KeySet free_cells, occupied_cells;
250 m_octomap.computeUpdate(
251 scan, sensorPt, free_cells, occupied_cells,
252 insertionOptions.maxrange);
256 it != free_cells.end(); ++it)
258 m_octomap.updateNode(*it,
false,
false);
261 it != occupied_cells.end(); ++it)
263 m_octomap.updateNode(*it,
true,
false);
267 const float colF2B = 255.0f;
268 for (
size_t i = 0; i < sizeRangeScan; i++)
274 if (pt.
x != 0 || pt.
y != 0 || pt.
z != 0)
275 this->updateVoxelColour(
281 if (insertionOptions.pruning) m_octomap.prune();
292 bool CColouredOctoMap::getPointColour(
296 octomap::OcTreeKey key;
297 if (m_octomap.coordToKeyChecked(octomap::point3d(
x,
y,
z), key))
299 octomap::ColorOcTreeNode* node = m_octomap.search(key, 0 );
300 if (!node)
return false;
302 const octomap::ColorOcTreeNode::Color& col = node->getColor();
313 void CColouredOctoMap::updateVoxelColour(
314 const double x,
const double y,
const double z,
const uint8_t r,
317 switch (m_colour_method)
320 m_octomap.integrateNodeColor(
x,
y,
z,
r,
g,
b);
323 m_octomap.setNodeColor(
x,
y,
z,
r,
g,
b);
326 m_octomap.averageNodeColor(
x,
y,
z,
r,
g,
b);
335 void CColouredOctoMap::getAsOctoMapVoxels(
341 octomap::ColorOcTree::tree_iterator it_end = m_octomap.end_tree();
343 const unsigned char max_depth = 0;
345 const TColor general_color_u(
346 general_color.
R * 255, general_color.
G * 255, general_color.
B * 255,
347 general_color.
A * 255);
358 const size_t nLeafs = this->getNumLeafNodes();
362 double xmin, xmax, ymin, ymax, zmin,
zmax;
363 this->getMetricMin(xmin, ymin, zmin);
364 this->getMetricMax(xmax, ymax,
zmax);
366 for (octomap::ColorOcTree::tree_iterator it =
367 m_octomap.begin_tree(max_depth);
370 const octomap::point3d vx_center = it.getCoordinate();
371 const double vx_length = it.getSize();
372 const double L = 0.5 * vx_length;
377 const double occ = it->getOccupancy();
378 if ((occ >= 0.5 && renderingOptions.generateOccupiedVoxels) ||
379 (occ < 0.5 && renderingOptions.generateFreeVoxels))
382 octomap::ColorOcTreeNode::Color node_color = it->getColor();
383 vx_color =
TColor(node_color.r, node_color.g, node_color.b);
385 const size_t vx_set = (m_octomap.isNodeOccupied(*it))
392 TPoint3D(vx_center.x(), vx_center.y(), vx_center.z()),
393 vx_length, vx_color));
396 else if (renderingOptions.generateGridLines)
400 vx_center.x() - L, vx_center.y() - L, vx_center.z() - L);
402 vx_center.x() + L, vx_center.y() + L, vx_center.z() + L);
415 this->getMetricMin(bbmin.
x, bbmin.
y, bbmin.
z);
416 this->getMetricMax(bbmax.
x, bbmax.
y, bbmax.
z);
#define MRPT_LOAD_CONFIG_VAR( variableName, variableType, configFileObject, sectionNameStr)
An useful macro for loading variables stored in a INI-like file under a key with the same name that t...
#define LOADABLEOPTS_DUMP_VAR(variableName, variableType)
Macro for dumping a variable to a stream, within the method "dumpToTextStream(out)" (Variable types a...
#define IS_CLASS(ptrObj, class_name)
Evaluates to true if the given pointer to an object (derived from mrpt::utils::CSerializable) is of t...
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
#define MAP_DEFINITION_REGISTER(_CLASSNAME_STRINGS, _CLASSNAME_WITH_NS)
Registers one map class into TMetricMapInitializer factory.
A three-dimensional probabilistic occupancy grid, implemented as an octo-tree with the "octomap" C++ ...
Declares a virtual base class for all metric maps storage classes.
A three-dimensional probabilistic occupancy grid, implemented as an octo-tree with the "octomap" C++ ...
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans or other sensors.
void getPointFast(size_t index, float &x, float &y, float &z) const
Just like getPoint() but without checking out-of-bound index and without returning the point weight,...
size_t size() const
Returns the number of stored points in the map.
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
const POINTSMAP * buildAuxPointsMap(const void *options=nullptr) const
Returns a cached points map representing this laser scan, building it upon the first call.
mrpt::poses::CPose3D sensorPose
The 6D pose of the sensor on the robot at the moment of starting the scan.
Declares a class derived from "CObservation" that encapsules a 3D range scan measurement,...
virtual void load() const override
Makes sure all images and other fields which may be externally stored are loaded in memory.
mrpt::poses::CPose3D sensorPose
The 6D pose of the sensor on the robot.
Declares a class that represents any robot's observation.
A flexible renderer of voxels, typically from a 3D octo map (see mrpt::maps::COctoMap).
void clear()
Clears everything.
void push_back_Voxel(const size_t set_index, const TVoxel &v)
bool isCubeTransparencyEnabled() const
void setBoundingBox(const mrpt::math::TPoint3D &bb_min, const mrpt::math::TPoint3D &bb_max)
Manually changes the bounding box (normally the user doesn't need to call this)
void reserveVoxels(const size_t set_index, const size_t nVoxels)
void showVoxels(unsigned int voxel_set, bool show)
Shows/hides the voxels (voxel_set is a 0-based index for the set of voxels to modify,...
void reserveGridCubes(const size_t nCubes)
void resizeVoxelSets(const size_t nVoxelSets)
void push_back_GridCube(const TGridCube &c)
std::shared_ptr< CPointCloudColoured > Ptr
mrpt::utils::TColorf getColor() const
Returns the object color property as a TColorf.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
void composePoint(double lx, double ly, double lz, double &gx, double &gy, double &gz, mrpt::math::CMatrixFixedNumeric< double, 3, 3 > *out_jacobian_df_dpoint=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dpose=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dse3=nullptr, bool use_small_rot_approx=false) const
An alternative, slightly more efficient way of doing with G and L being 3D points and P this 6D pose...
void composeFrom(const CPose3D &A, const CPose3D &B)
Makes "this = A (+) B"; this method is slightly more efficient than "this= A + B;" since it avoids th...
double x() const
Common members of all points & poses classes.
This class allows loading and storing values and vectors of different types from a configuration text...
A memory buffer (implements CStream) which can be itself serialized.
void readFromStream(mrpt::utils::CStream &in, int version) override
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
bool loadBufferFromFile(const std::string &file_name)
Loads the entire buffer from a file *.
bool saveBufferToFile(const std::string &file_name)
Saves the entire buffer to a file.
uint64_t getTotalBytesCount() override
Returns the total size of the internal buffer
virtual void writeToStream(mrpt::utils::CStream &out, int *getVersion) const =0
Introduces a pure virtual method responsible for writing to a CStream.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
GLsizei GLsizei GLuint * obj
GLdouble GLdouble GLdouble r
GLsizei const GLchar ** string
GLsizei GLsizei GLchar * source
std::string getTempFileName()
Returns the name of a proposed temporary file name.
bool deleteFile(const std::string &fileName)
Deletes a single file.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
#define THROW_EXCEPTION(msg)
This base provides a set of functions for maths stuff.
void project3DPointsFromDepthImageInto(mrpt::obs::CObservation3DRangeScan &src_obs, POINTMAP &dest_pointcloud, const mrpt::obs::T3DPointsProjectionParams &projectParams, const mrpt::obs::TRangeImageFilterParams &filterParams)
This namespace contains representation of robot actions and observations.
The namespace for 3D scene representation and rendering.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values,...
void clear()
Clear the contents of this container.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
mrpt::maps::CColouredOctoMap::TInsertionOptions insertionOpts
Observations insertion options.
double resolution
The finest resolution of the octomap (default: 0.10 meters)
mrpt::maps::CColouredOctoMap::TLikelihoodOptions likelihoodOpts
Probabilistic observation likelihood options.
Virtual base for specifying the kind and parameters of one map (normally, to be inserted into mrpt::m...
double x
X,Y,Z coordinates.
Lightweight 3D point (float version).
Used in CObservation3DRangeScan::project3DPointsFromDepthImageInto()
bool PROJ3D_USE_LUT
(Default:true) [Only used when range_is_depth=true] Whether to use a Look-up-table (LUT) to speed up ...
const mrpt::poses::CPose3D * robotPoseInTheWorld
(Default: nullptr) Read takeIntoAccountSensorPoseOnRobot
The info of each grid block.
The info of each of the voxels.
A RGB color - floats in the range [0,1].