Robotics Library  0.7.0
SickLms200.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2009, Markus Rickert
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // * Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright notice,
11 // this list of conditions and the following disclaimer in the documentation
12 // and/or other materials provided with the distribution.
13 //
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 // POSSIBILITY OF SUCH DAMAGE.
25 //
26 
27 #ifndef RL_HAL_SICKLMS200_H
28 #define RL_HAL_SICKLMS200_H
29 
30 #include <array>
31 #include <cstdint>
32 
33 #include "CyclicDevice.h"
34 #include "Device.h"
35 #include "Lidar.h"
36 #include "Serial.h"
37 
38 namespace rl
39 {
40  namespace hal
41  {
45  class SickLms200 : public CyclicDevice, public Lidar
46  {
47  public:
48  enum BaudRate
49  {
55 #if defined(WIN32) || defined(__QNX__)
57 #else // defined(WIN32) || defined(__QNX__)
61 #endif // defined(WIN32) || defined(__QNX__)
62  };
63 
64  enum Measuring
65  {
72  };
73 
75  {
78  };
79 
80  enum Variant
81  {
92  };
93 
97  SickLms200(
98  const ::std::string& device = "/dev/ttyS0",
101  const Variant& variant = VARIANT_180_50,
103  const ::std::string& password = "SICK_LMS"
104  );
105 
106  virtual ~SickLms200();
107 
108  void close();
109 
110  void dumpConfiguration();
111 
112  void dumpStatus();
113 
114  BaudRate getBaudRate() const;
115 
117 
118  ::std::size_t getDistancesCount() const;
119 
120  ::rl::math::Real getDistancesMaximum(const ::std::size_t& i) const;
121 
122  ::rl::math::Real getDistancesMinimum(const ::std::size_t& i) const;
123 
124  Measuring getMeasuring() const;
125 
126  Monitoring getMonitoring() const;
127 
129 
131 
133 
134  ::std::string getType();
135 
136  Variant getVariant() const;
137 
138  void open();
139 
140  void reset();
141 
142  void setBaudRate(const BaudRate& baudRate);
143 
144  void setMeasuring(const Measuring& measuring);
145 
146  void setMonitoring(const Monitoring& monitoring);
147 
148  void setVariant(const Variant& variant);
149 
150  void start();
151 
152  void step();
153 
154  void stop();
155 
156  protected:
157 
158  private:
159  ::std::uint16_t crc(const ::std::uint8_t* buf, const ::std::size_t& len) const;
160 
161  ::std::size_t recv(::std::uint8_t* buf, const ::std::size_t& len, const ::std::uint8_t& command);
162 
163  void send(::std::uint8_t* buf, const ::std::size_t& len);
164 
165  bool waitAck();
166 
168 
169  ::std::uint8_t configuration;
170 
171  ::std::array< ::std::uint8_t, 812> data;
172 
174 
176 
178 
179  ::std::string password;
180 
182 
184  };
185  }
186 }
187 
188 #endif // RL_HAL_SICKLMS200_H
rl::hal::SickLms200::password
::std::string password
Definition: SickLms200.h:179
rl::hal::SickLms200::Monitoring
Monitoring
Definition: SickLms200.h:75
rl::hal::SickLms200::VARIANT_100_100
@ VARIANT_100_100
Angle = 100 degrees, resolution = 1 degree.
Definition: SickLms200.h:87
rl::hal::SickLms200::BAUDRATE_500000BPS
@ BAUDRATE_500000BPS
500,000 bps.
Definition: SickLms200.h:60
rl::hal::SickLms200::VARIANT_100_50
@ VARIANT_100_50
Angle = 100 degrees, resolution = 0.5 degrees.
Definition: SickLms200.h:85
rl::hal::SickLms200::getStartAngle
::rl::math::Real getStartAngle() const
Definition: SickLms200.cpp:558
rl::hal::SickLms200::variant
Variant variant
Definition: SickLms200.h:183
rl::hal::SickLms200::crc
::std::uint16_t crc(const ::std::uint8_t *buf, const ::std::size_t &len) const
Definition: SickLms200.cpp:106
rl::hal::SickLms200::measuring
Measuring measuring
Definition: SickLms200.h:175
Serial.h
rl::hal::SickLms200::MEASURING_320M
@ MEASURING_320M
Definition: SickLms200.h:71
rl::hal::SickLms200::VARIANT_180_100
@ VARIANT_180_100
Angle = 180 degrees, resolution = 1 degree.
Definition: SickLms200.h:91
rl::hal::SickLms200::getMeasuring
Measuring getMeasuring() const
Definition: SickLms200.cpp:517
rl::hal::SickLms200::getResolution
::rl::math::Real getResolution() const
Definition: SickLms200.cpp:533
rl::hal::SickLms200::MEASURING_32M
@ MEASURING_32M
Definition: SickLms200.h:68
rl::hal::SickLms200::MEASURING_16M
@ MEASURING_16M
Definition: SickLms200.h:67
rl::math::Vector
::Eigen::Matrix< Real, ::Eigen::Dynamic, 1 > Vector
Definition: Vector.h:42
rl::hal::SickLms200::setMonitoring
void setMonitoring(const Monitoring &monitoring)
Definition: SickLms200.cpp:1117
rl::hal::SickLms200::open
void open()
Definition: SickLms200.cpp:632
rl::hal::SickLms200::MEASURING_80M
@ MEASURING_80M
Definition: SickLms200.h:69
rl::hal::SickLms200::~SickLms200
virtual ~SickLms200()
Definition: SickLms200.cpp:71
rl::hal::SickLms200::getMonitoring
Monitoring getMonitoring() const
Definition: SickLms200.cpp:525
rl::hal::SickLms200::getDistancesCount
::std::size_t getDistancesCount() const
Definition: SickLms200.cpp:446
rl::hal::Lidar
Definition: Lidar.h:37
rl::hal::SickLms200::serial
Serial serial
Definition: SickLms200.h:181
rl::hal::SickLms200::getVariant
Variant getVariant() const
Definition: SickLms200.cpp:624
rl::hal::Serial
Definition: Serial.h:48
rl::hal::CyclicDevice
Definition: CyclicDevice.h:39
rl::hal::SickLms200::getDistances
::rl::math::Vector getDistances() const
Definition: SickLms200.cpp:299
rl::hal::SickLms200::MEASURING_160M
@ MEASURING_160M
Definition: SickLms200.h:70
rl::hal::SickLms200::Measuring
Measuring
Definition: SickLms200.h:65
rl::hal::SickLms200
Sick LMS 200 laser measurement system.
Definition: SickLms200.h:46
rl::hal::SickLms200::setBaudRate
void setBaudRate(const BaudRate &baudRate)
Definition: SickLms200.cpp:945
rl::hal::SickLms200::waitAck
bool waitAck()
Definition: SickLms200.cpp:1283
Device.h
rl::hal::SickLms200::monitoring
Monitoring monitoring
Definition: SickLms200.h:177
rl::hal::SickLms200::getBaudRate
BaudRate getBaudRate() const
Definition: SickLms200.cpp:293
rl::hal::SickLms200::SickLms200
SickLms200(const ::std::string &device="/dev/ttyS0", const BaudRate &baudRate=BAUDRATE_9600BPS, const Monitoring &monitoring=MONITORING_SINGLE, const Variant &variant=VARIANT_180_50, const Measuring &measuring=MEASURING_8M, const ::std::string &password="SICK_LMS")
Definition: SickLms200.cpp:41
rl::hal::SickLms200::VARIANT_100_25
@ VARIANT_100_25
Angle = 100 degrees, resolution = 0.25 degrees.
Definition: SickLms200.h:83
rl::hal::SickLms200::baudRate
BaudRate baudRate
Definition: SickLms200.h:167
rl::hal::SickLms200::BAUDRATE_19200BPS
@ BAUDRATE_19200BPS
19,200 bps.
Definition: SickLms200.h:53
rl::hal::SickLms200::BAUDRATE_9600BPS
@ BAUDRATE_9600BPS
9,600 bps.
Definition: SickLms200.h:51
rl::hal::SickLms200::BaudRate
BaudRate
Definition: SickLms200.h:49
rl::hal::SickLms200::VARIANT_180_50
@ VARIANT_180_50
Angle = 180 degrees, resolution = 0.5 degrees.
Definition: SickLms200.h:89
rl::hal::SickLms200::start
void start()
Definition: SickLms200.cpp:1222
rl::hal::SickLms200::getStopAngle
::rl::math::Real getStopAngle() const
Definition: SickLms200.cpp:581
rl::hal::SickLms200::configuration
::std::uint8_t configuration
Definition: SickLms200.h:169
rl::hal::SickLms200::getDistancesMaximum
::rl::math::Real getDistancesMaximum(const ::std::size_t &i) const
Definition: SickLms200.cpp:475
rl::hal::SickLms200::getType
::std::string getType()
Definition: SickLms200.cpp:604
rl::hal::SickLms200::BAUDRATE_38400BPS
@ BAUDRATE_38400BPS
38,400 bps.
Definition: SickLms200.h:58
rl::hal::SickLms200::close
void close()
Definition: SickLms200.cpp:76
rl::hal::SickLms200::setVariant
void setVariant(const Variant &variant)
Definition: SickLms200.cpp:1161
CyclicDevice.h
rl::hal::SickLms200::MEASURING_8M
@ MEASURING_8M
Definition: SickLms200.h:66
rl::hal::SickLms200::setMeasuring
void setMeasuring(const Measuring &measuring)
Definition: SickLms200.cpp:1019
rl::hal::SickLms200::stop
void stop()
Definition: SickLms200.cpp:1272
rl::hal::SickLms200::MONITORING_CONTINUOUS
@ MONITORING_CONTINUOUS
Definition: SickLms200.h:76
rl::hal::SickLms200::data
::std::array< ::std::uint8_t, 812 > data
Definition: SickLms200.h:171
rl::hal::SickLms200::step
void step()
Definition: SickLms200.cpp:1233
rl::hal::SickLms200::dumpStatus
void dumpStatus()
Definition: SickLms200.cpp:194
rl::hal::SickLms200::send
void send(::std::uint8_t *buf, const ::std::size_t &len)
Definition: SickLms200.cpp:918
rl::hal::SickLms200::dumpConfiguration
void dumpConfiguration()
Definition: SickLms200.cpp:129
rl::hal::SickLms200::recv
::std::size_t recv(::std::uint8_t *buf, const ::std::size_t &len, const ::std::uint8_t &command)
Definition: SickLms200.cpp:797
Lidar.h
rl::math::Real
double Real
Definition: Real.h:42
rl::hal::SickLms200::desired
BaudRate desired
Definition: SickLms200.h:173
rl::hal::SickLms200::reset
void reset()
Definition: SickLms200.cpp:896
rl::hal::SickLms200::getDistancesMinimum
::rl::math::Real getDistancesMinimum(const ::std::size_t &i) const
Definition: SickLms200.cpp:508
rl::hal::SickLms200::MONITORING_SINGLE
@ MONITORING_SINGLE
Definition: SickLms200.h:77
rl::hal::SickLms200::Variant
Variant
Definition: SickLms200.h:81
rl
Robotics Library.
Definition: AnalogInput.cpp:30