6#define _USE_MATH_DEFINES
21#define DEG2RAD M_PI/180.0
33 info =
"Hokuyo Laser";
38 bool br = config.
check(
"GENERAL");
59 std::string s =
general_config.check(
"Laser_Mode",
Value(
"GD"),
"Laser Mode (GD/MD").asString();
63 yCError(
LASERHOKUYO) <<
"Deprecated parameter 'Measurement_Units'. Please Remove it from the configuration file.";
68 yCInfo(
LASERHOKUYO,
"'error_codes' option enabled. Invalid samples will be substituted with out-of-range measurements.");
87 bool br2 = config.
check(
"SERIAL_PORT_CONFIGURATION");
97 prop.
put(
"device",
"serialport");
188 if (
found != std::string::npos) {
192 if (
found != std::string::npos) {
196 if (
found != std::string::npos) {
200 if (
found != std::string::npos) {
204 if (
found != std::string::npos) {
208 if (
found != std::string::npos) {
212 if (
found != std::string::npos) {
216 if (
found != std::string::npos) {
294 return ReturnValue::return_code::return_value_error_not_implemented_by_device;
308 return ReturnValue::return_code::return_value_error_not_implemented_by_device;
320 return ReturnValue::return_code::return_value_error_not_implemented_by_device;
332 return ReturnValue::return_code::return_value_error_not_implemented_by_device;
347 return ReturnValue::return_code::return_value_error_not_ready;
362 return ReturnValue::return_code::return_value_error_method_failed;
366 for (
size_t i = 0; i < size; i++)
377 return ReturnValue::return_code::return_value_error_not_ready;
394inline int laserHokuyo::calculateCheckSum(
const char*
buffer,
int size,
char actual_sum)
399 for (i = 0; i < size; ++i)
408inline long laserHokuyo::decodeDataValue(
const char* data,
int data_byte)
415 value |= data[i] - 0x30;
511 constexpr int buffer_size = 128;
512 char command [buffer_size];
513 char answer [buffer_size];
520 bool timeout =
false;
587 this->
mutex.unlock();
Device_status device_status
yarp::dev::ReturnValue getDeviceStatus(Device_status &status) override
get the device status
yarp::dev::ReturnValue getLaserMeasurement(std::vector< yarp::sig::LaserMeasurementData > &data, double *timestamp) override
Get the device measurements.
yarp::dev::ReturnValue setScanRate(double rate) override
set the scan rate (scans per seconds)
@ HOKUYO_STATUS_ERROR_INVALID_CHECKSUM
@ HOKUYO_STATUS_NOT_READY
@ HOKUYO_STATUS_ERROR_BUSY
@ HOKUYO_STATUS_ERROR_INVALID_COMMAND
@ HOKUYO_STATUS_ERROR_NOTHING_RECEIVED
@ HOKUYO_STATUS_ACQUISITION_COMPLETE
yarp::dev::ReturnValue setHorizontalResolution(double step) override
get the angular step between two measurements (if available)
yarp::dev::ReturnValue setScanLimits(double min, double max) override
set the scan angular range.
void run() override
Loop function.
yarp::dev::ReturnValue getRawData(yarp::sig::Vector &data, double *timestamp) override
Get the device measurements.
yarp::dev::ReturnValue getScanRate(double &rate) override
get the scan rate (scans per seconds)
yarp::dev::ReturnValue getScanLimits(double &min, double &max) override
get the scan angular range.
void threadRelease() override
Release method.
yarp::sig::Vector laser_data
struct laserHokuyo::sensor_property_struct sensor_properties
bool threadInit() override
Initialization method.
bool close() override
Close the DeviceDriver.
yarp::dev::ReturnValue getDistanceRange(double &min, double &max) override
get the device detection range
yarp::dev::ReturnValue setDistanceRange(double min, double max) override
set the device detection range.
yarp::dev::ReturnValue getHorizontalResolution(double &step) override
get the angular step between two measurements.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
Laser_mode_type laser_mode
yarp::dev::ReturnValue getDeviceInfo(std::string &device_info) override
get the device hardware characteristics
bool view(T *&x)
Get an interface to the device driver.
virtual int receiveLine(char *line, const int MaxLineLength)=0
Gets one line (a sequence of chars with a ending '\n' or '\r') from the receive queue.
virtual bool send(const yarp::os::Bottle &msg)=0
Sends a string of chars to the serial communications channel.
virtual bool receive(yarp::os::Bottle &msg)=0
Gets the existing chars in the receive queue.
bool close() override
Close the DeviceDriver.
bool isValid() const
Check if device is valid.
bool open(const std::string &txt)
Construct and configure a device by its common name.
A simple collection of objects that can be described and transmitted in a portable way.
void clear()
Empties the bottle of any objects it contains.
void addString(const char *str)
Places a string in the bottle, at the end of the list.
A mini-server for performing network communication in the background.
bool setPeriod(double period)
Set the (new) period of the thread.
bool start()
Call this to start the thread.
void step()
Call this to "step" the thread rather than starting it.
void stop()
Call this to stop the thread, this call blocks until the thread is terminated (and releaseThread() ca...
A class for storing options and configuration information.
void fromString(const std::string &txt, bool wipe=true)
Interprets a string as a list of properties.
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
A base class for nested structures that can be searched.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
virtual std::string toString() const =0
Return a standard text representation of the content of the object.
virtual Bottle & findGroup(const std::string &key) const =0
Gets a list corresponding to a given keyword.
static double nowSystem()
static void delaySystem(double seconds)
A single value (typically within a Bottle).
std::string toString(int precision=-1, int width=-1) const
Creates a string object containing a text representation of the object.
void resize(size_t size) override
Resize the vector.
void push_back(const T &elem)
Push a new element in the vector: size is changed.
#define yCInfo(component,...)
#define yCError(component,...)
#define yCTrace(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)