Program Listing for File DdsKinematics2D.hpp¶
↰ Return to documentation for file (sinspekto/DdsKinematics2D.hpp
)
#pragma once
#include "sinspekto/QtToDds.hpp"
#include "QDateTime"
#include "QVector2D"
class DdsKinematics2DSubscriber : public QObject
{
Q_OBJECT
Q_PROPERTY(QVector2D position READ position NOTIFY positionChanged)
Q_PROPERTY(double speed READ speed NOTIFY speedChanged)
Q_PROPERTY(double course READ course NOTIFY courseChanged)
Q_PROPERTY(QDateTime timestamp READ timestamp NOTIFY timestampChanged)
public:
explicit DdsKinematics2DSubscriber(QObject *parent = nullptr);
virtual ~DdsKinematics2DSubscriber();
QVector2D position() const;
double speed() const;
double course() const;
QDateTime timestamp() const;
Q_INVOKABLE void init(
QtToDds* dds,
const QString& topic,
const QString& id,
bool with_listener=true);
signals:
void positionChanged(QVector2D position);
void speedChanged(double speed);
void courseChanged(double course);
void timestampChanged(QDateTime timestamp);
void eventHeard();
public slots:
void updateValues();
private:
std::unique_ptr<sinspekto::Reader<fkin::Kinematics2D>> m_reader;
QString m_id;
};
class DdsKinematics2DPublisher : public QObject
{
Q_OBJECT
Q_PROPERTY(QVector2D position READ position WRITE setPosition NOTIFY positionChanged)
Q_PROPERTY(double speed READ speed WRITE setSpeed NOTIFY speedChanged)
Q_PROPERTY(double course READ course WRITE setCourse NOTIFY courseChanged)
public:
explicit DdsKinematics2DPublisher(QObject *parent = nullptr);
virtual ~DdsKinematics2DPublisher();
QVector2D position() const;
double speed() const;
double course() const;
Q_INVOKABLE void init(
QtToDds* dds,
const QString& topic,
const QString& id);
signals:
void positionChanged(QVector2D position);
void speedChanged(double speed);
void courseChanged(double course);
public slots:
void setPosition(QVector2D position);
void setSpeed(double speed);
void setCourse(double course);
void publish();
private:
std::unique_ptr<sinspekto::Writer<fkin::Kinematics2D>> m_writer;
};