YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
laserFromExternalPort.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 LASER_FROM_EXTERNAL_PORT_H
7#define LASER_FROM_EXTERNAL_PORT_H
8
10#include <yarp/os/Semaphore.h>
11#include <yarp/os/Port.h>
13#include <yarp/os/Stamp.h>
18#include <yarp/sig/Vector.h>
20#include <yarp/dev/PolyDriver.h>
21
22#include <mutex>
23#include <string>
24#include <vector>
25
26typedef unsigned char byte;
27
28//---------------------------------------------------------------------------------------------------------------
30 public yarp::os::BufferedPort<yarp::sig::LaserScan2D>
31{
32 std::mutex m_port_mutex;
33 yarp::sig::LaserScan2D m_lastScan;
34 yarp::os::Stamp m_lastStamp;
35 bool m_contains_data;
36
37public:
39 yarp::os::BufferedPort<yarp::sig::LaserScan2D>(),
40 m_lastScan(alt.m_lastScan),
41 m_lastStamp(alt.m_lastStamp),
42 m_contains_data(alt.m_contains_data)
43 {
44 }
45
48 void onRead(yarp::sig::LaserScan2D& v) override;
50};
51
83{
84 enum base_enum
85 {
86 BASE_IS_NAN = 0,
87 BASE_IS_INF = 1,
88 BASE_IS_ZERO = 2
89 };
90
91protected:
93 std::vector <std::string> m_port_names;
94 std::vector<LaserFromExternalPort_InputPortProcessor> m_input_ports;
95 std::vector <yarp::os::Stamp> m_last_stamp;
96 std::vector<yarp::sig::LaserScan2D> m_last_scan_data;
99
100 std::vector <std::string> m_src_frame_id;
101 std::string m_dst_frame_id;
103 base_enum m_base_type;
104
106
107public:
108 LaserFromExternalPort(double period = 0.01) : Lidar2DDeviceBase(), PeriodicThread(period)
109 {
111 m_base_type = base_enum::BASE_IS_NAN;
112 }
113
117
118 bool open(yarp::os::Searchable& config) override;
119 bool close() override;
120 bool threadInit() override;
121 void threadRelease() override;
122 void run() override;
123
124public:
125 //IRangefinder2D interface
126 yarp::dev::ReturnValue setDistanceRange (double min, double max) override;
127 yarp::dev::ReturnValue setScanLimits (double min, double max) override;
129 yarp::dev::ReturnValue setScanRate (double rate) override;
130
131public:
132 //Lidar2DDeviceBase
133 bool acquireDataFromHW() override final;
134};
135
136#endif
define control board standard interfaces
contains the definition of a Vector type
void onRead(yarp::sig::LaserScan2D &v) override
LaserFromExternalPort_InputPortProcessor(const LaserFromExternalPort_InputPortProcessor &alt)
void getLast(yarp::sig::LaserScan2D &data, yarp::os::Stamp &stmp)
laserFromExternalPort: Documentation to be added
bool close() override
Close the DeviceDriver.
yarp::dev::ReturnValue setHorizontalResolution(double step) override
get the angular step between two measurements (if available)
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
bool threadInit() override
Initialization method.
std::vector< std::string > m_src_frame_id
std::vector< yarp::os::Stamp > m_last_stamp
std::vector< LaserFromExternalPort_InputPortProcessor > m_input_ports
yarp::dev::ReturnValue setScanLimits(double min, double max) override
set the scan angular range.
bool acquireDataFromHW() override final
This method should be implemented by the user, and contain the logic to grab data from the hardware.
std::vector< yarp::sig::LaserScan2D > m_last_scan_data
yarp::sig::Vector m_empty_laser_data
yarp::dev::IFrameTransform * m_iTc
void run() override
Loop function.
LaserFromExternalPort(double period=0.01)
std::vector< std::string > m_port_names
void threadRelease() override
Release method.
yarp::dev::ReturnValue setScanRate(double rate) override
set the scan rate (scans per seconds)
yarp::dev::ReturnValue setDistanceRange(double min, double max) override
set the device detection range.
yarp::dev::PolyDriver m_tc_driver
void calculate(yarp::sig::LaserScan2D scan, yarp::sig::Matrix m)
Interface implemented by all device drivers.
Transform Interface.
The Lidar2DDeviceBase class.
A container for a device driver.
Definition PolyDriver.h:23
A mini-server for performing network communication in the background.
An abstraction for a periodic thread.
PeriodicThread(double period, ShouldUseSystemClock useSystemClock=ShouldUseSystemClock::No, PeriodicThreadClock clockAccuracy=PeriodicThreadClock::Relative)
Constructor.
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:31
An abstraction for a time stamp and/or sequence number.
Definition Stamp.h:21
A class for a Matrix.
Definition Matrix.h:39
unsigned char byte
The main, catch-all namespace for YARP.
Definition dirs.h:16