Robotics Library  0.6.2
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 <rl/util/Timer.h>
31 
32 #include "Device.h"
33 #include "Lidar.h"
34 #include "types.h"
35 
36 namespace rl
37 {
38  namespace hal
39  {
40  class Serial;
41 
42  class LeuzeRs4 : public Lidar
43  {
44  public:
45  enum BaudRate
46  {
63  };
64 
68  LeuzeRs4(
69  const ::std::string& device = "/dev/ttyS0",
71  const ::std::string& password = "ROD4LE"
72  );
73 
74  virtual ~LeuzeRs4();
75 
76  void close();
77 
78  BaudRate getBaudRate() const;
79 
80  void getDistances(::rl::math::Vector& distances) const;
81 
82  ::std::size_t getDistancesCount() const;
83 
84  ::rl::math::Real getDistancesMaximum(const ::std::size_t& i) const;
85 
86  ::rl::math::Real getDistancesMinimum(const ::std::size_t& i) const;
87 
89 
91 
93 
94  void open();
95 
96  void reset();
97 
98 #if 0
99  void setBaudRate(const BaudRate& baudRate);
100 
101  void setOutputParameters(const uint16_t& startIndex, const uint16_t& stopIndex, const uint16_t& step, const uint16_t& type);
102 #endif
103 
104  void start();
105 
106  void step();
107 
108  void stop();
109 
110  protected:
111 
112  private:
113  uint8_t crc(const uint8_t* buf, const ::std::size_t& len) const;
114 
115  ::std::size_t recv(uint8_t* buf, const ::std::size_t& len);
116 
117  void send(uint8_t* buf, const ::std::size_t& len);
118 
120 
121  uint8_t data[1099];
122 
124 
125  bool far1;
126 
127  bool far2;
128 
129  bool fn1Fn2;
130 
131  bool near1;
132 
133  bool near2;
134 
135  ::std::string password;
136 
138 
139  uint16_t startIndex;
140 
141  uint16_t stepSize;
142 
143  uint16_t stopIndex;
144 
146 
147  uint16_t type;
148  };
149  }
150 }
151 
152 #endif // _RL_HAL_LEUZERS4_H_
rl::hal::LeuzeRs4::send
void send(uint8_t *buf, const ::std::size_t &len)
Definition: LeuzeRs4.cpp:516
rl::hal::LeuzeRs4::far1
bool far1
Definition: LeuzeRs4.h:125
rl::hal::LeuzeRs4::type
uint16_t type
Definition: LeuzeRs4.h:147
rl::hal::LeuzeRs4::stopIndex
uint16_t stopIndex
Definition: LeuzeRs4.h:143
rl::hal::LeuzeRs4::getDistances
void getDistances(::rl::math::Vector &distances) const
Definition: LeuzeRs4.cpp:160
rl::hal::LeuzeRs4::data
uint8_t data[1099]
Definition: LeuzeRs4.h:121
types.h
rl::hal::LeuzeRs4::password
::std::string password
Definition: LeuzeRs4.h:135
rl::hal::LeuzeRs4::LeuzeRs4
LeuzeRs4(const ::std::string &device="/dev/ttyS0", const BaudRate &baudRate=BAUDRATE_57600BPS, const ::std::string &password="ROD4LE")
Definition: LeuzeRs4.cpp:76
rl::hal::LeuzeRs4::crc
uint8_t crc(const uint8_t *buf, const ::std::size_t &len) const
Definition: LeuzeRs4.cpp:136
rl::hal::LeuzeRs4::~LeuzeRs4
virtual ~LeuzeRs4()
Definition: LeuzeRs4.cpp:110
rl::hal::LeuzeRs4::near1
bool near1
Definition: LeuzeRs4.h:131
rl::hal::LeuzeRs4::BAUDRATE_115200BPS
@ BAUDRATE_115200BPS
115,200 bps.
Definition: LeuzeRs4.h:58
rl::hal::LeuzeRs4::stop
void stop()
Definition: LeuzeRs4.cpp:724
rl::hal::LeuzeRs4::BAUDRATE_345600BPS
@ BAUDRATE_345600BPS
345,600 bps.
Definition: LeuzeRs4.h:60
rl::hal::LeuzeRs4::BaudRate
BaudRate
Definition: LeuzeRs4.h:46
rl::hal::LeuzeRs4::open
void open()
Definition: LeuzeRs4.cpp:259
rl::hal::LeuzeRs4::getStartAngle
::rl::math::Real getStartAngle() const
Definition: LeuzeRs4.cpp:243
Timer.h
rl::hal::Lidar
Definition: Lidar.h:37
rl::hal::LeuzeRs4::getBaudRate
BaudRate getBaudRate() const
Definition: LeuzeRs4.cpp:154
rl::hal::Serial
Definition: Serial.h:46
rl::hal::LeuzeRs4::baudRate
BaudRate baudRate
Definition: LeuzeRs4.h:119
rl::hal::LeuzeRs4::BAUDRATE_9600BPS
@ BAUDRATE_9600BPS
9,600 bps.
Definition: LeuzeRs4.h:50
rl::hal::LeuzeRs4::getStopAngle
::rl::math::Real getStopAngle() const
Definition: LeuzeRs4.cpp:251
rl::hal::LeuzeRs4::getDistancesCount
::std::size_t getDistancesCount() const
Definition: LeuzeRs4.cpp:211
rl::hal::LeuzeRs4::reset
void reset()
Definition: LeuzeRs4.cpp:479
Device.h
rl::hal::LeuzeRs4::BAUDRATE_19200BPS
@ BAUDRATE_19200BPS
19,200 bps.
Definition: LeuzeRs4.h:52
rl::hal::LeuzeRs4
Definition: LeuzeRs4.h:43
rl::hal::LeuzeRs4::fn1Fn2
bool fn1Fn2
Definition: LeuzeRs4.h:129
rl::hal::LeuzeRs4::timer
::rl::util::Timer timer
Definition: LeuzeRs4.h:145
rl::hal::LeuzeRs4::desired
BaudRate desired
Definition: LeuzeRs4.h:123
rl::hal::LeuzeRs4::serial
Serial * serial
Definition: LeuzeRs4.h:137
rl::hal::LeuzeRs4::far2
bool far2
Definition: LeuzeRs4.h:127
rl::math::Vector
::Eigen::Matrix< Real, ::Eigen::Dynamic, 1 > Vector
Definition: Vector.h:41
rl::hal::LeuzeRs4::step
void step()
Definition: LeuzeRs4.cpp:701
rl::hal::LeuzeRs4::BAUDRATE_57600BPS
@ BAUDRATE_57600BPS
57,600 bps.
Definition: LeuzeRs4.h:56
rl::hal::LeuzeRs4::BAUDRATE_625000BPS
@ BAUDRATE_625000BPS
625,000 bps.
Definition: LeuzeRs4.h:62
rl::hal::LeuzeRs4::getResolution
::rl::math::Real getResolution() const
Definition: LeuzeRs4.cpp:235
rl::util::Timer
Definition: Timer.h:46
rl::hal::LeuzeRs4::stepSize
uint16_t stepSize
Definition: LeuzeRs4.h:141
rl::hal::LeuzeRs4::getDistancesMaximum
::rl::math::Real getDistancesMaximum(const ::std::size_t &i) const
Definition: LeuzeRs4.cpp:219
Lidar.h
rl::math::Real
double Real
Definition: Real.h:34
rl::hal::LeuzeRs4::start
void start()
Definition: LeuzeRs4.cpp:695
rl::hal::LeuzeRs4::close
void close()
Definition: LeuzeRs4.cpp:116
rl::hal::LeuzeRs4::getDistancesMinimum
::rl::math::Real getDistancesMinimum(const ::std::size_t &i) const
Definition: LeuzeRs4.cpp:227
rl::hal::LeuzeRs4::near2
bool near2
Definition: LeuzeRs4.h:133
rl::hal::LeuzeRs4::recv
::std::size_t recv(uint8_t *buf, const ::std::size_t &len)
Definition: LeuzeRs4.cpp:364
rl::hal::LeuzeRs4::startIndex
uint16_t startIndex
Definition: LeuzeRs4.h:139
rl::hal::LeuzeRs4::BAUDRATE_38400BPS
@ BAUDRATE_38400BPS
38,400 bps.
Definition: LeuzeRs4.h:54
rl::hal::LeuzeRs4::BAUDRATE_4800BPS
@ BAUDRATE_4800BPS
4,800 bps.
Definition: LeuzeRs4.h:48
rl
Definition: Ati.cpp:35