class mrpt::hwdrivers::C2DRangeFinderAbstract
Overview
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:
#include <mrpt/hwdrivers/C2DRangeFinderAbstract.h> class C2DRangeFinderAbstract: public mrpt::system::COutputLogger, public mrpt::hwdrivers::CGenericSensor { public: // construction C2DRangeFinderAbstract(); // methods void bindIO(const std::shared_ptr<mrpt::io::CStream>& streamIO); void getObservation(bool& outThereIsObservation, mrpt::obs::CObservation2DRangeScan& outObservation, bool& hardwareError); virtual void doProcess(); virtual void doProcessSimple( bool& outThereIsObservation, mrpt::obs::CObservation2DRangeScan& outObservation, bool& hardwareError ) = 0; virtual bool turnOn() = 0; virtual bool turnOff() = 0; double getEstimatedScanPeriod() const; }; // direct descendants class CHokuyoURG; class CLMS100Eth; class CRoboPeakLidar; class CSICKTim561Eth; class CSickLaserSerial; class CSickLaserUSB; class FakeLaser;
Inherited Members
public: // typedefs typedef std::shared_ptr<CGenericSensor> Ptr; typedef std::multimap<mrpt::system::TTimeStamp, mrpt::serialization::CSerializable::Ptr> TListObservations; typedef std::pair<mrpt::system::TTimeStamp, mrpt::serialization::CSerializable::Ptr> TListObsPair; // enums enum TSensorState; // structs struct TMsg; // fields bool logging_enable_console_output {true}; bool logging_enable_keep_record {false}; // methods void logStr(const VerbosityLevel level, std::string_view msg_str) const; void logFmt(const VerbosityLevel level, const char* fmt, ...) const; void void logCond(const VerbosityLevel level, bool cond, const std::string& msg_str) const; void setLoggerName(const std::string& name); std::string getLoggerName() const; void setVerbosityLevel(const VerbosityLevel level); void setVerbosityLevelForCallbacks(const VerbosityLevel level); void setMinLoggingLevel(const VerbosityLevel level); VerbosityLevel getMinLoggingLevel() const; VerbosityLevel getMinLoggingLevelForCallbacks() const; bool isLoggingLevelVisible(VerbosityLevel level) const; void getLogAsString(std::string& log_contents) const; std::string getLogAsString() const; void writeLogToFile(const std::optional<std::string>& fname_in = std::nullopt) const; void dumpLogToConsole() const; std::string getLoggerLastMsg() const; void getLoggerLastMsg(std::string& msg_str) const; void loggerReset(); void logRegisterCallback(output_logger_callback_t userFunc); bool logDeregisterCallback(output_logger_callback_t userFunc); COutputLogger& operator = (const COutputLogger&); COutputLogger& operator = (COutputLogger&&); static std::array<mrpt::system::ConsoleForegroundColor, NUMBER_OF_VERBOSITY_LEVELS>& logging_levels_to_colors(); static const std::array<const char*, NUMBER_OF_VERBOSITY_LEVELS>& logging_levels_to_names(); virtual const mrpt::hwdrivers::TSensorClassId* GetRuntimeClass() const = 0; TSensorState getState() const; double getProcessRate() const; std::string getSensorLabel() const; void setSensorLabel(const std::string& sensorLabel); void enableVerbose(bool enabled = true); bool isVerboseEnabled() const; CGenericSensor& operator = (const CGenericSensor&); virtual void loadConfig(const mrpt::config::CConfigFileBase& configSource, const std::string& section); virtual void initialize(); virtual void doProcess() = 0; virtual TListObservations getObservations(); virtual void setPathForExternalImages(] const std::string& directory); virtual void setExternalImageFormat(const std::string& ext); virtual void setExternalImageJPEGQuality(const unsigned int quality); virtual unsigned int getExternalImageJPEGQuality() const; static void registerClass(const TSensorClassId* pNewClass); static CGenericSensor* createSensor(const std::string& className); static Ptr createSensorPtr(const std::string& className);
Construction
C2DRangeFinderAbstract()
Default constructor.
Methods
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:
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()
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.
double getEstimatedScanPeriod() const
Returns the empirical, filtered estimation for the period at which whole scans are being returned from calls to doProcessSimple()
: Units: seconds