Class C2DRangeFinderAbstract

Inheritance Relationships

Base Types

Derived Types

Class Documentation

class C2DRangeFinderAbstract : public mrpt::system::COutputLogger, public mrpt::hwdrivers::CGenericSensor

This is the base, abstract class for “software drivers” interfaces to 2D scanners (laser range finders). Physical devices may be interfaced through a serial port, a USB connection,etc. but this class abstract those details through the “binding” of the specific scanner driver to a given I/O channel, which must be set by calling “hwdrivers::C2DRangeFinderAbstract::bindIO”. See also the derived classes.

There is support for “exclusion polygons”, areas where points, if detected, should be marked as invalid. Those areas are useful in cases where the scanner always detects part of the vehicle itself, and those points want to be ignored (see C2DRangeFinderAbstract::loadExclusionAreas).

See also

comms::CSerialPort

Subclassed by mrpt::hwdrivers::CHokuyoURG, mrpt::hwdrivers::CLMS100Eth, mrpt::hwdrivers::CRoboPeakLidar, mrpt::hwdrivers::CSICKTim561Eth, mrpt::hwdrivers::CSickLaserSerial, mrpt::hwdrivers::CSickLaserUSB

Public Functions

C2DRangeFinderAbstract()

Default constructor

~C2DRangeFinderAbstract() override

Destructor

void bindIO(const std::shared_ptr<mrpt::io::CStream> &streamIO)

Binds the object to a given I/O channel. The stream object must not be deleted before the destruction of this class.

See also

comms::CSerialPort

void getObservation(bool &outThereIsObservation, mrpt::obs::CObservation2DRangeScan &outObservation, bool &hardwareError)

Get the last observation from the sensor, if available, and unmarks it as being “the last one” (thus a new scan must arrive or subsequent calls will find no new observations).

virtual void doProcess() override

Main method for a CGenericSensor

virtual void doProcessSimple(bool &outThereIsObservation, mrpt::obs::CObservation2DRangeScan &outObservation, bool &hardwareError) = 0

Specific laser scanner “software drivers” must process here new data from the I/O stream, and, if a whole scan has arrived, return it. This method MUST BE CALLED in a timely fashion by the user to allow the proccessing of incoming data. It can be run in a different thread safely.

virtual bool turnOn() = 0

Enables the scanning mode (which may depend on the specific laser device); this must be called before asking for observations to assure that the protocol has been initializated.

Returns:

If everything works “true”, or “false” if there is any error.

virtual bool turnOff() = 0

Disables the scanning mode (this can be used to turn the device in low energy mode, if available)

Returns:

If everything works “true”, or “false” if there is any error.

inline double getEstimatedScanPeriod() const

Returns the empirical, filtered estimation for the period at which whole scans are being returned from calls to doProcessSimple()

Note

: Units: seconds

Protected Functions

void loadCommonParams(const mrpt::config::CConfigFileBase &configSource, const std::string &iniSection)

Should be call by derived classes at “loadConfig” (loads exclusion areas AND exclusion angles). This loads a sequence of vertices of a polygon given by its (x,y) coordinates relative to the vehicle, that is, taking into account the “sensorPose”.

  • exclusionZoneu_x

  • exclusionZoneu_y for u=1,2,3,… All points within the 2D polygon will be ignored, for any Z, unless an optional entry is found:

  • exclusionZoneu_z=[z_min z_max] In that case, only the points within the 2D polygon AND the given range in Z will be ignored.

The number of zones is variable, but they must start at 1 and be consecutive.

This also loads any other common params (e.g. ‘preview’)

void filterByExclusionAreas(mrpt::obs::CObservation2DRangeScan &obs) const

Mark as invalid those points which (x,y) coordinates fall within the exclusion polygons.

See also

loadExclusionAreas

void filterByExclusionAngles(mrpt::obs::CObservation2DRangeScan &obs) const

Mark as invalid those ranges in a set of forbidden angle ranges.

See also

loadExclusionAreas

void internal_notifyGoodScanNow()

Must be called from doProcessSimple() implementations

bool internal_notifyNoScanReceived()

Must be called from doProcessSimple() implementations. Returns true if ok, false if this seems strange and should return an error condition to the user.

Protected Attributes

std::shared_ptr<mrpt::io::CStream> m_stream

The I/O channel (will be nullptr if not bound).