YARP
Yet Another Robot Platform
laserHokuyo.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: LGPL-2.1-or-later
4 */
5
6#ifndef LASERHOKUYO_THREAD_H
7#define LASERHOKUYO_THREAD_H
8
9//#include <cstdio>
10#include <string>
11
13#include <mutex>
16#include <yarp/dev/PolyDriver.h>
18#include <yarp/sig/Vector.h>
19
20using namespace yarp::os;
21using namespace yarp::dev;
22
29{
30protected:
33
34 std::mutex mutex;
35
36 int cardId;
37 double period;
41 double min_angle;
42 double max_angle;
45 std::string info;
47
50 {
58 };
59
61
63 {
64 std::string MODL;
65 int DMIN;
66 int DMAX;
67 int ARES;
68 int AMIN;
69 int AMAX;
70 int AFRT;
71 int SCAN;
73
75
76public:
78 pSerial(nullptr),
79 mutex(),
80 cardId(0),
82 sensorsNum(0),
84 end_position(0),
85 min_angle(0.0),
86 max_angle(0.0),
87 error_codes(0),
89 info(""),
92 {}
93
94
96 {
97 }
98
99 bool open(yarp::os::Searchable& config) override;
100 bool close() override;
101 bool threadInit() override;
102 void threadRelease() override;
103 void run() override;
104
105public:
106 //IRangefinder2D interface
107 bool getRawData(yarp::sig::Vector &data, double* timestamp) override;
108 bool getLaserMeasurement(std::vector<LaserMeasurementData> &data, double* timestamp) override;
109 bool getDeviceStatus (Device_status &status) override;
110 bool getDeviceInfo (std::string &device_info) override;
111 bool getDistanceRange (double& min, double& max) override;
112 bool setDistanceRange (double min, double max) override;
113 bool getScanLimits (double& min, double& max) override;
114 bool setScanLimits (double min, double max) override;
115 bool getHorizontalResolution (double& step) override;
116 bool setHorizontalResolution (double step) override;
117 bool getScanRate (double& rate) override;
118 bool setScanRate (double rate) override;
119
120private:
121 //laser methods
122 int calculateCheckSum(const char* buffer, int size, char actual_sum);
123 long decodeDataValue(const char* data, int data_byte);
124 int readData(const Laser_mode_type laser_mode, const char* text_data, const int lext_data_len, int current_line, yarp::sig::Vector& values);
125};
126
127#endif
define control board standard interfaces
contains the definition of a Vector type
laserHokuyo: Documentation to be added
Definition: laserHokuyo.h:29
Device_status device_status
Definition: laserHokuyo.h:46
std::string info
Definition: laserHokuyo.h:45
bool setScanRate(double rate) override
set the scan rate (scans per seconds)
PolyDriver driver
Definition: laserHokuyo.h:31
bool getRawData(yarp::sig::Vector &data, double *timestamp) override
Get the device measurements.
double period
Definition: laserHokuyo.h:37
int error_codes
Definition: laserHokuyo.h:43
bool getDeviceStatus(Device_status &status) override
get the device status
int internal_status
Definition: laserHokuyo.h:44
int end_position
Definition: laserHokuyo.h:40
@ HOKUYO_STATUS_ERROR_INVALID_CHECKSUM
Definition: laserHokuyo.h:55
@ HOKUYO_STATUS_NOT_READY
Definition: laserHokuyo.h:57
@ HOKUYO_STATUS_ERROR_BUSY
Definition: laserHokuyo.h:53
@ HOKUYO_STATUS_OK
Definition: laserHokuyo.h:52
@ HOKUYO_STATUS_ERROR_INVALID_COMMAND
Definition: laserHokuyo.h:54
@ HOKUYO_STATUS_ERROR_NOTHING_RECEIVED
Definition: laserHokuyo.h:56
@ HOKUYO_STATUS_ACQUISITION_COMPLETE
Definition: laserHokuyo.h:51
ISerialDevice * pSerial
Definition: laserHokuyo.h:32
void run() override
Loop function.
bool getScanRate(double &rate) override
get the scan rate (scans per seconds)
bool getScanLimits(double &min, double &max) override
get the scan angular range.
std::mutex mutex
Definition: laserHokuyo.h:34
laserHokuyo(double period=0.02)
Definition: laserHokuyo.h:77
bool getDistanceRange(double &min, double &max) override
get the device detection range
void threadRelease() override
Release method.
int start_position
Definition: laserHokuyo.h:39
yarp::sig::Vector laser_data
Definition: laserHokuyo.h:74
double min_angle
Definition: laserHokuyo.h:41
struct laserHokuyo::sensor_property_struct sensor_properties
bool setHorizontalResolution(double step) override
get the angular step between two measurements (if available)
bool threadInit() override
Initialization method.
bool close() override
Close the DeviceDriver.
double max_angle
Definition: laserHokuyo.h:42
int sensorsNum
Definition: laserHokuyo.h:38
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
Definition: laserHokuyo.cpp:29
bool getLaserMeasurement(std::vector< LaserMeasurementData > &data, double *timestamp) override
Get the device measurements.
bool setDistanceRange(double min, double max) override
set the device detection range.
bool getDeviceInfo(std::string &device_info) override
get the device hardware characteristics
Laser_mode_type laser_mode
Definition: laserHokuyo.h:60
bool setScanLimits(double min, double max) override
set the scan angular range.
bool getHorizontalResolution(double &step) override
get the angular step between two measurements.
Interface implemented by all device drivers.
Definition: DeviceDriver.h:30
A generic interface for planar laser range finders.
A generic interface to serial port devices.
Definition: ISerialDevice.h:24
A container for a device driver.
Definition: PolyDriver.h:23
An abstraction for a periodic thread.
void step()
Call this to "step" the thread rather than starting it.
A base class for nested structures that can be searched.
Definition: Searchable.h:63
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.