INTRODUCTION
Overview
Download and Install
Documentation
Publications

REPOSITORY
Libraries

DEVELOPER
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         
gbxsickacfr/driver.h
1 /*
2  * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics
3  * http://gearbox.sf.net/
4  * Copyright (c) 2004-2010 Alex Brooks
5  *
6  * This distribution is licensed to you under the terms described in
7  * the LICENSE file included in this distribution.
8  *
9  */
10 
11 #ifndef GBX_SICK_ACFR_H
12 #define GBX_SICK_ACFR_H
13 
14 #include <gbxsickacfr/serialhandler.h>
15 #include <gbxutilacfr/tracer.h>
16 #include <gbxutilacfr/status.h>
17 #include <memory>
18 
19 namespace gbxsickacfr {
20 
22 class Config
23 {
24 public:
25  Config();
26  bool isValid() const;
27  std::string toString() const;
28  bool operator==( const Config & other );
29  bool operator!=( const Config & other );
30 
32  std::string device;
34  int baudRate;
36  double minRange;
38  double maxRange;
40  double fieldOfView;
42  double startAngle;
45 };
46 
48 class Data
49 {
50 public:
51  Data()
52  : haveWarnings(false)
53  {}
54 
55  float *ranges;
56  unsigned char *intensities;
57  int timeStampSec;
58  int timeStampUsec;
59  bool haveWarnings;
61  std::string warnings;
62 };
63 
65 class Driver
66 {
67 
68 public:
69 
75  Driver( const Config &config,
76  gbxutilacfr::Tracer &tracer,
77  gbxutilacfr::Status &status );
78 
86  void read( Data &data );
87 
88 private:
89 
90  // Waits up to maxWaitMs for a rxMsg of a particular type.
91  // Returns true iff it got the rxMsg it wanted.
92  bool waitForRxMsgType( uChar type, TimedLmsRxMsg &rxMsg, int maxWaitMs );
93  // Returns: true if ack or nack received.
94  // (and sets receivedAck: true = ACK, false=NACK)
95  bool waitForAckOrNack( bool &receivedAck );
96 
97  LmsRxMsgPtr askLaserForStatusData();
98  LmsRxMsgPtr askLaserForConfigData();
99 
100  LmsConfigurationData desiredConfiguration();
101  bool isAsDesired( const LmsConfigurationData &lmsConfig );
102 
103  int guessLaserBaudRate();
104 
105  // Connects to the laser, sets params, and starts continuous mode.
106  void initLaser();
107 
108  TimedLmsRxMsg sendAndExpectRxMsg( const std::vector<uChar> &commandAndData,
109  bool ignoreErrorConditions=false );
110 
111  std::string errorConditions();
112 
113  uChar desiredMeasuredValueUnit();
114  uint16_t desiredAngularResolution();
115 
116  void setBaudRate( int baudRate );
117 
118  Config config_;
119 
120  std::auto_ptr<SerialHandler> serialHandler_;
121 
122  std::vector<uChar> commandAndData_;
123  std::vector<uChar> telegramBuffer_;
124 
125  gbxutilacfr::Tracer& tracer_;
126  gbxutilacfr::Status& status_;
127 };
128 
129 } // namespace
130 
131 #endif
SICK laser driver.
Data structure returned by read()
Definition: gbxsickacfr/driver.h:48
double maxRange
maximum range [m]
Definition: gbxsickacfr/driver.h:38
double minRange
minimum range [m]
Definition: gbxsickacfr/driver.h:36
double startAngle
starting angle [rad]
Definition: gbxsickacfr/driver.h:42
Configuration structure.
Definition: gbxsickacfr/driver.h:22
double fieldOfView
field of viewe [rad]
Definition: gbxsickacfr/driver.h:40
Local and remote tracing.
Definition: tracer.h:111
std::string device
Serial device. e.g. "/dev/ttyS0".
Definition: gbxsickacfr/driver.h:32
SICK driver.
Definition: gbxsickacfr/driver.h:65
int baudRate
Baud rate.
Definition: gbxsickacfr/driver.h:34
Local interface to component status.
Definition: status.h:253
std::string warnings
if &#39;haveWarnings&#39; is set, &#39;warnings&#39; will contain diagnostic information.
Definition: gbxsickacfr/driver.h:61
int numberOfSamples
number of samples in a scan
Definition: gbxsickacfr/driver.h:44
 

Generated for GearBox by  doxygen 1.4.5