20 template <
class OCTREE,
class OCTREE_NODE>
29 robotPose3D = (*robotPose);
46 const size_t nPts = scanPts->
size();
52 for (
size_t i=0;i<nPts;i++)
55 scanPts->getPointFast(i,pt.
x,pt.
y,pt.
z);
83 const size_t sizeRangeScan = o->
points3D_x.size();
91 const float m00 = H.get_unsafe(0,0);
92 const float m01 = H.get_unsafe(0,1);
93 const float m02 = H.get_unsafe(0,2);
94 const float m03 = H.get_unsafe(0,3);
95 const float m10 = H.get_unsafe(1,0);
96 const float m11 = H.get_unsafe(1,1);
97 const float m12 = H.get_unsafe(1,2);
98 const float m13 = H.get_unsafe(1,3);
99 const float m20 = H.get_unsafe(2,0);
100 const float m21 = H.get_unsafe(2,1);
101 const float m22 = H.get_unsafe(2,2);
102 const float m23 = H.get_unsafe(2,3);
105 for (
size_t i=0;i<sizeRangeScan;i++)
112 if ( pt.
x!=0 || pt.
y!=0 || pt.
z!=0 )
115 const float gx = m00*pt.
x + m01*pt.
y + m02*pt.
z + m03;
116 const float gy = m10*pt.
x + m11*pt.
y + m12*pt.
z + m13;
117 const float gz = m20*pt.
x + m21*pt.
y + m22*pt.
z + m23;
129 template <
class OCTREE,
class OCTREE_NODE>
132 return m_octomap.size()==1;
135 template <
class OCTREE,
class OCTREE_NODE>
145 this->getAs3DObject(obj3D);
149 const std::string fil = filNamePrefix + std::string(
"_3D.3Dscene");
156 const std::string fil = filNamePrefix + std::string(
"_binary.bt");
157 const_cast<OCTREE*
>(&m_octomap)->writeBinary(fil);
162 template <
class OCTREE,
class OCTREE_NODE>
168 if (!internal_build_PointCloud_for_observation(obs,&takenFrom, sensorPt, scan))
172 const size_t N=scan.
size();
175 for (
size_t i=0;i<N;i+=likelihoodOptions.decimation)
177 if (m_octomap.coordToKeyChecked(scan.
getPoint(i), key))
181 log_lik += std::log(node->getOccupancy());
188 template <
class OCTREE,
class OCTREE_NODE>
195 if (!node)
return false;
197 prob_occupancy = node->getOccupancy();
203 template <
class OCTREE,
class OCTREE_NODE>
209 const float *xs,*ys,*zs;
211 for (
size_t i=0;i<N;i++)
212 m_octomap.insertRay(sensorPt,
octomap::point3d(xs[i],ys[i],zs[i]), insertionOptions.maxrange,insertionOptions.pruning);
216 template <
class OCTREE,
class OCTREE_NODE>
221 const bool ret=m_octomap.castRay(
224 _end,ignoreUnknownCells,maxRange);
237 template <
class OCTREE,
class OCTREE_NODE>
243 occupancyThres (0.5),
246 clampingThresMin(0.1192),
247 clampingThresMax(0.971)
251 template <
class OCTREE,
class OCTREE_NODE>
257 occupancyThres (0.5),
260 clampingThresMin(0.1192),
261 clampingThresMax(0.971)
265 template <
class OCTREE,
class OCTREE_NODE>
271 template <
class OCTREE,
class OCTREE_NODE>
274 const int8_t version = 0;
279 template <
class OCTREE,
class OCTREE_NODE>
299 template <
class OCTREE,
class OCTREE_NODE>
302 out.
printf(
"\n----------- [COctoMapBase<>::TInsertionOptions] ------------ \n\n");
316 template <
class OCTREE,
class OCTREE_NODE>
319 out.
printf(
"\n----------- [COctoMapBase<>::TLikelihoodOptions] ------------ \n\n");
327 template <
class OCTREE,
class OCTREE_NODE>
330 const std::string §ion)
342 this->setOccupancyThres(occupancyThres);
343 this->setProbHit(probHit);
344 this->setProbMiss(probMiss);
345 this->setClampingThresMin(clampingThresMin);
346 this->setClampingThresMax(clampingThresMax);
349 template <
class OCTREE,
class OCTREE_NODE>
352 const std::string §ion)
358 template <
class OCTREE,
class OCTREE_NODE>
361 const int8_t version = 0;
363 out << generateGridLines << generateOccupiedVoxels << visibleOccupiedVoxels
364 << generateFreeVoxels << visibleFreeVoxels;
367 template <
class OCTREE,
class OCTREE_NODE>
376 in >> generateGridLines >> generateOccupiedVoxels >> visibleOccupiedVoxels
377 >> generateFreeVoxels >> visibleFreeVoxels;
void readFromStream(CStream &in)
Binary dump to stream.
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
virtual void saveMetricMapRepresentationToFile(const std::string &filNamePrefix) const
This virtual method saves the map to a file "filNamePrefix"+< some_file_extension >...
void loadFromConfigFile(const mrpt::utils::CConfigFileBase &source, const std::string §ion)
See utils::CLoadableOptions.
point3d getPoint(unsigned int i)
void loadFromConfigFile(const mrpt::utils::CConfigFileBase &source, const std::string §ion)
See utils::CLoadableOptions.
EIGEN_STRONG_INLINE iterator end()
void dumpToTextStream(CStream &out) const
See utils::CLoadableOptions.
std::vector< float > points3D_y
If hasPoints3D=true, the Y coordinates of the 3D point cloud detected by the camera.
void insertPointCloud(const CPointsMap &ptMap, const float sensor_x, const float sensor_y, const float sensor_z)
Update the octomap with a 2D or 3D scan, given directly as a point cloud and the 3D location of the s...
bool getPointOccupancy(const float x, const float y, const float z, double &prob_occupancy) const
Get the occupancy probability [0,1] of a point.
#define LOADABLEOPTS_DUMP_VAR(variableName, variableType)
Macro for dumping a variable to a stream, within the method "dumpToTextStream(out)" (Variable types a...
size_t size() const
Returns the number of stored points in the map.
void readFromStream(CStream &in)
Binary dump to stream.
TInsertionOptions()
Especial constructor, not attached to a real COctoMap object: used only in limited situations...
double z
X,Y,Z coordinates.
void dumpToTextStream(CStream &out) const
See utils::CLoadableOptions.
virtual double computeObservationLikelihood(const CObservation *obs, const CPose3D &takenFrom)
Computes the log-likelihood of a given observation given an arbitrary robot 3D pose.
This class allows loading and storing values and vectors of different types from a configuration text...
virtual bool isEmpty() const
Returns true if the map is empty/no observation has been inserted.
CPose3D sensorPose
The 6D pose of the sensor on the robot.
bool hasPoints3D
true means the field points3D contains valid data.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
bool castRay(const mrpt::math::TPoint3D &origin, const mrpt::math::TPoint3D &direction, mrpt::math::TPoint3D &end, bool ignoreUnknownCells=false, double maxRange=-1.0) const
Performs raycasting in 3d, similar to computeRay().
std::vector< float > points3D_x
If hasPoints3D=true, the X coordinates of the 3D point cloud detected by the camera.
A numeric matrix of compile-time fixed size.
void composePoint(double lx, double ly, double lz, double &gx, double &gy, double &gz, mrpt::math::CMatrixFixedNumeric< double, 3, 3 > *out_jacobian_df_dpoint=NULL, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dpose=NULL, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dse3=NULL, 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...
double x() const
Common members of all points & poses classes.
Lightweight 3D point (float version).
void push_back(float x, float y, float z)
void writeToStream(CStream &out) const
Binary dump to stream.
This CStream derived class allow using a file as a write-only, binary stream.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
void getHomogeneousMatrix(mrpt::math::CMatrixDouble44 &out_HM) const
Returns the corresponding 4x4 homogeneous transformation matrix for the point(translation) or pose (t...
Declares a class that represents any robot's observation.
const POINTSMAP * buildAuxPointsMap(const void *options=NULL) const
Returns a cached points map representing this laser scan, building it upon the first call...
A collection of 3D coordinates (point3d), which are regarded as endpoints of a 3D laser scan...
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
#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...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void reserve(size_t size)
void insert(const CRenderizablePtr &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)...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
#define IS_CLASS(ptrObj, class_name)
Evaluates to true if the given pointer to an object (derived from mrpt::utils::CSerializable) is of t...
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...
std::vector< float > points3D_z
If hasPoints3D=true, the Z coordinates of the 3D point cloud detected by the camera.
OCTREE_NODE octree_node_t
The type of nodes in the octree, in the "octomap" library.
OcTreeKey is a container class for internal key addressing.
TLikelihoodOptions()
Initilization of default parameters.
This class allows the user to create, load, save, and render 3D scenes using OpenGL primitives...
octomath::Vector3 point3d
Use Vector3 (float precision) as a point3d in octomap.
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans or other sensors...
void getPointsBuffer(size_t &outPointsCount, const float *&xs, const float *&ys, const float *&zs) const
Provides a direct access to points buffer, or NULL if there is no points in the map.
Declares a class derived from "CObservation" that encapsules a 3D range scan measurement (e...
void writeToStream(CStream &out) const
Binary dump to stream.
CPose3D sensorPose
The 6D pose of the sensor on the robot.
A three-dimensional probabilistic occupancy grid, implemented as an octo-tree with the "octomap" C++ ...
virtual void load() const
Makes sure all images and other fields which may be externally stored are loaded in memory...
virtual int printf(const char *fmt,...) MRPT_printf_format_check(2
Writes a string to the stream in a textual form.
static CSetOfObjectsPtr Create()
bool internal_build_PointCloud_for_observation(const CObservation *obs, const CPose3D *robotPose, octomap::point3d &point3d_sensorPt, octomap::Pointcloud &ptr_scan) const
Builds the list of 3D points in global coordinates for a generic observation.
This class represents a three-dimensional vector.