class mrpt::hwdrivers::CLMS100Eth
Overview
Driver for the SICK LMS100 2-D laser range-finder over Ethernet.
Connects to the device via TCP/IP and acquires 2-D laser scans as mrpt::obs::CObservation2DRangeScan observations. The fixed hardware parameters of the LMS100 are: FOV 270 deg, angular resolution 0.25 deg, scan frequency 25 Hz, and maximum range 20 m.
Before using this class the scanner must be pre-configured with the SICK SOPAS software at least once (to set the frame rate and save to flash), because this driver does not handle the full SOPAS configuration protocol.
No external library is required; communication is via a plain TCP socket through mrpt::comms::CClientTCPSocket.
This “software driver” implements the communication protocol for interfacing a SICK LMS100 laser scanners through an ethernet controller. This class does not need to be bind, i.e. you do not need to call C2DRangeFinderAbstract::bindIO. Connection is established when user call the turnOn() method. You can pass to the class’s constructor the LMS100 ‘s ip address and port. Device will be configured with the following parameters :
Start Angle : -45 deg (imposed by hardware)
Stop Angle : +225 deg (imposed by hardware)
Apperture : 270 deg (imposed by hardware)
Angular resolution : 0.25 deg
Scan frequency : 25 Hz
Max Range : 20m (imposed by hardware).
Important note: SICK LMS 1xx devices have two levels of configuration. In its present implementation, this class only handles one of them, so before using this class, you must “pre-configure” your scanner with the SICK’s software “SOAP” (this software ships with the device), and set the framerate with this software. Of course, you have to pre-configure the device just once, then save that configuration in its flash memory.
To get a laser scan you must proceed like that :
CLMS200Eth laser(string("192.168.0.10"), 1234); laser.turnOn(); bool isOutObs, hardwareError; CObservation2DRangeScan outObs; laser.doProcessSimple(isOutObs, outObs, hardwareError);
The sensor pose on the vehicle could be loaded from an ini configuration file with :
PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS: ------------------------------------------------------- [supplied_section_name] ip_address = 192.168.0.50 ;a string which is the SICK's ip adress *(default is 192.168.0.1) TCP_port = 1234 ; an integer value : the tcp ip port on which the *sick is listening (default is 2111). pose_x=0.21 ; Laser range scaner 3D position in the robot (meters) pose_y=0 pose_z=0.34 pose_yaw=0 ; Angles in degrees pose_pitch=0 pose_roll=0
This class doesn’t configure the SICK LMS sensor, it is recommended to configure the sensor via the the SICK software : SOPAS. This class was contributed by Adrien Barral - Robopec (France)
#include <mrpt/hwdrivers/CLMS100eth.h> class CLMS100Eth: public mrpt::hwdrivers::C2DRangeFinderAbstract { public: // construction CLMS100Eth(std::string _ip = std::string("192.168.0.1"), unsigned int _port = 2111); // methods virtual void doProcessSimple( bool& outThereIsObservation, mrpt::obs::CObservation2DRangeScan& outObservation, bool& hardwareError ); virtual bool turnOn(); virtual bool turnOff(); void setSensorPose(const mrpt::poses::CPose3D& _pose); virtual void doProcess(); virtual void initialize(); };
Inherited Members
public: // enums enum TSensorState; // structs struct TMsg; // fields bool logging_enable_console_output {true}; bool logging_enable_keep_record {false}; // methods COutputLogger& operator = (const COutputLogger&); COutputLogger& operator = (COutputLogger&&); CGenericSensor& operator = (const CGenericSensor&); virtual void doProcess() = 0; 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; 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(); bool logDeregisterCallback(output_logger_callback_t userFunc); 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; TSensorState getState() const; void enableVerbose(bool enabled = true); virtual void loadConfig(const mrpt::config::CConfigFileBase& configSource, const std::string& section); virtual void initialize(); virtual TListObservations getObservations(); virtual void setPathForExternalImages(] const std::string& directory); virtual void setExternalImageFormat(const std::string& ext); virtual void setExternalImageJPEGQuality(const unsigned int quality); static const std::array<const char*, NUMBER_OF_VERBOSITY_LEVELS>& logging_levels_to_names(); static void registerClass(const TSensorClassId* pNewClass); static CGenericSensor* createSensor(const std::string& className); static Ptr createSensorPtr(const std::string& className);
Construction
CLMS100Eth( std::string _ip = std::string("192.168.0.1"), unsigned int _port = 2111 )
Constructor.
Parameters:
_ip |
IPv4 address of the LMS100 (default “192.168.0.1”). |
_port |
TCP port on the device (default 2111). |
Methods
virtual void doProcessSimple( bool& outThereIsObservation, mrpt::obs::CObservation2DRangeScan& outObservation, bool& hardwareError )
Acquires one laser scan from the device.
Parameters:
outThereIsObservation |
Set to true when a valid scan is ready. |
outObservation |
Filled with the new scan on success. |
hardwareError |
Set to true on communication failure. |
std::exception |
If the received frame has an unexpected status or unsupported data channel (e.g. RSSI instead of DIST1). |
virtual bool turnOn()
Opens the TCP connection and starts the measurement stream.
Must be called before requesting any laser scans.
Returns:
true on success, false on error.
virtual bool turnOff()
Stops measurement and closes the TCP connection.
Also called automatically by the destructor.
Returns:
true on success, false on error.
void setSensorPose(const mrpt::poses::CPose3D& _pose)
Sets the 3-D pose of the sensor on the robot.
A method to set the sensor pose on the robot.
Equivalent to loading the pose from a configuration file.
Parameters:
_pose |
The sensor pose in robot coordinates. |
virtual void doProcess()
Periodic processing step (called at process_rate Hz).
Internally calls doProcessSimple() and queues the resulting observation.
virtual void initialize()
Initializes the sensor using parameters loaded from a config file.
Parameters:
std::exception |
On failure to connect or configure the device. |