33 void COctoMap::TMapDefinition::loadFromConfigFile_map_specific(
39 sectionNamePrefix +
string(
"_creationOpts");
42 insertionOpts.loadFromConfigFile(
43 source, sectionNamePrefix +
string(
"_insertOpts"));
44 likelihoodOpts.loadFromConfigFile(
45 source, sectionNamePrefix +
string(
"_likelihoodOpts"));
48 void COctoMap::TMapDefinition::dumpToTextStream_map_specific(
53 this->insertionOpts.dumpToTextStream(out);
54 this->likelihoodOpts.dumpToTextStream(out);
75 :
COctoMapBase<octomap::OcTree, octomap::OcTreeNode>(resolution)
82 COctoMap::~COctoMap() {}
95 this->renderingOptions.writeToStream(out);
96 out << genericMapParams;
100 const_cast<octomap::OcTree*
>(&m_octomap)->writeBinary(tmpFil);
122 if (version >= 1) this->renderingOptions.readFromStream(
in);
123 if (version >= 2)
in >> genericMapParams;
130 if (chunk.getTotalBytesCount())
133 if (!chunk.saveBufferToFile(tmpFil))
135 m_octomap.readBinary(tmpFil);
145 bool COctoMap::internal_insertObservation(
148 octomap::point3d sensorPt;
149 octomap::Pointcloud scan;
150 if (!internal_build_PointCloud_for_observation(
151 obs, robotPose, sensorPt, scan))
154 m_octomap.insertPointCloud(
155 scan, sensorPt, insertionOptions.maxrange, insertionOptions.pruning);
165 octomap::OcTree::tree_iterator it_end = m_octomap.end_tree();
167 const unsigned char max_depth = 0;
169 const TColor general_color_u(
170 general_color.
R * 255, general_color.
G * 255, general_color.
B * 255,
171 general_color.
A * 255);
182 const size_t nLeafs = this->getNumLeafNodes();
186 double xmin, xmax, ymin, ymax, zmin,
zmax, inv_dz;
187 this->getMetricMin(xmin, ymin, zmin);
188 this->getMetricMax(xmax, ymax,
zmax);
189 inv_dz = 1 / (
zmax - zmin + 0.01);
191 for (octomap::OcTree::tree_iterator it = m_octomap.begin_tree(max_depth);
194 const octomap::point3d vx_center = it.getCoordinate();
195 const double vx_length = it.getSize();
196 const double L = 0.5 * vx_length;
201 const double occ = it->getOccupancy();
202 if ((occ >= 0.5 && renderingOptions.generateOccupiedVoxels) ||
203 (occ < 0.5 && renderingOptions.generateFreeVoxels))
209 case COctoMapVoxels::FIXED:
210 vx_color = general_color_u;
212 case COctoMapVoxels::COLOR_FROM_HEIGHT:
213 coefc = 255 * inv_dz * (vx_center.z() - zmin);
215 coefc * general_color.
R, coefc * general_color.
G,
216 coefc * general_color.
B, 255.0 * general_color.
A);
219 case COctoMapVoxels::COLOR_FROM_OCCUPANCY:
220 coefc = 240 * (1 - occ) + 15;
222 coefc * general_color.
R, coefc * general_color.
G,
223 coefc * general_color.
B, 255.0 * general_color.
A);
226 case COctoMapVoxels::TRANSPARENCY_FROM_OCCUPANCY:
227 coeft = 255 - 510 * (1 - occ);
233 255 * general_color.
R, 255 * general_color.
G,
234 255 * general_color.
B, coeft);
237 case COctoMapVoxels::TRANS_AND_COLOR_FROM_OCCUPANCY:
238 coefc = 240 * (1 - occ) + 15;
240 coefc * general_color.
R, coefc * general_color.
G,
241 coefc * general_color.
B, 50);
244 case COctoMapVoxels::MIXED:
245 coefc = 255 * inv_dz * (vx_center.z() - zmin);
246 coeft = 255 - 510 * (1 - occ);
252 coefc * general_color.
R, coefc * general_color.
G,
253 coefc * general_color.
B, coeft);
260 const size_t vx_set = (m_octomap.isNodeOccupied(*it))
267 TPoint3D(vx_center.x(), vx_center.y(), vx_center.z()),
268 vx_length, vx_color));
271 else if (renderingOptions.generateGridLines)
275 vx_center.x() - L, vx_center.y() - L, vx_center.z() - L);
277 vx_center.x() + L, vx_center.y() + L, vx_center.z() + L);
290 this->getMetricMin(bbmin.
x, bbmin.
y, bbmin.
z);
291 this->getMetricMax(bbmax.
x, bbmax.
y, bbmax.
z);
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, e.g.
Virtual base for specifying the kind and parameters of one map (normally, to be inserted into mrpt::m...
void reserveVoxels(const size_t set_index, const size_t nVoxels)
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
double resolution
The finest resolution of the octomap (default: 0.10 meters)
#define THROW_EXCEPTION(msg)
virtual void writeToStream(mrpt::utils::CStream &out, int *getVersion) const =0
Introduces a pure virtual method responsible for writing to a CStream.
#define LOADABLEOPTS_DUMP_VAR(variableName, variableType)
Macro for dumping a variable to a stream, within the method "dumpToTextStream(out)" (Variable types a...
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 reserveGridCubes(const size_t nCubes)
void clear()
Clears everything.
GLsizei GLsizei GLuint * obj
void clear()
Clear the contents of this container.
This class allows loading and storing values and vectors of different types from a configuration text...
A three-dimensional probabilistic occupancy grid, implemented as an octo-tree with the "octomap" C++ ...
A flexible renderer of voxels, typically from a 3D octo map (see mrpt::maps::COctoMap).
void push_back_GridCube(const TGridCube &c)
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
This base provides a set of functions for maths stuff.
std::string getTempFileName()
Returns the name of a proposed temporary file name.
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...
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
mrpt::maps::COctoMap::TInsertionOptions insertionOpts
Observations insertion options.
mrpt::maps::COctoMap::TLikelihoodOptions likelihoodOpts
Probabilistic observation likelihood options.
This namespace contains representation of robot actions and observations.
double x
X,Y,Z coordinates.
A memory buffer (implements CStream) which can be itself serialized.
A three-dimensional probabilistic occupancy grid, implemented as an octo-tree with the "octomap" C++ ...
GLsizei const GLchar ** string
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
The info of each grid block.
void push_back_Voxel(const size_t set_index, const TVoxel &v)
The info of each of the voxels.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define MAP_DEFINITION_REGISTER(_CLASSNAME_STRINGS, _CLASSNAME_WITH_NS)
Registers one map class into TMetricMapInitializer factory.
Declares a virtual base class for all metric maps storage classes.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Declares a class that represents any robot's observation.
void resizeVoxelSets(const size_t nVoxelSets)
visualization_mode_t getVisualizationMode() const
The namespace for 3D scene representation and rendering.
GLsizei GLsizei GLchar * source
A RGB color - floats in the range [0,1].
bool deleteFile(const std::string &fileName)
Deletes a single file.
#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...
bool loadBufferFromFile(const std::string &file_name)
Loads the entire buffer from a file *.
bool isCubeTransparencyEnabled() const
mrpt::utils::TColorf getColor() const
Returns the object color property as a TColorf.