INTRODUCTION
Overview
Download and Install
Documentation
Publications

REPOSITORY
Libraries

DEVELOPER
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         
messages.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 SICK_ACFR_DRIVER_MESSAGES_H
12#define SICK_ACFR_DRIVER_MESSAGES_H
13
14#include <string>
15#include <vector>
16#include <gbxsickacfr/sickdefines.h>
17#include <gbxsickacfr/gbxserialdeviceacfr/gbxserialdeviceacfr.h>
18
19namespace gbxsickacfr {
20
21 std::string toHexString( const uChar *buf, int bufLen );
22 inline std::string toHexString( const std::vector<uChar> &buf )
23 {return toHexString( &(buf[0]), buf.size() );}
24
26 // Generic LMS RxMsg classes:
27 //
28 // - The SICK replies to commands with rxMsgs.
29 // - RxMsgs are of a standard format, but some rxMsgs contain
30 // extra rxMsg-type-specific data.
31 // - This is handled with the abstract class 'LmsRxMsgData':
32 // - The LmsRxMsg has a pointer to LmsRxMsgData, which should
33 // be cast to the appropriate type depending on the rxMsg type.
34 //
35 // (Note that in continuous mode, the measurements continuously
36 // sent out by the SICK are 'rxMsgs', even though there's no command).
37 //
39
40 // Abstract class for representing rxMsg-type-specific data.
41 class LmsRxMsgData : public IceUtil::Shared {
42 public:
43 virtual ~LmsRxMsgData() {}
44
45 // human-readable string
46 virtual std::string toString() const=0;
47
48 virtual bool isError() const { return false; }
49 virtual bool isWarn() const { return false; }
50
51 // Returns a freshly allocated object of the same type
52 //virtual LmsRxMsgData *clone() const=0;
53 };
54 typedef IceUtil::Handle<LmsRxMsgData> LmsRxMsgDataPtr;
55
56 // This class represents rxMsgs which the SICK uses to reply to commands.
57 // All rxMsg types have the information in this class.
58 // Some rxMsgs also have extra data, which is stored in the 'data' member.
59 class LmsRxMsg : public gbxserialdeviceacfr::RxMsg {
60 public:
61 LmsRxMsg()
62 : status(0),
63 data(NULL)
64 {}
65 // ~LmsRxMsg()
66 // { if (data) delete data; }
67
68 // private:
69 // LmsRxMsg( const LmsRxMsg &other );
70 // LmsRxMsg &operator=( const LmsRxMsg &other );
71 // public:
72
73 uChar type;
74 uChar status;
75 LmsRxMsgDataPtr data;
76
77 bool isError() const;
78 bool isWarn() const;
79
80 std::string toString() const;
81 };
82 std::string toString( const LmsRxMsg &r );
83 typedef IceUtil::Handle<LmsRxMsg> LmsRxMsgPtr;
84 inline std::string toString( const LmsRxMsgPtr &r )
85 { return toString(*r); }
86
88 // RxMsg-specific data classes
89 //
90 // - The set of classes below all inherit from the abstract
91 // 'LmsRxMsgData' class. They represent the data contained
92 // in specific rxMsg types.
93 // - See 'parseRxMsg' in the .cpp file for details of which
94 // classes go with which rxMsg codes.
95 //
97
98 class LmsInitRxMsgData : public LmsRxMsgData {
99 public:
100 std::string description;
101
102 std::string toString() const { return description; }
103 LmsRxMsgData *clone() const { return new LmsInitRxMsgData(*this); }
104 };
105
106 class LmsStatusRxMsgData : public LmsRxMsgData {
107 public:
108 std::string version;
109 uChar operatingMode;
110 uChar status;
111 std::string manufacturer;
112 uChar variantType;
113 uint16_t pollution[POLLUTION_LENGTH];
114 uint16_t refPollution[REF_POLLUTION_LENGTH];
115 uint16_t calibPollution[CALIB_POLLUTION_LENGTH];
116 uint16_t calibRefPollution[CALIB_REF_POLLUTION_LENGTH];
117 uint16_t numMotorRevolutions;
118 uint16_t refScale1Dark100Pct;
119 uint16_t refScale2Dark100Pct;
120 uint16_t refScale1Dark66Pct;
121 uint16_t refScale2Dark66Pct;
122 uint16_t signalAmplitudePct;
123 uint16_t currentAngle;
124 uint16_t peakThreshold;
125 uint16_t angleOfMeasurement;
126 uint16_t calibSignalAmplitude;
127 uint16_t targetStopThreshold;
128 uint16_t targetPeakThreshold;
129 uint16_t actualStopThreshold;
130 uint16_t actualPeakThreshold;
131 uChar measuringMode;
132 uint16_t refSingleMeasuredValues;
133 uint16_t refMeanMeasuredValues;
134 uint16_t scanningAngle;
135 uint16_t angularResolution;
136 uChar restartMode;
137 uChar restartTime;
138 uint16_t baudRate;
139 uChar evaluationNumber;
140 uChar permanentBaudRate;
141 uChar lmsAddress;
142 uChar fieldSetNumber;
143 uChar currentMeasuredValueUnit;
144 uChar laserSwitchOff;
145 std::string softwareVersion;
146
147 std::string toString() const;
148 LmsRxMsgData *clone() const { return new LmsStatusRxMsgData(*this); }
149 };
150
151 class LmsSwitchOperatingModeRxMsgData : public LmsRxMsgData {
152 public:
153 uChar success;
154
155 bool isError() const { return success != OPERATING_MODE_RESPONSE_SUCCESS; }
156 std::string toString() const { return modeSwitchSuccessToString(success); }
157 LmsRxMsgData *clone() const { return new LmsSwitchOperatingModeRxMsgData(*this); }
158 };
159
160 class LmsConfigurationData : public LmsRxMsgData {
161 public:
162
163 // Default values for all these fuckers
164 LmsConfigurationData();
165 bool operator==( const LmsConfigurationData &o ) const;
166 bool operator!=( const LmsConfigurationData &o ) const
167 { return !(operator==(o)); }
168
169 uint16_t blanking;
170 uChar sensitivity;
171 uChar availability;
172 uChar measuringMode;
173 uChar measuredValueUnit;
174 uChar transientFieldSet;
175 uChar subtractiveFields; // 14
176 uChar multipleEvaluation;
177 uChar restart;
178 uChar restartTime;
179 uChar multipleEvaluationForSuppressed;
180 uChar contourARef;
181 uChar contourAPosToleranceBand; // 20
182 uChar contourANegToleranceBand;
183 uChar contourAStartAngle;
184 uChar contourAStopAngle;
185 uChar contourBRef;
186 uChar contourBPosToleranceBand;
187 uChar contourBNegToleranceBand;
188 uChar contourBStartAngle;
189 uChar contourBStopAngle;
190 uChar contourARef2;
191 uChar contourAPosToleranceBand2; // 30
192 uChar contourCNegToleranceBand;
193 uChar contourCStartAngle;
194 uChar contourCStopAngle;
195 uChar pixelOrientedEvaluation;
196 uChar singleMeasuredValueEvaluation;
197 uint16_t restartTimeFields;
198 uint16_t multipleEvaluationForDazzle;
199
200 std::string toString() const;
201 LmsRxMsgData *clone() const { return new LmsConfigurationData(*this); }
202 };
203
204 class LmsConfigurationRxMsgData : public LmsRxMsgData {
205 public:
206 LmsConfigurationData config;
207 uChar configSuccess;
208
209 std::string toString() const;
210 LmsRxMsgData *clone() const { return new LmsConfigurationRxMsgData(*this); }
211 bool isError() const { return configSuccess != CONFIGURATION_SUCCESS; }
212 };
213
214 class LmsSwitchVariantRxMsgData : public LmsRxMsgData {
215 public:
216 uChar success;
217 uint16_t scanningAngle;
218 uint16_t angularResolution;
219
220 std::string toString() const;
221 LmsRxMsgData *clone() const { return new LmsSwitchVariantRxMsgData(*this); }
222 bool isError() const { return success != SWITCH_VARIANT_SUCCESS; }
223 };
224
225 class LmsMeasurementData : public LmsRxMsgData {
226 public:
227
228 // ranges in metres
229 std::vector<float> ranges;
230 std::vector<uChar> intensities;
231
232 std::string toString() const;
233 LmsRxMsgData *clone() const { return new LmsMeasurementData(*this); }
234 };
235
236 class LmsErrorRxMsgData : public LmsRxMsgData {
237 public:
238
239 std::vector<uChar> errorTypes;
240 std::vector<uChar> errorCodes;
241
242 std::string toString() const;
243 LmsRxMsgData *clone() const { return new LmsErrorRxMsgData(*this); }
244 bool isError() const;
245 bool isWarn() const;
246 };
247
248 class LmsOperatingDataCounterData : public LmsRxMsgData {
249 public:
250
251 int hoursOfOperation;
252 int numSwitchOns;
253
254 std::string toString() const;
255 LmsRxMsgData *clone() const { return new LmsOperatingDataCounterData(*this); }
256 };
257
259
260 // If a complete telegram was found, returns it
261 // (also sets bytesParsed regardless of whether a complete message was found)
262 LmsRxMsgPtr parseBufferForRxMsgs( const uChar *buffer,
263 int bufferLength,
264 int &bytesParsed );
265
266 void constructTelegram( std::vector<uChar> &buffer,
267 const std::vector<uChar> &commandAndData );
268
269 // SICK parameters can be changed in installation mode.
270 void constructRequestInstallationMode( std::vector<uChar> &commandAndData );
271
272 void constructRequestContinuousMode( std::vector<uChar> &commandAndData );
273 void constructRequestMeasuredOnRequestMode( std::vector<uChar> &commandAndData );
274
275 void constructInitAndReset( std::vector<uChar> &commandAndData );
276
277 void constructStatusRequest( std::vector<uChar> &commandAndData );
278
279 void constructConfigurationRequest( std::vector<uChar> &commandAndData );
280
281 void constructConfigurationCommand( const LmsConfigurationData &c,
282 std::vector<uChar> &commandAndData );
283
284 void constructRequestErrorMessage( std::vector<uChar> &commandAndData );
285
286 void constructSwitchVariant( uint16_t scanningAngle,
287 uint16_t angularResolution,
288 std::vector<uChar> &commandAndData );
289
290 void constructRequestOperatingDataCounter( std::vector<uChar> &commandAndData );
291
292 void constructRequestBaudRate( std::vector<uChar> &commandAndData, int baudRate );
293}
294
295#endif
A base-class for a message received from the device on the other end.
Definition: serialdevicehandler.h:23
SICK laser driver.
 

Generated for GearBox by  doxygen 1.4.5