YARP
Yet Another Robot Platform
stateExtendedReader.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef YARP_DEV_REMOTECONTROLBOARD_STATEEXTENDEDREADER_H
7#define YARP_DEV_REMOTECONTROLBOARD_STATEEXTENDEDREADER_H
8
9
12#include <yarp/os/Time.h>
13#include <yarp/os/Network.h>
14#include <yarp/os/Thread.h>
15#include <yarp/os/Vocab.h>
16#include <yarp/os/Stamp.h>
17#include <yarp/os/Log.h>
18
19#include <yarp/sig/Vector.h>
20
22#include <yarp/dev/PolyDriver.h>
26
28
29#include <cstring>
30#include <mutex>
31
32// encoders should arrive at least every 0.5s to be considered valide
33// getEncoders will return false otherwise.
34
35using namespace yarp::os;
36using namespace yarp::dev;
37using namespace yarp::sig;
38
40 public yarp::os::BufferedPort<yarp::dev::impl::jointData>
41{
43 std::mutex mutex;
44 Stamp lastStamp;
45 double deltaT;
46 double deltaTMax;
47 double deltaTMin;
48 double now;
49 double prev;
50 double timeout;
51
52 bool valid;
53 int count;
54public:
55
57
58 void resetStat();
59 void init(int numberOfJoints);
60
62 void onRead(yarp::dev::impl::jointData &v) override;
63
68 void setTimeout(const double& timeout);
69
70 // use vocab to identify the data to be read
71 // get a value for a single joint
72 bool getLastSingle(int j, int field, double *data, Stamp &stamp, double &localArrivalTime);
73 bool getLastSingle(int j, int field, int *data, Stamp &stamp, double &localArrivalTime);
74
75 // get a value for all joints
76 bool getLastVector(int field, double *data, Stamp &stamp, double &localArrivalTime);
77 bool getLastVector(int field, int *data, Stamp &stamp, double &localArrivalTime);
78 int getIterations();
79
80 // time is in ms
81 void getEstFrequency(int &ite, double &av, double &min, double &max);
82};
83
84#endif // YARP_DEV_REMOTECONTROLBOARD_STATEEXTENDEDREADER_H
define control board standard interfaces
contains the definition of a Vector type
void onRead(yarp::dev::impl::jointData &v) override
void setTimeout(const double &timeout)
setTimeout, set the timeout for retrieving data
bool getLastVector(int field, double *data, Stamp &stamp, double &localArrivalTime)
bool getLastSingle(int j, int field, double *data, Stamp &stamp, double &localArrivalTime)
void init(int numberOfJoints)
void getEstFrequency(int &ite, double &av, double &min, double &max)
A mini-server for performing network communication in the background.
Definition: BufferedPort.h:60
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:21
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.