Skip to content

Commit

Permalink
Merge pull request #3130 from randaz81/dev2sig_datatypes
Browse files Browse the repository at this point in the history
dev to sig datatypes migration
  • Loading branch information
randaz81 authored Sep 4, 2024
2 parents 5d84128 + 3ee438f commit d3b2af0
Show file tree
Hide file tree
Showing 64 changed files with 721 additions and 172 deletions.
5 changes: 4 additions & 1 deletion doc/release/master.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ New Features
#### `lib_yarp_dev`

* `Drivers.cpp` If the user requests for a not existing plugin, the system now prints a message suggesting devices with similar names
* The following data types have been migrated from `yarp_dev` to `yarp_sig` library: `AudioPlayerStatus, AudioRecorderStatus, AudioBufferSize, AudioBufferSizeData, LaserMeasurementData, LaserScan2D`.

#### `lib_yarp_sig`

* Improvements to serialization class `yarp::sig::Sound` (breaking change)
* Improvements to serialization class `yarp::sig::Sound` (breaking change)
* yarp_sig can now use IDL thrift to generate custom data types.
* The following data types have been migrated from `yarp_dev` to `yarp_sig` library: `AudioPlayerStatus, AudioRecorderStatus, AudioBufferSize, AudioBufferSizeData, LaserMeasurementData, LaserScan2D`.
5 changes: 3 additions & 2 deletions src/devices/ffmpeg/FfmpegGrabber.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ extern "C" {
#include <yarp/dev/AudioVisualInterfaces.h>
#include <yarp/dev/IFrameGrabberImage.h>
#include <yarp/dev/DeviceDriver.h>
#include <yarp/sig/AudioBufferSize.h>

#include "ffmpeg_api.h"
#include "FfmpegGrabber_ParamsParser.h"
Expand Down Expand Up @@ -89,11 +90,11 @@ class FfmpegGrabber :
return false;
}

