37 m_has_intensity(false),
39 intensity( m_intensity ),
40 validRange( m_validRange ),
54 intensity( m_intensity ),
55 validRange( m_validRange )
116 itScan++, itValid++, k++ )
119 float x = (*itScan)*cos(ang);
121 if( min_height != 0 || max_height != 0 )
123 ASSERT_( max_height > min_height );
124 if( *itScan < min_distance || ang > max_angle ||
x > h - min_height ||
x < h - max_height )
128 if( *itScan < min_distance || ang > max_angle )
153 in.ReadBufferFixEndianness( &
m_scan[0], N);
206 in.ReadBufferFixEndianness( &
m_scan[0], N);
249 const char* fields[] = {
"class",
251 "scan",
"validRange",
"intensity" 252 "aperture",
"rightToLeft",
"maxRange",
253 "stdError",
"beamAperture",
"deltaPitch",
256 mexplus::MxArray obs_struct( mexplus::MxArray::Struct(
sizeof(fields)/
sizeof(fields[0]),fields) );
263 obs_struct.set(
"scan", this->
m_scan);
267 obs_struct.set(
"aperture", this->
aperture);
269 obs_struct.set(
"maxRange", this->
maxRange);
270 obs_struct.set(
"stdError", this->
stdError);
272 obs_struct.set(
"deltaPitch", this->
deltaPitch);
275 return obs_struct.release();
302 if (areas.empty())
return;
311 if (!sizeRangeScan)
return;
321 dA = -
aperture / (sizeRangeScan-1);
336 const double Lx = *scan_it * cos( Ang );
337 const double Ly = *scan_it * sin( Ang );
347 if ( i->first.PointIntoPolygon(Gx,Gy) &&
348 (Gz>=i->second.first && Gz<=i->second.second) )
364 if (areas.empty())
return;
367 for (
size_t i=0;i<areas.size();i++)
369 TListExclusionAreasWithRanges::value_type dat;
370 dat.first = areas[i];
371 dat.second.first = -std::numeric_limits<double>::max();
372 dat.second.second = std::numeric_limits<double>::max();
384 if (angles.empty())
return;
389 const size_t sizeRangeScan =
scan.
size();
393 if (!sizeRangeScan)
return;
403 dA = -
aperture / (sizeRangeScan-1);
407 for (vector<pair<double,double> >::
const_iterator itA=angles.begin();itA!=angles.end();++itA)
412 if (ap_idx_ini<0) ap_idx_ini=0;
413 if (ap_idx_end<0) ap_idx_end=0;
415 if (ap_idx_ini>(
int)sizeRangeScan) ap_idx_ini=sizeRangeScan-1;
416 if (ap_idx_end>(
int)sizeRangeScan) ap_idx_end=sizeRangeScan-1;
418 const size_t idx_ini = ap_idx_ini;
419 const size_t idx_end = ap_idx_end;
421 if (idx_end>=idx_ini)
423 for (
size_t i=idx_ini;i<=idx_end;i++)
428 for (
size_t i=0;i<idx_end;i++)
431 for (
size_t i=idx_ini;i<sizeRangeScan;i++)
455 throw std::runtime_error(
"[CObservation2DRangeScan::buildAuxPointsMap] ERROR: This function needs linking against mrpt-maps.\n");
457 (*ptr_internal_build_points_map_from_scan2D)(*
this,
m_cachedMap, options);
470 if (
a.nRays !=
b.nRays)
return a.nRays<
b.nRays;
471 if (
a.aperture !=
b.aperture)
return a.aperture <
b.aperture;
472 if (
a.rightToLeft !=
b.rightToLeft)
return a.rightToLeft;
480 o <<
"Homogeneous matrix for the sensor's 3D pose, relative to robot base:\n";
483 o <<
format(
"Samples direction: %s\n", (
rightToLeft) ?
"Right->Left" :
"Left->Right");
490 o <<
format(
"Invalid points in the scan: %u\n", (
unsigned)inval);
495 o <<
"Raw scan values: [";
499 o <<
"Raw valid-scan values: [";
504 o <<
"Raw intensity values: [";
579 for (
size_t i=0;i<nRays;i++) {
580 m_scan[i] = scanRanges[i];
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
virtual const mrpt::utils::TRuntimeClassId * GetRuntimeClass() const
Returns information about the class of an object in runtime.
void OBS_IMPEXP(* ptr_internal_build_points_map_from_scan2D)(const mrpt::obs::CObservation2DRangeScan &obs, mrpt::maps::CMetricMapPtr &out_map, const void *insertOps)
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 setScanRange(const size_t i, const float val)
std::vector< std::pair< mrpt::math::CPolygon, std::pair< double, double > > > TListExclusionAreasWithRanges
Used in filterByExclusionAreas.
#define ASSERT_BELOW_(__A, __B)
void WriteBuffer(const void *Buffer, size_t Count)
Writes a block of bytes to the stream from Buffer.
bool OBS_IMPEXP 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.
const Scalar * const_iterator
float stdError
The "sigma" error of the device in meters, used while inserting the scan in an occupancy grid...
IMPLEMENTS_SERIALIZABLE(CLogFileRecord_FullEval, CHolonomicLogFileRecord, mrpt::nav) IMPLEMENTS_SERIALIZABLE(CHolonomicFullEval
void getDescriptionAsText(std::ostream &o) const MRPT_OVERRIDE
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...
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. 80m, 50m,...)
void WriteBufferFixEndianness(const T *ptr, size_t ElementCount)
Writes a sequence of elemental datatypes, taking care of reordering their bytes from the running arch...
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...
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.
void readFromStream(mrpt::utils::CStream &in, int version)
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
float getScanRange(const size_t i) const
mrpt::math::CMatrixDouble44 getHomogeneousMatrixVal() const
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.
#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. If available, must have same length than validRange.
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 BASE_IMPEXP 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. If not, space is saved during serialization.
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...
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 writeToStream(mrpt::utils::CStream &out, int *getVersion) const
Introduces a pure virtual method responsible for writing to a CStream.
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. Where available, this should contain the accurate satellite-based time...
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).
Declares a class that represents any robot's observation.
void resizeScan(const size_t len)
Resizes all data vectors to allocate a given number of scan rays.
double deltaPitch
If the laser gathers data by sweeping in the pitch/elevation angle, this holds the increment in "pitc...
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. Must have same length than validRange.
void loadFromVectors(size_t nRays, const float *scanRanges, const char *scanValidity)
void internal_buildAuxPointsMap(const void *options=NULL) const
Internal method, used from buildAuxPointsMap()
mrpt::maps::CMetricMapPtr m_cachedMap
A points map, build only under demand by the methods getAuxPointsMap() and buildAuxPointsMap().
bool hasIntensity() const
Return true if scan has intensity.
mrpt::utils::ContainerReadOnlyProxyAccessor< std::vector< float > > scan
The range values of the scan, in meters. Must have same length than validRange.
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