INTRODUCTION
Overview
Download and Install
Documentation
Publications

REPOSITORY
Libraries

DEVELOPER
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         
sensor.h
1/*
2 * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics
3 * http://gearbox.sf.net/
4 * Copyright (c) 2008-2010 Geoffrey Biggs
5 *
6 * hokuyo_aist Hokuyo laser scanner driver.
7 *
8 * This distribution is licensed to you under the terms described in the
9 * LICENSE file included in this distribution.
10 *
11 * This work is a product of the National Institute of Advanced Industrial
12 * Science and Technology, Japan. Registration number: H22PRO-1086.
13 *
14 * This file is part of hokuyo_aist.
15 *
16 * This software is licensed under the Eclipse Public License -v 1.0 (EPL). See
17 * http://www.opensource.org/licenses/eclipse-1.0.txt
18 */
19
20#ifndef SENSOR_H__
21#define SENSOR_H__
22
23#include <string>
24
25#if defined(WIN32)
26 typedef unsigned char uint8_t;
27 typedef unsigned int uint32_t;
28 #if defined(HOKUYO_AIST_STATIC)
29 #define HOKUYO_AIST_EXPORT
30 #elif defined(HOKUYO_AIST_EXPORTS)
31 #define HOKUYO_AIST_EXPORT __declspec(dllexport)
32 #else
33 #define HOKUYO_AIST_EXPORT __declspec(dllimport)
34 #endif
35#else
36 #include <stdint.h>
37 #define HOKUYO_AIST_EXPORT
38#endif
39
40namespace flexiport
41{
42 class Port;
43}
44
49namespace hokuyo_aist
50{
51
65{
66 ME_OFF,
67 ME_FRONT,
68 ME_MIDDLE,
69 ME_REAR,
70 ME_AVERAGE
71};
72
73
74HOKUYO_AIST_EXPORT inline char const* multiecho_mode_to_string(MultiechoMode mode)
75{
76 switch(mode)
77 {
78 case ME_OFF:
79 return "Off";
80 case ME_FRONT:
81 return "Front";
82 case ME_MIDDLE:
83 return "Middle";
84 case ME_REAR:
85 return "Rear";
86 case ME_AVERAGE:
87 return "Average";
88 default:
89 return "Unknown";
90 }
91}
92
93
95typedef struct IPAddr
96{
98 unsigned int first;
100 unsigned int second;
102 unsigned int third;
104 unsigned int fourth;
105} IPAddr;
106
107
121class HOKUYO_AIST_EXPORT Sensor
122{
123 public:
124 Sensor();
125 Sensor(std::ostream& err_output);
126 ~Sensor();
127
129 void open(std::string port_options);
130
141 unsigned int open_with_probing(std::string port_options);
142
144 void close();
145
147 bool is_open() const;
148
150 void set_power(bool on);
151
156 void set_baud(unsigned int baud);
157
164 void set_ip(IPAddr const& addr, IPAddr const& subnet,
165 IPAddr const& gateway);
166
170 void reset();
171
175 void semi_reset();
176
187 void set_motor_speed(unsigned int speed);
188
191 void set_high_sensitivity(bool on);
192
196 void get_sensor_info(SensorInfo& info);
197
201 unsigned int get_time();
202
206 unsigned int get_raw_time();
207
236 long long calibrate_time(unsigned int skew_sleep_time=0,
237 unsigned int samples=10);
238
240 long long time_offset() const { return time_offset_; }
241
243 void set_time_offset(long long time_offset)
244 { time_offset_ = time_offset; }
246 float drift_rate() const { return time_drift_rate_; }
262 void set_drift_rate(float drift_rate)
263 { time_drift_rate_ = drift_rate; }
264
266 float skew_alpha() const { return time_skew_alpha_; }
279 void set_skew_alpha(float alpha) { time_skew_alpha_ = alpha; }
280
303 unsigned int get_ranges(ScanData& data, int start_step = -1,
304 int end_step = -1, unsigned int cluster_count = 1);
305
320 unsigned int get_ranges_by_angle(ScanData& data, double start_angle,
321 double end_angle, unsigned int cluster_count = 1);
322
345 unsigned int get_ranges_intensities(ScanData& data,
346 int start_step = -1, int end_step = -1,
347 unsigned int cluster_count = 1);
348
363 unsigned int get_ranges_intensities_by_angle(ScanData& data,
364 double start_angle, double end_angle,
365 unsigned int cluster_count = 1);
366
395 unsigned int get_new_ranges(ScanData& data, int start_step = -1,
396 int end_step = -1, unsigned int cluster_count = 1);
397
414 unsigned int get_new_ranges_by_angle(ScanData& data,
415 double start_angle, double end_angle,
416 unsigned int cluster_count = 1);
417
445 unsigned int get_new_ranges_intensities(ScanData& data,
446 int start_step = -1, int end_step = -1,
447 unsigned int cluster_count = 1);
448
465 unsigned int get_new_ranges_intensities_by_angle(ScanData& data,
466 double start_angle, double end_angle,
467 unsigned int cluster_count = 1);
468
470 uint8_t scip_version() const { return scip_version_; }
471
474 void set_verbose(bool verbose) { verbose_ = verbose; }
475
478 void ignore_unknowns(bool ignore) { ignore_unknowns_ = ignore; }
479
481 void set_multiecho_mode(MultiechoMode mode) { multiecho_mode_ = mode; }
482
484 double step_to_angle(unsigned int step);
487 unsigned int angle_to_step(double angle);
488
489 private:
490 flexiport::Port* port_;
491 std::ostream& err_output_;
492
493 uint8_t scip_version_;
494 LaserModel model_;
495 bool verbose_, enable_checksum_workaround_,
496 ignore_unknowns_;
497 MultiechoMode multiecho_mode_;
498 double min_angle_, max_angle_, resolution_;
499 int first_step_, last_step_, front_step_;
500 unsigned int max_range_;
502 unsigned int time_resolution_;
505 long long time_offset_;
508 unsigned int last_timestamp_;
510 unsigned int wrap_count_;
512 float time_drift_rate_;
514 float time_skew_alpha_;
515
516 void clear_read_buffer();
517 int read_line(char* buffer, int expected_length=-1);
518 int read_line_with_check(char* buffer, int expected_length=-1,
519 bool has_semicolon=false);
520 bool read_data_block(char* buffer, int& block_size);
521 void skip_lines(int count);
522 int send_command(char const* cmd, char const* param, int param_length,
523 char const* extra_ok);
524
525 void enter_timing_mode();
526 void leave_timing_mode();
528 unsigned int get_timing_mode_time(unsigned long long* reception_time=0);
530 unsigned long long get_computer_time();
532 unsigned int wrap_timestamp(unsigned int timestamp);
535 unsigned long long offset_timestamp(unsigned int timestamp);
538 unsigned int step_to_time_offset(int start_step);
539
540 void find_model(char const* buffer);
541 void get_and_set_scip_version();
542 void get_defaults();
543 void process_vv_line(char const* buffer, SensorInfo& info);
544 void process_pp_line(char const* buffer, SensorInfo& info);
545 void process_ii_line(char const* buffer, SensorInfo& info);
546
547 uint32_t process_echo_buffer(int const* buffer, int num_echos);
548 void read_2_byte_range_data(ScanData& data, unsigned int num_steps);
549 void read_3_byte_range_data(ScanData& data, unsigned int num_steps);
550 void read_3_byte_range_and_intensity_data(ScanData& data,
551 unsigned int num_steps);
552
553 int confirm_checksum(char const* buffer, int length,
554 int expected_sum);
555}; // class Sensor
556
557} // namespace hokuyo_aist
558
561#endif // SENSOR_H__
562
Base Port class.
Definition: port.h:80
Structure to store data returned from the laser scanner.
Definition: scan_data.h:53
Sensor information.
Definition: sensor_info.h:128
Hokuyo laser scanner class.
Definition: sensor.h:122
void set_drift_rate(float drift_rate)
Definition: sensor.h:262
long long time_offset() const
Retrieve the calculated time offset (0 if not calibrated).
Definition: sensor.h:240
float skew_alpha() const
Get the calculated skew line slope (default: 0).
Definition: sensor.h:266
void set_time_offset(long long time_offset)
Set the time offset (if the calculated value is bad).
Definition: sensor.h:243
float drift_rate() const
Retrieve the current clock drift rate (0 if not set).
Definition: sensor.h:246
void ignore_unknowns(bool ignore)
Enables/disables ignoring unknown lines in sensor info messages. Default is off.
Definition: sensor.h:478
uint8_t scip_version() const
Return the major version of the SCIP protocol in use.
Definition: sensor.h:470
void set_verbose(bool verbose)
Turns on and off printing of verbose operating information to stderr. Default is off.
Definition: sensor.h:474
void set_skew_alpha(float alpha)
Definition: sensor.h:279
void set_multiecho_mode(MultiechoMode mode)
Set the multi-echo mode to use. Default is ME_OFF.
Definition: sensor.h:481
FlexiPort data communications library.
Hokuyo laser scanner driver name space.
LaserModel
Laser models.
Definition: sensor_info.h:50
MultiechoMode
Possible values of the multiecho mode setting.
Definition: sensor.h:65
Structure to store an IP address.
Definition: sensor.h:96
unsigned int first
First byte.
Definition: sensor.h:98
unsigned int second
Second byte.
Definition: sensor.h:100
unsigned int third
Third byte.
Definition: sensor.h:102
unsigned int fourth
Fourth byte.
Definition: sensor.h:104
 

Generated for GearBox by  doxygen 1.4.5