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//---------------------------------------------------------------------------------------------------------------
35
37 public yarp::os::BufferedPort<yarp::dev::LaserScan2D>
38{
39 std::mutex m_port_mutex;
40 yarp::dev::LaserScan2D m_lastScan;
41 yarp::os::Stamp m_lastStamp;
42 bool m_contains_data;
43
44public:
46 yarp::os::BufferedPort<yarp::dev::LaserScan2D>(),
47 m_lastScan(alt.m_lastScan),
48 m_lastStamp(alt.m_lastStamp),
49 m_contains_data(alt.m_contains_data)
50 {
51 }
52
55 void onRead(yarp::dev::LaserScan2D& v) override;
57};
58
90{
91protected:
93 std::vector <std::string> m_port_names;
94 std::vector<InputPortProcessor> m_input_ports;
95 std::vector <yarp::os::Stamp> m_last_stamp;
96 std::vector <yarp::dev::LaserScan2D> m_last_scan_data;
99
100 std::vector <std::string> m_src_frame_id;
101 std::string m_dst_frame_id;
104
106
107public:
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 bool setDistanceRange (double min, double max) override;
127 bool setScanLimits (double min, double max) override;
128 bool setHorizontalResolution (double step) override;
129 bool 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
InputPortProcessor(const InputPortProcessor &alt)
void getLast(yarp::dev::LaserScan2D &data, yarp::os::Stamp &stmp)
void onRead(yarp::dev::LaserScan2D &v) override
laserFromExternalPort: Documentation to be added
std::vector< InputPortProcessor > m_input_ports
bool close() override
Close the DeviceDriver.
std::vector< yarp::dev::LaserScan2D > m_last_scan_data
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
bool setScanRate(double rate) override
set the scan rate (scans per seconds)
void calculate(yarp::dev::LaserScan2D scan, yarp::sig::Matrix m)
bool setHorizontalResolution(double step) override
get the angular step between two measurements (if available)
bool acquireDataFromHW() override final
This method should be implemented by the user, and contain the logic to grab data from the hardware.
bool setDistanceRange(double min, double max) override
set the device detection range.
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.
bool setScanLimits(double min, double max) override
set the scan angular range.
yarp::dev::PolyDriver m_tc_driver
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