6#define _USE_MATH_DEFINES
26#define DEG2RAD M_PI/180.0
40 now=SystemClock::nowSystem();
47 state = IRangefinder2D::DEVICE_GENERAL_ERROR;
53 now=SystemClock::nowSystem();
58 double tmpDT=now-prev;
60 if (tmpDT > deltaTMax) {
63 if (tmpDT < deltaTMin) {
74 state = IRangefinder2D::DEVICE_TIMEOUT;
98 state = IRangefinder2D::DEVICE_TIMEOUT;
100 lastStamp = newStamp;
109 if (
ret != IRangefinder2D::DEVICE_GENERAL_ERROR)
166 yCError(RANGEFINDER2DCLIENT,
"open() error you have to provide valid local name");
171 yCError(RANGEFINDER2DCLIENT,
"open() error you have to provide valid remote name");
175 std::string local_rpc =
local;
176 local_rpc +=
"/rpc:o";
177 std::string remote_rpc =
remote;
178 remote_rpc +=
"/rpc:i";
182 yCError(RANGEFINDER2DCLIENT,
"open() error could not open port %s, check network\n",
local.c_str());
189 yCError(RANGEFINDER2DCLIENT,
"open() error could not open rpc port %s, check network\n", local_rpc.c_str());
196 yCError(RANGEFINDER2DCLIENT,
"open() error could not connect to %s\n",
remote.c_str());
200 ok=Network::connect(local_rpc, remote_rpc);
203 yCError(RANGEFINDER2DCLIENT,
"open() error could not connect to %s\n", remote_rpc.c_str());
218 TransformClientOptions.
put(
"device",
"transformClient");
219 TransformClientOptions.
put(
"local",
"/rangefinder2DTransformClient");
220 TransformClientOptions.
put(
"remote",
"/transformServer");
221 TransformClientOptions.
put(
"period",
"10");
223 bool b_canOpenTransformClient =
false;
224 if (config.
check(
"laser_frame_name") &&
225 config.
check(
"robot_frame_name"))
229 b_canOpenTransformClient = drv->open(TransformClientOptions);
232 if (b_canOpenTransformClient)
238 yCError(RANGEFINDER2DCLIENT) <<
"A Problem occurred while trying to view the IFrameTransform interface";
250 if (fabs(v[0]) < 1e-6 && fabs(v[1]) < 1e-6)
252 yCError(RANGEFINDER2DCLIENT) <<
"Laser device is not planar";
254 yCInfo(RANGEFINDER2DCLIENT) <<
"Position information obtained fromtransform server";
259 if (config.
check(
"device_position_x") &&
260 config.
check(
"device_position_y") &&
261 config.
check(
"device_position_theta"))
263 yCInfo(RANGEFINDER2DCLIENT) <<
"Position information obtained from configuration parameters";
270 yCDebug(RANGEFINDER2DCLIENT) <<
"No position information provided for this device";
292 if (timestamp !=
nullptr)
307 for (
size_t i = 0; i < size; i++)
310 double value = scan.
scans[i];
314 data[i].set_polar(value,angle);
317 if (timestamp!=
nullptr)
331 if (CHECK_FAIL(ok, response) !=
false)
354 return (CHECK_FAIL(ok, response));
364 if (CHECK_FAIL(ok, response) !=
false)
382 return (CHECK_FAIL(ok, response));
392 if (CHECK_FAIL(ok, response) !=
false)
408 return (CHECK_FAIL(ok, response));
418 if (CHECK_FAIL(ok, response) !=
false)
434 return (CHECK_FAIL(ok, response));
450 if (CHECK_FAIL(ok, response)!=
false)
constexpr yarp::conf::vocab32_t VOCAB_GET
constexpr yarp::conf::vocab32_t VOCAB_SET
constexpr yarp::conf::vocab32_t VOCAB_LASER_ANGULAR_RANGE
constexpr yarp::conf::vocab32_t VOCAB_LASER_SCAN_RATE
constexpr yarp::conf::vocab32_t VOCAB_ILASER2D
constexpr yarp::conf::vocab32_t VOCAB_LASER_DISTANCE_RANGE
constexpr yarp::conf::vocab32_t VOCAB_DEVICE_INFO
constexpr yarp::conf::vocab32_t VOCAB_LASER_ANGULAR_STEP
bool setDistanceRange(double min, double max) override
set the device detection range.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
bool getHorizontalResolution(double &step) override
get the angular step between two measurments.
bool getScanRate(double &rate) override
get the scan rate (scans per seconds)
bool setHorizontalResolution(double step) override
get the angular step between two measurments (if available)
bool close() override
Close the DeviceDriver.
bool setScanRate(double rate) override
set the scan rate (scans per seconds)
bool setScanLimits(double min, double max) override
set the scan angular range.
bool getDistanceRange(double &min, double &max) override
get the device detection range
bool getRawData(yarp::sig::Vector &data, double *timestamp=nullptr) override
Get the device measurements.
double device_position_theta
std::string robot_frame_name
bool getLaserMeasurement(std::vector< yarp::dev::LaserMeasurementData > &data, double *timestamp=nullptr) override
Get the device measurements.
bool getDeviceStatus(Device_status &status) override
get the device status
Rangefinder2DInputPortProcessor inputPort
std::string laser_frame_name
bool getDeviceInfo(std::string &device_info) override
get the device hardware charactestics
bool getScanLimits(double &min, double &max) override
get the scan angular range.
yarp::sig::Vector scans
the scan data, measured in [m].
A container for a device driver.
A simple collection of objects that can be described and transmitted in a portable way.
void addVocab32(yarp::conf::vocab32_t x)
Places a vocabulary item in the bottle, at the end of the list.
void addFloat64(yarp::conf::float64_t x)
Places a 64-bit floating point number in the bottle, at the end of the list.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
bool getEnvelope(PortReader &envelope) override
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
void useCallback(TypedReaderCallback< T > &callback) override
Set an object whose onRead method will be called when data is available.
bool write(const PortWriter &writer, const PortWriter *callback=nullptr) const override
Write an object to the port.
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
A class for storing options and configuration information.
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 Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
An abstraction for a time stamp and/or sequence number.
double getTime() const
Get the time stamp.
bool isValid() const
Check if this Stamp is valid.
A single value (typically within a Bottle).
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
std::string toString() const override
Return a standard text representation of the content of the object.
virtual std::string asString() const
Get string value.
#define yCInfo(component,...)
#define yCError(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
For streams capable of holding different kinds of content, check what they actually have.
yarp::sig::Vector dcm2rpy(const yarp::sig::Matrix &R)
Converts a dcm (direction cosine matrix) rotation matrix to roll-pitch-yaw angles (defined in Math....
An interface to the operating system, including Port based communication.