Robotics Library  0.7.0
LeuzeRs4.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_LEUZERS4_H
28 #define RL_HAL_LEUZERS4_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 LeuzeRs4 : public CyclicDevice, public Lidar
46  {
47  public:
48  enum BaudRate
49  {
66  };
67 
71  LeuzeRs4(
72  const ::std::string& device = "/dev/ttyS0",
74  const ::std::string& password = "ROD4LE"
75  );
76 
77  virtual ~LeuzeRs4();
78 
79  void close();
80 
81  BaudRate getBaudRate() const;
82 
83  void getDistances(::rl::math::Vector& distances) const;
84 
85  ::std::size_t getDistancesCount() const;
86 
87  ::rl::math::Real getDistancesMaximum(const ::std::size_t& i) const;
88 
89  ::rl::math::Real getDistancesMinimum(const ::std::size_t& i) const;
90 
92 
94 
96 
97  void open();
98 
99  void reset();
100 
101 #if 0
102  void setBaudRate(const BaudRate& baudRate);
103 
104  void setOutputParameters(const ::std::uint16_t& startIndex, const ::std::uint16_t& stopIndex, const ::std::uint16_t& step, const ::std::uint16_t& type);
105 #endif
106 
107  void start();
108 
109  void step();
110 
111  void stop();
112 
113  protected:
114 
115  private:
116  ::std::uint8_t crc(const ::std::uint8_t* buf, const ::std::size_t& len) const;
117 
118  const ::std::uint8_t& get(const ::std::uint8_t*& ptr) const;
119 
120  ::std::size_t recv(uint8_t* buf, const ::std::size_t& len);
121 
122  void send(uint8_t* buf, const ::std::size_t& len);
123 
124  void set(const ::std::uint8_t& value, ::std::uint8_t*& ptr, ::std::size_t& len) const;
125 
127 
128  ::std::array< ::std::uint8_t, 1099> data;
129 
131 
132  bool far1;
133 
134  bool far2;
135 
136  bool fn1Fn2;
137 
138  bool near1;
139 
140  bool near2;
141 
142  ::std::string password;
143 
145 
146  ::std::uint16_t startIndex;
147 
148  ::std::uint16_t stepSize;
149 
150  ::std::uint16_t stopIndex;
151 
152  ::std::uint16_t type;
153  };
154  }
155 }
156 
157 #endif // RL_HAL_LEUZERS4_H
rl::hal::LeuzeRs4::send
void send(uint8_t *buf, const ::std::size_t &len)
Definition: LeuzeRs4.cpp:494
rl::hal::LeuzeRs4::far1
bool far1
Definition: LeuzeRs4.h:132
rl::hal::LeuzeRs4::password
::std::string password
Definition: LeuzeRs4.h:142
rl::hal::LeuzeRs4::stepSize
::std::uint16_t stepSize
Definition: LeuzeRs4.h:148
rl::hal::LeuzeRs4::LeuzeRs4
LeuzeRs4(const ::std::string &device="/dev/ttyS0", const BaudRate &baudRate=BAUDRATE_57600BPS, const ::std::string &password="ROD4LE")
Definition: LeuzeRs4.cpp:40
Serial.h
rl::hal::LeuzeRs4::~LeuzeRs4
virtual ~LeuzeRs4()
Definition: LeuzeRs4.cpp:72
rl::hal::LeuzeRs4::data
::std::array< ::std::uint8_t, 1099 > data
Definition: LeuzeRs4.h:128
rl::hal::LeuzeRs4::near1
bool near1
Definition: LeuzeRs4.h:138
rl::hal::LeuzeRs4::BAUDRATE_115200BPS
@ BAUDRATE_115200BPS
115,200 bps.
Definition: LeuzeRs4.h:61
rl::hal::LeuzeRs4::set
void set(const ::std::uint8_t &value, ::std::uint8_t *&ptr, ::std::size_t &len) const
Definition: LeuzeRs4.cpp:528
rl::math::Vector
::Eigen::Matrix< Real, ::Eigen::Dynamic, 1 > Vector
Definition: Vector.h:42
rl::hal::LeuzeRs4::serial
Serial serial
Definition: LeuzeRs4.h:144
rl::hal::LeuzeRs4::stop
void stop()
Definition: LeuzeRs4.cpp:717
rl::hal::LeuzeRs4::BAUDRATE_345600BPS
@ BAUDRATE_345600BPS
345,600 bps.
Definition: LeuzeRs4.h:63
rl::hal::LeuzeRs4::BaudRate
BaudRate
Definition: LeuzeRs4.h:49
rl::hal::LeuzeRs4::open
void open()
Definition: LeuzeRs4.cpp:237
rl::hal::LeuzeRs4::getStartAngle
::rl::math::Real getStartAngle() const
Definition: LeuzeRs4.cpp:221
rl::hal::Lidar
Definition: Lidar.h:37
rl::hal::LeuzeRs4::startIndex
::std::uint16_t startIndex
Definition: LeuzeRs4.h:146
rl::hal::LeuzeRs4::getBaudRate
BaudRate getBaudRate() const
Definition: LeuzeRs4.cpp:132
rl::hal::Serial
Definition: Serial.h:48
rl::hal::CyclicDevice
Definition: CyclicDevice.h:39
rl::hal::LeuzeRs4::baudRate
BaudRate baudRate
Definition: LeuzeRs4.h:126
rl::hal::LeuzeRs4::stopIndex
::std::uint16_t stopIndex
Definition: LeuzeRs4.h:150
rl::hal::LeuzeRs4::BAUDRATE_9600BPS
@ BAUDRATE_9600BPS
9,600 bps.
Definition: LeuzeRs4.h:53
rl::hal::LeuzeRs4::getStopAngle
::rl::math::Real getStopAngle() const
Definition: LeuzeRs4.cpp:229
rl::hal::LeuzeRs4::getDistancesCount
::std::size_t getDistancesCount() const
Definition: LeuzeRs4.cpp:189
rl::hal::LeuzeRs4::reset
void reset()
Definition: LeuzeRs4.cpp:457
Device.h
rl::hal::LeuzeRs4::BAUDRATE_19200BPS
@ BAUDRATE_19200BPS
19,200 bps.
Definition: LeuzeRs4.h:55
rl::hal::RangeSensor::getDistances
virtual ::rl::math::Vector getDistances() const =0
rl::hal::LeuzeRs4::crc
::std::uint8_t crc(const ::std::uint8_t *buf, const ::std::size_t &len) const
Definition: LeuzeRs4.cpp:97
rl::hal::LeuzeRs4
Leuze RS4 safety laser scanner.
Definition: LeuzeRs4.h:46
rl::hal::LeuzeRs4::fn1Fn2
bool fn1Fn2
Definition: LeuzeRs4.h:136
rl::hal::LeuzeRs4::type
::std::uint16_t type
Definition: LeuzeRs4.h:152
rl::hal::LeuzeRs4::desired
BaudRate desired
Definition: LeuzeRs4.h:130
CyclicDevice.h
rl::hal::LeuzeRs4::far2
bool far2
Definition: LeuzeRs4.h:134
rl::hal::LeuzeRs4::step
void step()
Definition: LeuzeRs4.cpp:694
rl::hal::LeuzeRs4::BAUDRATE_57600BPS
@ BAUDRATE_57600BPS
57,600 bps.
Definition: LeuzeRs4.h:59
rl::hal::LeuzeRs4::BAUDRATE_625000BPS
@ BAUDRATE_625000BPS
625,000 bps.
Definition: LeuzeRs4.h:65
rl::hal::LeuzeRs4::getResolution
::rl::math::Real getResolution() const
Definition: LeuzeRs4.cpp:213
rl::hal::LeuzeRs4::getDistancesMaximum
::rl::math::Real getDistancesMaximum(const ::std::size_t &i) const
Definition: LeuzeRs4.cpp:197
Lidar.h
rl::math::Real
double Real
Definition: Real.h:42
rl::hal::LeuzeRs4::start
void start()
Definition: LeuzeRs4.cpp:688
rl::hal::LeuzeRs4::get
const ::std::uint8_t & get(const ::std::uint8_t *&ptr) const
Definition: LeuzeRs4.cpp:115
rl::hal::LeuzeRs4::close
void close()
Definition: LeuzeRs4.cpp:77
rl::hal::LeuzeRs4::getDistancesMinimum
::rl::math::Real getDistancesMinimum(const ::std::size_t &i) const
Definition: LeuzeRs4.cpp:205
rl::hal::LeuzeRs4::near2
bool near2
Definition: LeuzeRs4.h:140
rl::hal::LeuzeRs4::recv
::std::size_t recv(uint8_t *buf, const ::std::size_t &len)
Definition: LeuzeRs4.cpp:342
rl::hal::LeuzeRs4::BAUDRATE_38400BPS
@ BAUDRATE_38400BPS
38,400 bps.
Definition: LeuzeRs4.h:57
rl::hal::LeuzeRs4::BAUDRATE_4800BPS
@ BAUDRATE_4800BPS
4,800 bps.
Definition: LeuzeRs4.h:51
rl
Robotics Library.
Definition: AnalogInput.cpp:30