SickPLS.hh
Go to the documentation of this file.
1 
15 #ifndef SICK_PLS_HH
16 #define SICK_PLS_HH
17 
18 /* Implementation dependencies */
19 #include <string>
20 #include <iostream>
21 #include <termios.h>
22 
23 #include "SickLIDAR.hh"
24 #include "SickException.hh"
25 
26 #include "SickPLSBufferMonitor.hh"
27 #include "SickPLSMessage.hh"
28 
29 /* Macro definitions */
30 #define DEFAULT_SICK_PLS_SICK_BAUD (B500000)
31 #define DEFAULT_SICK_PLS_HOST_ADDRESS (0x80)
32 #define DEFAULT_SICK_PLS_SICK_ADDRESS (0x00)
33 #define DEFAULT_SICK_PLS_SICK_PASSWORD "SICK_PLS"
34 #define DEFAULT_SICK_PLS_SICK_MESSAGE_TIMEOUT (unsigned int)(20e6)
35 #define DEFAULT_SICK_PLS_SICK_SWITCH_MODE_TIMEOUT (unsigned int)(20e6)
36 #define DEFAULT_SICK_PLS_SICK_CONFIG_MESSAGE_TIMEOUT (unsigned int)(20e6)
37 #define DEFAULT_SICK_PLS_BYTE_INTERVAL (55)
38 //#define DEFAULT_SICK_PLS_BYTE_INTERVAL (0)
39 #define DEFAULT_SICK_PLS_NUM_TRIES (1)
40 
41 /* Associate the namespace */
42 namespace SickToolbox {
43 
50  class SickPLS : public SickLIDAR< SickPLSBufferMonitor, SickPLSMessage >
51  {
52 
53  public:
54 
56  /* TODO: I think this should be 180 * 2 */
57  static const uint16_t SICK_MAX_NUM_MEASUREMENTS = 721;
58 
59 
68  };
69 
78  };
79 
85 
86  /* Only in cm */
89  };
90 
96  SICK_STATUS_OK = 0x00,
99  };
100 
107 
128  };
129 
135  SICK_BAUD_9600 = 0x42,
138  SICK_BAUD_500K = 0x48,
140  };
141 
142 
154  uint16_t sick_scan_angle;
158  uint8_t sick_laser_mode;
160  uint8_t sick_address;
162 
163 
164 
174  typedef struct sick_pls_baud_status_tag {
175  uint16_t sick_baud_rate;
178 
179 
192  uint16_t sick_measurements[SICK_MAX_NUM_MEASUREMENTS];
197 
198 
200  SickPLS( const std::string sick_device_path );
201 
203  ~SickPLS( );
204 
206  bool Initialize( const sick_pls_baud_t desired_baud_rate )
208 
211 
213  std::string GetSickDevicePath( ) const;
214 
216  double GetSickScanAngle( ) const throw( SickConfigException );
217 
219  double GetSickScanResolution( ) const throw( SickConfigException );
220 
222  SickPLS::sick_pls_measuring_units_t GetSickMeasuringUnits( ) const throw( SickConfigException );
223 
225  sick_pls_operating_mode_t GetSickOperatingMode( ) const throw( SickConfigException );
226 
228  void GetSickScan( unsigned int * const measurement_values,
229  unsigned int & num_measurement_values) throw( SickConfigException, SickTimeoutException, SickIOException, SickThreadException);
230 
232  sick_pls_status_t GetSickStatus( ) throw( SickConfigException, SickTimeoutException, SickIOException, SickThreadException );
233 
235  void ResetSick( ) throw( SickConfigException, SickTimeoutException, SickIOException, SickThreadException );
236 
238  std::string GetSickStatusAsString( ) const;
239 
240 
241 
242 
243  /*
244  * NOTE: The following methods are given to make working with our
245  * predefined types a bit more manageable.
246  */
247 
248 
250  static sick_pls_scan_angle_t IntToSickScanAngle( const int scan_angle_int );
251 
253  static sick_pls_scan_resolution_t IntToSickScanResolution( const int scan_resolution_int );
254 
256  static sick_pls_scan_resolution_t DoubleToSickScanResolution( const double scan_resolution_double );
257 
259  static std::string SickBaudToString( const sick_pls_baud_t baud_rate );
260 
262  static sick_pls_baud_t IntToSickBaud( const int baud_int );
263 
265  static sick_pls_baud_t StringToSickBaud( const std::string baud_str );
266 
268  static std::string SickStatusToString( const sick_pls_status_t sick_status );
269 
272 
274  static std::string SickMeasuringUnitsToString( const sick_pls_measuring_units_t sick_units );
275 
276  protected:
277 
280 
283 
286 
287 
290 
291 
294 
295 
297  struct termios _old_term;
298 
300  void _setupConnection( ) throw( SickIOException, SickThreadException );
301 
303  void _teardownConnection( ) throw( SickIOException );
304 
306  void _sendMessageAndGetReply( const SickPLSMessage &sick_send_message,
307  SickPLSMessage &sick_recv_message,
308  const unsigned int timeout_value,
309  const unsigned int num_tries ) throw( SickIOException, SickThreadException, SickTimeoutException );
310 
312  void _sendMessageAndGetReply( const SickPLSMessage &sick_send_message,
313  SickPLSMessage &sick_recv_message,
314  const uint8_t reply_code,
315  const unsigned int timeout_value,
316  const unsigned int num_tries ) throw( SickIOException, SickThreadException, SickTimeoutException );
317 
319  void _flushTerminalBuffer( ) throw ( SickThreadException );
320 
322  void _setSessionBaud( const sick_pls_baud_t baud_rate ) throw( SickIOException, SickThreadException, SickTimeoutException );
323 
325  bool _testSickBaud( const sick_pls_baud_t baud_rate ) throw( SickIOException, SickThreadException );
326 
328  void _setTerminalBaud( const sick_pls_baud_t sick_baud ) throw( SickIOException, SickThreadException );
329 
331  void _getSickErrors( unsigned int * const num_sick_errors = NULL,
332  uint8_t * const error_type_buffer = NULL,
333  uint8_t * const error_num_buffer = NULL ) throw( SickTimeoutException, SickIOException, SickThreadException );
334 
337  throw( SickConfigException, SickTimeoutException, SickIOException, SickThreadException);
338 
341  throw( SickConfigException, SickTimeoutException, SickIOException, SickThreadException);
342 
345  throw( SickConfigException, SickTimeoutException, SickIOException, SickThreadException);
346 
349  throw( SickConfigException, SickTimeoutException, SickIOException, SickThreadException);
350 
352  void _switchSickOperatingMode( const uint8_t sick_mode, const uint8_t * const mode_params = NULL )
353  throw( SickConfigException, SickTimeoutException, SickIOException, SickThreadException);
354 
356  void _parseSickScanProfileB0( const uint8_t * const src_buffer, sick_pls_scan_profile_b0_t &sick_scan_profile ) const;
357 
358 
360  void _extractSickMeasurementValues( const uint8_t * const byte_sequence, const uint16_t num_measurements, uint16_t * const measured_values) const;
361 
364 
367 
369  sick_pls_baud_t _baudToSickBaud( const int baud_rate ) const;
370 
371  };
372 
378 
384 
390 
391 
397 
403 
404 } //namespace SickToolbox
405 
406 #endif //SICK_PLS_HH
sick_pls_baud_t _desired_session_baud
Definition: SickPLS.hh:285
0.50 degree angular resolution
Definition: SickPLS.hh:76
static sick_pls_scan_resolution_t IntToSickScanResolution(const int scan_resolution_int)
Converts integer to corresponding Sick PLS scan resolution.
Definition: SickPLS.cc:665
void ResetSick()
Reset the Sick PLS active field values NOTE: Considered successful if the PLS ready message is receiv...
Definition: SickPLS.cc:525
uint16_t sick_num_measurements
Number of measurements.
Definition: SickPLS.hh:191
void _setSickOpModeMonitorRequestValues()
Sets the device to monitor mode and tells it to send values only upon request.
Definition: SickPLS.cc:1557
Streams measured values with associated flags.
Definition: SickPLS.hh:121
uint8_t sick_permanent_baud_rate
0 - When power is switched on baud rate is 9600/1 - configured transmission rate is used ...
Definition: SickPLS.hh:176
sick_pls_baud_t
Defines available Sick PLS baud rates.
Definition: SickPLS.hh:134
uint16_t sick_scan_angle
Sick scanning angle (deg)
Definition: SickPLS.hh:154
SickPLS(const std::string sick_device_path)
Primary constructor.
Definition: SickPLS.cc:46
Streams mean values from a sample size of n consecutive scans.
Definition: SickPLS.hh:118
void _setTerminalBaud(const sick_pls_baud_t sick_baud)
Sets the local terminal baud rate.
Definition: SickPLS.cc:1225
Contains some simple exception classes.
SickPLS::sick_pls_measuring_units_t GetSickMeasuringUnits() const
Gets the current Sick PLS measuring units.
Definition: SickPLS.cc:376
void _setSickOpModeDiagnostic()
Sets the device to diagnostic mode.
Definition: SickPLS.cc:1492
Streams minimum measured values for each segment in a sub-range.
Definition: SickPLS.hh:124
void _parseSickScanProfileB0(const uint8_t *const src_buffer, sick_pls_scan_profile_b0_t &sick_scan_profile) const
Parses a byte sequence into a scan profile corresponding to message B0.
Definition: SickPLS.cc:1914
uint16_t sick_scan_resolution
Sick angular resolution (1/100 deg)
Definition: SickPLS.hh:155
uint8_t sick_operating_mode
Sick operating mode.
Definition: SickPLS.hh:157
void _switchSickOperatingMode(const uint8_t sick_mode, const uint8_t *const mode_params=NULL)
Attempts to switch the operating mode of the Sick PLS.
Definition: SickPLS.cc:1686
~SickPLS()
Destructor.
Definition: SickPLS.cc:69
sick_pls_status_t
Defines the status of the Sick PLS unit.
Definition: SickPLS.hh:95
static sick_pls_baud_t StringToSickBaud(const std::string baud_str)
Converts string to corresponding Sick PLS baud.
Definition: SickPLS.cc:738
static sick_pls_scan_resolution_t DoubleToSickScanResolution(const double scan_resolution_double)
Converts double to corresponding Sick PLS scan resolution.
Definition: SickPLS.cc:682
A general class for interfacing w/ SickPLS laser range finders.
Definition: SickPLS.hh:50
void _flushTerminalBuffer()
Flushes terminal I/O buffers.
Definition: SickPLS.cc:916
uint16_t sick_baud_rate
Sick baud as reported by the device.
Definition: SickPLS.hh:175
double GetSickScanResolution() const
Gets the current angular resolution.
Definition: SickPLS.cc:356
static std::string SickStatusToString(const sick_pls_status_t sick_status)
Converts the Sick PLS status code to a string.
Definition: SickPLS.cc:754
uint8_t sick_laser_mode
Sick laser is on/off.
Definition: SickPLS.hh:158
A structure for aggregating the data that collectively define the baud config.
Definition: SickPLS.hh:174
Streams measured range from a scan and sub-range of reflectivity values.
Definition: SickPLS.hh:126
Definition of class SickPLSMessage.
struct SickToolbox::SickPLS::sick_pls_scan_profile_b0_tag sick_pls_scan_profile_b0_t
Adopt c-style convention.
bool _validSickScanResolution(const sick_pls_scan_resolution_t sick_scan_resolution) const
Indicates whether the given scan resolution is defined.
Definition: SickPLS.cc:1979
static std::string SickMeasuringUnitsToString(const sick_pls_measuring_units_t sick_units)
Converts the Sick PLS measurement units to a corresponding string.
Definition: SickPLS.cc:824
struct termios _old_term
Definition: SickPLS.hh:297
void _setSickOpModeMonitorStreamValues()
Sets the device to monitor mode and tells it to stream measured values.
Definition: SickPLS.cc:1618
std::string GetSickDevicePath() const
Gets the Sick PLS device path.
Definition: SickPLS.cc:328
A structure for aggregating the data that define a scan profile obtained from reply B0 (See page 49 T...
Definition: SickPLS.hh:190
static std::string SickOperatingModeToString(const sick_pls_operating_mode_t sick_operating_mode)
Converts the Sick operating mode to a corresponding string.
Definition: SickPLS.cc:772
Sends min vertical distance to object when detected.
Definition: SickPLS.hh:115
struct SickToolbox::SickPLS::sick_pls_operating_status_tag sick_pls_operating_status_t
Adopt c-style convention.
void _teardownConnection()
Closes the data connection associated with the device.
Definition: SickPLS.cc:890
static std::string SickBaudToString(const sick_pls_baud_t baud_rate)
Converts Sick PLS baud to a corresponding string.
Definition: SickPLS.cc:692
uint16_t sick_num_motor_revs
Sick number of motor revs.
Definition: SickPLS.hh:156
Sends the min measured values when object is detected.
Definition: SickPLS.hh:113
uint8_t sick_partial_scan_index
Indicates the start angle of the scan (This is useful for partial scans)
Definition: SickPLS.hh:195
Streams all measured values in a scan.
Definition: SickPLS.hh:116
uint8_t sick_address
Sick device address.
Definition: SickPLS.hh:160
Scanning angle of 180 degrees.
Definition: SickPLS.hh:66
void _extractSickMeasurementValues(const uint8_t *const byte_sequence, const uint16_t num_measurements, uint16_t *const measured_values) const
Extracts the measured values (w/ flags) that were returned by the device.
Definition: SickPLS.cc:1946
Sends measured range values on request (i.e. when polled)
Definition: SickPLS.hh:117
sick_pls_measuring_units_t
Defines the available Sick PLS measured value units.
Definition: SickPLS.hh:84
sick_pls_baud_t _curr_session_baud
Definition: SickPLS.hh:282
struct SickToolbox::SickPLS::sick_pls_baud_status_tag sick_pls_baud_status_t
Adopt c-style convention.
Provides an abstract parent for all Sick LIDAR devices.
Definition: SickLIDAR.hh:53
sick_pls_operating_mode_t GetSickOperatingMode() const
Gets the current Sick PLS operating mode.
Definition: SickPLS.cc:392
void _setSessionBaud(const sick_pls_baud_t baud_rate)
Sets the baud rate for the current communication session.
Definition: SickPLS.cc:1076
bool _testSickBaud(const sick_pls_baud_t baud_rate)
Attempts to detect whether the PLS is operating at the given baud rate.
Definition: SickPLS.cc:1153
Streams mean values over requested subrange.
Definition: SickPLS.hh:120
uint8_t sick_telegram_index
Telegram index modulo 256.
Definition: SickPLS.hh:193
void _setSickOpModeInstallation()
Sets the device to installation mode.
Definition: SickPLS.cc:1429
bool _validSickScanAngle(const sick_pls_scan_angle_t sick_scan_angle) const
Indicates whether the given scan angle is defined.
Definition: SickPLS.cc:1961
double GetSickScanAngle() const
Gets the current scan angle of the device.
Definition: SickPLS.cc:338
PLS has encountered an error.
Definition: SickPLS.hh:97
void GetSickScan(unsigned int *const measurement_values, unsigned int &num_measurement_values)
Returns the most recent measured values obtained by the Sick PLS.
Definition: SickPLS.cc:424
Sick outputs navigation data records.
Definition: SickPLS.hh:125
sick_pls_operating_status_t _sick_operating_status
Definition: SickPLS.hh:289
Defines the abstract parent class for defining a Sick LIDAR device driver.
sick_pls_scan_angle_t
Defines the scan angle for the Sick PLS.
Definition: SickPLS.hh:64
static const uint16_t SICK_MAX_NUM_MEASUREMENTS
Maximum number of measurements returned by the Sick PLS.
Definition: SickPLS.hh:57
std::string _sick_device_path
Definition: SickPLS.hh:279
void _setupConnection()
Attempts to open a I/O stream using the device path given at object instantiation.
Definition: SickPLS.cc:841
Defines a class for monitoring the receive buffer when interfacing w/ a Sick PLS laser range finder...
Measured values are in centimeters.
Definition: SickPLS.hh:87
A class to represent all messages sent to and from the Sick PLS.
A structure for aggregating the data that collectively defines the operating status of the device...
Definition: SickPLS.hh:153
sick_pls_operating_mode_t
Defines the operating modes supported by Sick PLS. See page 41 of the PLS telegram manual for additio...
Definition: SickPLS.hh:106
Installation mode for writing EEPROM.
Definition: SickPLS.hh:110
std::string GetSickStatusAsString() const
Acquire the Sick PLS&#39;s status as a printable string.
Definition: SickPLS.cc:611
sick_pls_scan_resolution_t
Defines the available resolution settings for the Sick PLS.
Definition: SickPLS.hh:74
sick_pls_baud_t _baudToSickBaud(const int baud_rate) const
Converts a termios baud to an equivalent Sick baud.
Definition: SickPLS.cc:2000
static sick_pls_scan_angle_t IntToSickScanAngle(const int scan_angle_int)
Converts integer to corresponding Sick PLS scan angle.
Definition: SickPLS.cc:648
Thrown instance where the driver can&#39;t read,write,drain,flush,... the buffers.
void _sendMessageAndGetReply(const SickPLSMessage &sick_send_message, SickPLSMessage &sick_recv_message, const unsigned int timeout_value, const unsigned int num_tries)
Sends a message and searches for the corresponding reply.
Definition: SickPLS.cc:962
void Uninitialize()
Uninitializes the PLS by putting it in a mode where it stops streaming data, and returns it to the de...
Definition: SickPLS.cc:253
Streams measured values of partial scan directly after measurement.
Definition: SickPLS.hh:122
static sick_pls_baud_t IntToSickBaud(const int baud_int)
Converts integer to corresponding Sick PLS baud.
Definition: SickPLS.cc:715
uint8_t sick_real_time_scan_index
If real-time scan indices are requested, this value is set (modulo 256)
Definition: SickPLS.hh:194
Streams minimum measured values for each segement.
Definition: SickPLS.hh:112
Thrown when the driver detects (or the Sick reports) an invalid config.
bool Initialize(const sick_pls_baud_t desired_baud_rate)
Attempts to initialize the Sick PLS and then sets communication at at the given baud rate...
Definition: SickPLS.cc:99
uint8_t sick_measuring_units
Sick measuring units {cm,mm}.
Definition: SickPLS.hh:159
Diagnostic mode for testing purposes.
Definition: SickPLS.hh:111
Makes handling timeouts much easier.
sick_pls_baud_status_t _sick_baud_status
Definition: SickPLS.hh:293
sick_pls_status_t GetSickStatus()
Thrown when error occurs during thread initialization, and uninitialization.
void _getSickErrors(unsigned int *const num_sick_errors=NULL, uint8_t *const error_type_buffer=NULL, uint8_t *const error_num_buffer=NULL)
Obtains any error codes from the Sick PLS.
Definition: SickPLS.cc:1339


asr_mild_base_laserscanner
Author(s): Aumann Florian, Borella Jocelyn, Dehmani Souheil, Marek Felix, Reckling Reno
autogenerated on Mon Jun 10 2019 12:41:37