class mrpt::hwdrivers::CLMS100Eth

Overview

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

    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 showPreview(bool enable = true);
    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 std::array<mrpt::system::ConsoleForegroundColor, NUMBER_OF_VERBOSITY_LEVELS>& logging_levels_to_colors();
    static std::array<std::string, 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.

Note that there is default arguments, here you can customize IP Adress and TCP Port of your device.

Methods

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

This function acquire a laser scan from the device.

If an error occurred, hardwareError will be set to true. The new laser scan will be stored in the outObservation argument.

Parameters:

This

method throw exception if the frame received from the LMS 100 contain the following bad parameters :

  • Status is not OK

  • Data in the scan aren’t DIST1 (may be RSSIx or DIST2).

virtual bool turnOn()

This method must be called before trying to get a laser scan.

virtual bool turnOff()

This method could be called manually to stop communication with the device.

Method is also called by destructor.

void setSensorPose(const mrpt::poses::CPose3D& _pose)

A method to set the sensor pose on the robot.

Equivalent to setting the sensor pose via loading it from a config file.

virtual void doProcess()

This method should be called periodically.

Period depend on the process_rate in the configuration file.

virtual void initialize()

Initialize the sensor according to the parameters previously read in the configuration file.