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
Definition: Lidar.h:36
void setBaudRate(const BaudRate &baudRate)
Definition: SickLms200.cpp:945
void close()
Definition: SickLms200.cpp:76
Definition: SickLms200.h:68
Sick LMS 200 laser measurement system.
Definition: SickLms200.h:45
::std::size_t recv(::std::uint8_t *buf, const ::std::size_t &len, const ::std::uint8_t &command)
Definition: SickLms200.cpp:797
Angle = 180 degrees, resolution = 0.5 degrees.
Definition: SickLms200.h:89
BaudRate
Definition: SickLms200.h:48
Angle = 100 degrees, resolution = 0.5 degrees.
Definition: SickLms200.h:85
::std::array< ::std::uint8_t, 812 > data
Definition: SickLms200.h:171
void setVariant(const Variant &variant)
Definition: SickLms200.cpp:1161
Definition: Serial.h:47
38,400 bps.
Definition: SickLms200.h:58
Measuring getMeasuring() const
Definition: SickLms200.cpp:517
Variant getVariant() const
Definition: SickLms200.cpp:624
Serial serial
Definition: SickLms200.h:181
::std::string getType()
Definition: SickLms200.cpp:604
Angle = 180 degrees, resolution = 1 degree.
Definition: SickLms200.h:91
500,000 bps.
Definition: SickLms200.h:60
double Real
Definition: Real.h:42
::rl::math::Real getStartAngle() const
Definition: SickLms200.cpp:558
::std::size_t getDistancesCount() const
Definition: SickLms200.cpp:446
Definition: SickLms200.h:66
Measuring
Definition: SickLms200.h:64
::rl::math::Real getResolution() const
Definition: SickLms200.cpp:533
Definition: SickLms200.h:69
Definition: CyclicDevice.h:38
void setMeasuring(const Measuring &measuring)
Definition: SickLms200.cpp:1019
BaudRate getBaudRate() const
Definition: SickLms200.cpp:293
::std::uint8_t configuration
Definition: SickLms200.h:169
::rl::math::Real getStopAngle() const
Definition: SickLms200.cpp:581
::Eigen::Matrix< Real, ::Eigen::Dynamic, 1 > Vector
Definition: Vector.h:42
void reset()
Definition: SickLms200.cpp:896
Angle = 100 degrees, resolution = 1 degree.
Definition: SickLms200.h:87
::std::string password
Definition: SickLms200.h:179
void open()
Definition: SickLms200.cpp:632
Angle = 100 degrees, resolution = 0.25 degrees.
Definition: SickLms200.h:83
void setMonitoring(const Monitoring &monitoring)
Definition: SickLms200.cpp:1117
bool waitAck()
Definition: SickLms200.cpp:1283
Robotics Library.
Definition: AnalogInput.cpp:29
Monitoring getMonitoring() const
Definition: SickLms200.cpp:525
BaudRate baudRate
Definition: SickLms200.h:167
::rl::math::Real getDistancesMinimum(const ::std::size_t &i) const
Definition: SickLms200.cpp:508
void stop()
Definition: SickLms200.cpp:1272
Variant variant
Definition: SickLms200.h:183
Definition: SickLms200.h:77
void start()
Definition: SickLms200.cpp:1222
void send(::std::uint8_t *buf, const ::std::size_t &len)
Definition: SickLms200.cpp:918
void dumpStatus()
Definition: SickLms200.cpp:194
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
Definition: SickLms200.h:70
Definition: SickLms200.h:71
::rl::math::Real getDistancesMaximum(const ::std::size_t &i) const
Definition: SickLms200.cpp:475
19,200 bps.
Definition: SickLms200.h:53
void step()
Definition: SickLms200.cpp:1233
::rl::math::Vector getDistances() const
Definition: SickLms200.cpp:299
Monitoring
Definition: SickLms200.h:74
Measuring measuring
Definition: SickLms200.h:175
Variant
Definition: SickLms200.h:80
Definition: SickLms200.h:67
void dumpConfiguration()
Definition: SickLms200.cpp:129
BaudRate desired
Definition: SickLms200.h:173
Monitoring monitoring
Definition: SickLms200.h:177
::std::uint16_t crc(const ::std::uint8_t *buf, const ::std::size_t &len) const
Definition: SickLms200.cpp:106
9,600 bps.
Definition: SickLms200.h:51
virtual ~SickLms200()
Definition: SickLms200.cpp:71