bool getRecordingAudioBufferMaxSize(yarp::dev::AudioBufferSize&) override {
bool getRecordingAudioBufferMaxSize(yarp::sig::AudioBufferSize&) override {
return false;
}

bool getRecordingAudioBufferCurrentSize(yarp::dev::AudioBufferSize&) override {
bool getRecordingAudioBufferCurrentSize(yarp::sig::AudioBufferSize&) override {
return false;
}

Expand Down
6 changes: 3 additions & 3 deletions src/devices/laserFromExternalPort/laserFromExternalPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ InputPortProcessor::InputPortProcessor()
m_contains_data=false;
}

void InputPortProcessor::onRead(yarp::dev::LaserScan2D& b)
void InputPortProcessor::onRead(yarp::sig::LaserScan2D& b)
{
m_port_mutex.lock();
m_lastScan = b;
Expand All @@ -56,7 +56,7 @@ void InputPortProcessor::onRead(yarp::dev::LaserScan2D& b)
m_port_mutex.unlock();
}

inline void InputPortProcessor::getLast(yarp::dev::LaserScan2D& data, Stamp& stmp)
inline void InputPortProcessor::getLast(yarp::sig::LaserScan2D& data, Stamp& stmp)
{
//this blocks untils the first data is received;
size_t counter =0;
Expand Down Expand Up @@ -292,7 +292,7 @@ bool LaserFromExternalPort::threadInit()
return true;
}

void LaserFromExternalPort::calculate(yarp::dev::LaserScan2D scan_data, yarp::sig::Matrix m)
void LaserFromExternalPort::calculate(yarp::sig::LaserScan2D scan_data, yarp::sig::Matrix m)
{
yarp::sig::Vector temp(3);
temp = yarp::math::dcm2rpy(m);
Expand Down
18 changes: 9 additions & 9 deletions src/devices/laserFromExternalPort/laserFromExternalPort.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <yarp/os/Stamp.h>
#include <yarp/dev/ControlBoardInterfaces.h>
#include <yarp/dev/IRangefinder2D.h>
#include <yarp/dev/LaserScan2D.h>
#include <yarp/sig/LaserScan2D.h>
#include <yarp/dev/Lidar2DDeviceBase.h>
#include <yarp/sig/Vector.h>
#include <yarp/dev/IFrameTransform.h>
Expand All @@ -34,26 +34,26 @@ enum base_enum
};

class InputPortProcessor :
public yarp::os::BufferedPort<yarp::dev::LaserScan2D>
public yarp::os::BufferedPort<yarp::sig::LaserScan2D>
{
std::mutex m_port_mutex;
yarp::dev::LaserScan2D m_lastScan;
yarp::sig::LaserScan2D m_lastScan;
yarp::os::Stamp m_lastStamp;
bool m_contains_data;

public:
InputPortProcessor(const InputPortProcessor& alt) :
yarp::os::BufferedPort<yarp::dev::LaserScan2D>(),
yarp::os::BufferedPort<yarp::sig::LaserScan2D>(),
m_lastScan(alt.m_lastScan),
m_lastStamp(alt.m_lastStamp),
m_contains_data(alt.m_contains_data)
{
}

InputPortProcessor();
using yarp::os::BufferedPort<yarp::dev::LaserScan2D>::onRead;
void onRead(yarp::dev::LaserScan2D& v) override;
void getLast(yarp::dev::LaserScan2D& data, yarp::os::Stamp& stmp);
using yarp::os::BufferedPort<yarp::sig::LaserScan2D>::onRead;
void onRead(yarp::sig::LaserScan2D& v) override;
void getLast(yarp::sig::LaserScan2D& data, yarp::os::Stamp& stmp);
};

/**
Expand Down Expand Up @@ -93,7 +93,7 @@ class LaserFromExternalPort : public yarp::dev::Lidar2DDeviceBase,
std::vector <std::string> m_port_names;
std::vector<InputPortProcessor> m_input_ports;
std::vector <yarp::os::Stamp> m_last_stamp;
std::vector <yarp::dev::LaserScan2D> m_last_scan_data;
std::vector<yarp::sig::LaserScan2D> m_last_scan_data;
yarp::dev::PolyDriver m_tc_driver;
yarp::dev::IFrameTransform* m_iTc = nullptr;

Expand All @@ -102,7 +102,7 @@ class LaserFromExternalPort : public yarp::dev::Lidar2DDeviceBase,
yarp::sig::Vector m_empty_laser_data;
base_enum m_base_type;

void calculate(yarp::dev::LaserScan2D scan, yarp::sig::Matrix m);
void calculate(yarp::sig::LaserScan2D scan, yarp::sig::Matrix m);

public:
LaserFromExternalPort(double period = 0.01) : Lidar2DDeviceBase(), PeriodicThread(period)
Expand Down
2 changes: 2 additions & 0 deletions src/devices/laserFromPointCloud/laserFromPointCloud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#define DEG2RAD M_PI/180.0
#endif

using namespace yarp::sig;

YARP_LOG_COMPONENT(LASER_FROM_POINTCLOUD, "yarp.devices.laserFromPointCloud")

/*
Expand Down
1 change: 1 addition & 0 deletions src/devices/laserHokuyo/laserHokuyo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define DEG2RAD M_PI/180.0
#endif

using namespace yarp::sig;

namespace {
YARP_LOG_COMPONENT(LASERHOKUYO, "yarp.devices.laserHokuyo")
Expand Down
2 changes: 1 addition & 1 deletion src/devices/laserHokuyo/laserHokuyo.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class laserHokuyo : public PeriodicThread, public yarp::dev::IRangefinder2D, pub
public:
//IRangefinder2D interface
bool getRawData(yarp::sig::Vector &data, double* timestamp) override;
bool getLaserMeasurement(std::vector<LaserMeasurementData> &data, double* timestamp) override;
bool getLaserMeasurement(std::vector<yarp::sig::LaserMeasurementData> &data, double* timestamp) override;
bool getDeviceStatus (Device_status &status) override;
bool getDeviceInfo (std::string &device_info) override;
bool getDistanceRange (double& min, double& max) override;
Expand Down
10 changes: 5 additions & 5 deletions src/devices/messages/IAudioGrabberMsgs/IAudioGrabberMsgs.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ struct return_isRecording {
2: bool isRecording = false;
}

struct yarp_dev_AudioBufferSize {
struct yarp_sig_AudioBufferSize {
} (
yarp.name = "yarp::dev::AudioBufferSize"
yarp.includefile = "yarp/dev/AudioBufferSize.h"
yarp.name = "yarp::sig::AudioBufferSize"
yarp.includefile = "yarp/sig/AudioBufferSize.h"
)

struct yarp_sig_Sound {
Expand All @@ -29,12 +29,12 @@ struct return_getSound {

struct return_getRecordingAudioBufferCurrentSize {
1: bool ret = false;
2: yarp_dev_AudioBufferSize bufsize;
2: yarp_sig_AudioBufferSize bufsize;
}

struct return_getRecordingAudioBufferMaxSize {
1: bool ret = false;
2: yarp_dev_AudioBufferSize bufsize;
2: yarp_sig_AudioBufferSize bufsize;
}

typedef i32 ( yarp.type = "size_t" ) size_t
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Rangefinder2DInputPortProcessor::Rangefinder2DInputPortProcessor()
resetStat();
}

void Rangefinder2DInputPortProcessor::onRead(yarp::dev::LaserScan2D&b)
void Rangefinder2DInputPortProcessor::onRead(yarp::sig::LaserScan2D& b)
{
now=SystemClock::nowSystem();
mutex.lock();
Expand Down Expand Up @@ -102,7 +102,7 @@ void Rangefinder2DInputPortProcessor::onRead(yarp::dev::LaserScan2D&b)
mutex.unlock();
}

inline int Rangefinder2DInputPortProcessor::getLast(yarp::dev::LaserScan2D&data, Stamp &stmp)
inline int Rangefinder2DInputPortProcessor::getLast(yarp::sig::LaserScan2D& data, Stamp& stmp)
{
mutex.lock();
int ret=state;
Expand Down Expand Up @@ -286,7 +286,7 @@ bool Rangefinder2DClient::close()

bool Rangefinder2DClient::getRawData(yarp::sig::Vector &data, double* timestamp)
{
yarp::dev::LaserScan2D scan;
yarp::sig::LaserScan2D scan;
inputPort.getLast(scan, lastTs);

data = scan.scans;
Expand All @@ -300,7 +300,7 @@ bool Rangefinder2DClient::getRawData(yarp::sig::Vector &data, double* timestamp)

bool Rangefinder2DClient::getLaserMeasurement(std::vector<LaserMeasurementData> &data, double* timestamp)
{
yarp::dev::LaserScan2D scan;
yarp::sig::LaserScan2D scan;
inputPort.getLast(scan, lastTs);
size_t size = scan.scans.size();
data.resize(size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <yarp/dev/IRangefinder2D.h>
#include <yarp/dev/ControlBoardInterfaces.h>
#include <yarp/dev/ControlBoardHelpers.h>
#include <yarp/dev/LaserScan2D.h>
#include <yarp/sig/LaserScan2D.h>
#include <yarp/sig/Vector.h>
#include <yarp/os/Time.h>
#include <yarp/dev/PolyDriver.h>
Expand All @@ -25,9 +25,9 @@
const int LASER_TIMEOUT=100; //ms

class Rangefinder2DInputPortProcessor :
public yarp::os::BufferedPort<yarp::dev::LaserScan2D>
public yarp::os::BufferedPort<yarp::sig::LaserScan2D>
{
yarp::dev::LaserScan2D lastScan;
yarp::sig::LaserScan2D lastScan;
std::mutex mutex;
yarp::os::Stamp lastStamp;
double deltaT;
Expand All @@ -45,10 +45,10 @@ class Rangefinder2DInputPortProcessor :

Rangefinder2DInputPortProcessor();

using yarp::os::BufferedPort<yarp::dev::LaserScan2D>::onRead;
void onRead(yarp::dev::LaserScan2D&v) override;
using yarp::os::BufferedPort<yarp::sig::LaserScan2D>::onRead;
void onRead(yarp::sig::LaserScan2D& v) override;

inline int getLast(yarp::dev::LaserScan2D &data, yarp::os::Stamp &stmp);
inline int getLast(yarp::sig::LaserScan2D& data, yarp::os::Stamp& stmp);

inline int getIterations();

Expand Down Expand Up @@ -105,7 +105,7 @@ class Rangefinder2DClient:
* @param data a vector containing the measurement data, expressed in cartesian/polar format
* @return true/false..
*/
bool getLaserMeasurement(std::vector<yarp::dev::LaserMeasurementData> &data, double* timestamp = nullptr) override;
bool getLaserMeasurement(std::vector<yarp::sig::LaserMeasurementData> &data, double* timestamp = nullptr) override;

/**
* Get the device measurements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Rangefinder2DInputPortProcessor::Rangefinder2DInputPortProcessor()
resetStat();
}

void Rangefinder2DInputPortProcessor::onRead(yarp::dev::LaserScan2D&b)
void Rangefinder2DInputPortProcessor::onRead(yarp::sig::LaserScan2D& b)
{
now=SystemClock::nowSystem();
mutex.lock();
Expand Down Expand Up @@ -103,7 +103,7 @@ void Rangefinder2DInputPortProcessor::onRead(yarp::dev::LaserScan2D&b)
mutex.unlock();
}

inline int Rangefinder2DInputPortProcessor::getLast(yarp::dev::LaserScan2D&data, Stamp &stmp)
inline int Rangefinder2DInputPortProcessor::getLast(yarp::sig::LaserScan2D& data, Stamp& stmp)
{
mutex.lock();
int ret=state;
Expand Down Expand Up @@ -204,7 +204,7 @@ bool Rangefinder2D_nwc_yarp::close()

bool Rangefinder2D_nwc_yarp::getRawData(yarp::sig::Vector &data, double* timestamp)
{
yarp::dev::LaserScan2D scan;
yarp::sig::LaserScan2D scan;
m_inputPort.getLast(scan, m_lastTs);

data = scan.scans;
Expand All @@ -218,7 +218,7 @@ bool Rangefinder2D_nwc_yarp::getRawData(yarp::sig::Vector &data, double* timesta

bool Rangefinder2D_nwc_yarp::getLaserMeasurement(std::vector<LaserMeasurementData> &data, double* timestamp)
{
yarp::dev::LaserScan2D scan;
yarp::sig::LaserScan2D scan;
m_inputPort.getLast(scan, m_lastTs);
size_t size = scan.scans.size();
data.resize(size);
Expand Down
Loading

0 comments on commit d3b2af0

Please sign in to comment.