37 m_has_intensity(false),
39 intensity(m_intensity),
40 validRange(m_validRange),
52 CObservation2DRangeScan::CObservation2DRangeScan(
55 intensity(m_intensity),
56 validRange(m_validRange)
104 float min_distance,
float max_angle,
float min_height,
float max_height,
115 itScan !=
m_scan.end(); itScan++, itValid++, k++)
118 float x = (*itScan) * cos(ang);
120 if (min_height != 0 || max_height != 0)
122 ASSERT_(max_height > min_height);
123 if (*itScan < min_distance || ang > max_angle ||
124 x > h - min_height ||
x < h - max_height)
127 else if (*itScan < min_distance || ang > max_angle)
153 if (N)
in.ReadBufferFixEndianness(&
m_scan[0], N);
206 in.ReadBufferFixEndianness(&
m_scan[0], N);
251 const char* fields[] = {
254 "scan",
"validRange",
257 "rightToLeft",
"maxRange",
258 "stdError",
"beamAperture",
"deltaPitch",
261 mexplus::MxArray obs_struct(
262 mexplus::MxArray::Struct(
sizeof(fields) /
sizeof(fields[0]), fields));
269 obs_struct.set(
"scan", this->
m_scan);
275 obs_struct.set(
"aperture", this->
aperture);
277 obs_struct.set(
"maxRange", this->
maxRange);
278 obs_struct.set(
"stdError", this->
stdError);
280 obs_struct.set(
"deltaPitch", this->
deltaPitch);
283 return obs_struct.release();
307 if (areas.empty())
return;
316 if (!sizeRangeScan)
return;
321 dA =
aperture / (sizeRangeScan - 1);
326 dA = -
aperture / (sizeRangeScan - 1);
333 scan_it !=
m_scan.end(); scan_it++, valid_it++)
342 const double Lx = *scan_it * cos(Ang);
343 const double Ly = *scan_it * sin(Ang);
352 i != areas.end(); ++i)
354 if (i->first.PointIntoPolygon(Gx, Gy) &&
355 (Gz >= i->second.first && Gz <= i->second.second))
370 const std::vector<mrpt::math::CPolygon>& areas)
372 if (areas.empty())
return;
375 for (
size_t i = 0; i < areas.size(); i++)
377 TListExclusionAreasWithRanges::value_type dat;
378 dat.first = areas[i];
379 dat.second.first = -std::numeric_limits<double>::max();
380 dat.second.second = std::numeric_limits<double>::max();
391 const std::vector<std::pair<double, double>>& angles)
393 if (angles.empty())
return;
398 const size_t sizeRangeScan =
scan.
size();
402 if (!sizeRangeScan)
return;
407 dA =
aperture / (sizeRangeScan - 1);
412 dA = -
aperture / (sizeRangeScan - 1);
416 for (vector<pair<double, double>>::
const_iterator itA = angles.begin();
417 itA != angles.end(); ++itA)
423 if (ap_idx_ini < 0) ap_idx_ini = 0;
424 if (ap_idx_end < 0) ap_idx_end = 0;
426 if (ap_idx_ini > (
int)sizeRangeScan) ap_idx_ini = sizeRangeScan - 1;
427 if (ap_idx_end > (
int)sizeRangeScan) ap_idx_end = sizeRangeScan - 1;
429 const size_t idx_ini = ap_idx_ini;
430 const size_t idx_end = ap_idx_end;
432 if (idx_end >= idx_ini)
434 for (
size_t i = idx_ini; i <= idx_end; i++)
m_validRange[i] =
false;
438 for (
size_t i = 0; i < idx_end; i++)
m_validRange[i] =
false;
440 for (
size_t i = idx_ini; i < sizeRangeScan; i++)
472 const void* options)
const 475 throw std::runtime_error(
476 "[CObservation2DRangeScan::buildAuxPointsMap] ERROR: This function " 477 "needs linking against mrpt-maps.\n");
479 (*ptr_internal_build_points_map_from_scan2D)(*
this,
m_cachedMap, options);
493 if (
a.nRays !=
b.nRays)
return a.nRays <
b.nRays;
494 if (
a.aperture !=
b.aperture)
return a.aperture <
b.aperture;
495 if (
a.rightToLeft !=
b.rightToLeft)
return a.rightToLeft;
502 o <<
"Homogeneous matrix for the sensor's 3D pose, relative to robot " 507 "Samples direction: %s\n",
517 o <<
format(
"Invalid points in the scan: %u\n", (
unsigned)inval);
521 "Sensor field-of-view (\"aperture\"): %.01f deg\n",
RAD2DEG(
aperture));
523 o <<
"Raw scan values: [";
527 o <<
"Raw valid-scan values: [";
534 o <<
"Raw intensity values: [";
570 const size_t i,
const bool val)
589 const size_t len,
const float rangeVal,
const bool rangeValidity,
604 size_t nRays,
const float* scanRanges,
const char* scanValidity)
609 for (
size_t i = 0; i < nRays; i++)
611 m_scan[i] = scanRanges[i];
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
void filterByExclusionAngles(const std::vector< std::pair< double, double >> &angles)
Mark as invalid the ranges in any of a given set of "forbiden angle ranges", given as pairs<min_angle...
void getDescriptionAsText(std::ostream &o) const override
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...
scan2pts_functor ptr_internal_build_points_map_from_scan2D
float beamAperture
The aperture of each beam, in radians, used to insert "thick" rays in the occupancy grid...
bool isHorizontal(const double tolerance=0) const
Return true if the 6D pose represents a Z axis almost exactly vertical (upwards or downwards)...
void getScanProperties(T2DScanProperties &p) const
Fill out a T2DScanProperties structure with the parameters of this scan.
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
void setScanRange(const size_t i, const float val)
#define ASSERT_BELOW_(__A, __B)
void WriteBuffer(const void *Buffer, size_t Count)
Writes a block of bytes to the stream from Buffer.
bool operator<(const T2DScanProperties &a, const T2DScanProperties &b)
Order operator, so T2DScanProperties can appear in associative STL containers.
void setScanHasIntensity(bool setHasIntensityFlag)
Marks this scan as having or not intensity data.
void internal_set_build_points_map_from_scan2D(scan2pts_functor fn)
const Scalar * const_iterator
float stdError
The "sigma" error of the device in meters, used while inserting the scan in an occupancy grid...
int32_t getScanIntensity(const size_t i) const
virtual ~CObservation2DRangeScan()
Destructor.
size_t getScanSize() const
Get number of scan rays.
std::vector< char > m_validRange
It's false (=0) on no reflected rays, referenced to elements in scan.
float maxRange
The maximum range allowed by the device, in meters (e.g.
void WriteBufferFixEndianness(const T *ptr, size_t ElementCount)
Writes a sequence of elemental datatypes, taking care of reordering their bytes from the running arch...
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.
T length2length4N(T len)
Returns the smaller number >=len such that it's a multiple of 4.
std::shared_ptr< CMetricMap > Ptr
float getScanRange(const size_t i) const
mrpt::math::CMatrixDouble44 getHomogeneousMatrixVal() const
mrpt::maps::CMetricMap::Ptr m_cachedMap
A points map, build only under demand by the methods getAuxPointsMap() and buildAuxPointsMap().
bool isPlanarScan(const double tolerance=0) const
Return true if the laser scanner is "horizontal", so it has an absolute value of "pitch" and "roll" l...
Auxiliary struct that holds all the relevant geometry information about a 2D scan.
void internal_buildAuxPointsMap(const void *options=nullptr) const
Internal method, used from buildAuxPointsMap()
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
void setScanIntensity(const size_t i, const int val)
T wrapTo2Pi(T a)
Modifies the given angle to translate it into the [0,2pi[ range.
std::vector< int32_t > m_intensity
The intensity values of the scan.
This namespace contains representation of robot actions and observations.
mrpt::utils::ContainerReadOnlyProxyAccessor< std::vector< char > > validRange
It's false (=0) on no reflected rays, referenced to elements in scan.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
#define IMPLEMENTS_MEXPLUS_FROM(complete_type)
bool m_has_intensity
Whether the intensity values are present or not.
void resizeScanAndAssign(const size_t len, const float rangeVal, const bool rangeValidity, const int32_t rangeIntensity=0)
Resizes all data vectors to allocate a given number of scan rays and assign default values...
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
std::string sensorLabel
An arbitrary label that can be used to identify the sensor.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
mrpt::system::TTimeStamp timestamp
The associated UTC time-stamp.
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
virtual mxArray * writeToMatlab() const
Introduces a pure virtual method responsible for writing to a mxArray Matlab object, typically a MATLAB struct whose contents are documented in each derived class.
void truncateByDistanceAndAngle(float min_distance, float max_angle, float min_height=0, float max_height=0, float h=0)
A general method to truncate the scan by defining a minimum valid distance and a maximum valid angle ...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
std::vector< std::pair< mrpt::math::CPolygon, std::pair< double, double > > > TListExclusionAreasWithRanges
Used in filterByExclusionAreas.
Declares a class that represents any robot's observation.
virtual const mrpt::utils::TRuntimeClassId * GetRuntimeClass() const override
Returns information about the class of an object in runtime.
void resizeScan(const size_t len)
Resizes all data vectors to allocate a given number of scan rays.
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...
double deltaPitch
If the laser gathers data by sweeping in the pitch/elevation angle, this holds the increment in "pitc...
static constexpr const char * className
float aperture
The "aperture" or field-of-view of the range finder, in radians (typically M_PI = 180 degrees)...
std::vector< float > m_scan
The range values of the scan, in meters.
void loadFromVectors(size_t nRays, const float *scanRanges, const char *scanValidity)
void(*)(const mrpt::obs::CObservation2DRangeScan &obs, mrpt::maps::CMetricMap::Ptr &out_map, const void *insertOps) scan2pts_functor
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
bool hasIntensity() const
Return true if scan has intensity.
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...
mrpt::utils::ContainerReadOnlyProxyAccessor< std::vector< float > > scan
The range values of the scan, in meters.
void filterByExclusionAreas(const TListExclusionAreas &areas)
Mark as invalid sensed points that fall within any of a set of "exclusion areas", given in coordinate...
This class is a "CSerializable" wrapper for "CMatrixFloat".
bool rightToLeft
Angles storage order: true=counterclockwise; false=clockwise.
unsigned __int32 uint32_t
GLubyte GLubyte GLubyte a
mrpt::poses::CPose3D sensorPose
The 6D pose of the sensor on the robot at the moment of starting the scan.
struct mxArray_tag mxArray
Forward declaration for mxArray (avoid #including as much as possible to speed up compiling) ...
bool rightToLeft
The scanning direction: true=counterclockwise; false=clockwise.
virtual void getDescriptionAsText(std::ostream &o) const
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...
void setScanRangeValidity(const size_t i, const bool val)
bool getScanRangeValidity(const size_t i) const