YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
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
11#include <yarp/os/Time.h>
12#include <yarp/os/Network.h>
13#include <yarp/os/Thread.h>
14#include <yarp/os/Vocab.h>
15#include <yarp/os/Stamp.h>
16#include <yarp/os/Log.h>
17
18#include <yarp/sig/Vector.h>
19
21#include <yarp/dev/PolyDriver.h>
25
27
28#include <cstring>
29#include <mutex>
30
31// encoders should arrive at least every 0.5s to be considered valid
32// getEncoders will return false otherwise.
33
34using namespace yarp::os;
35using namespace yarp::dev;
36using namespace yarp::sig;
37
39 public yarp::os::BufferedPort<yarp::dev::JointStateData>
40{
42 std::mutex mutex;
43 Stamp lastStamp;
44 double deltaT;
45 double deltaTMax;
46 double deltaTMin;
47 double now;
48 double prev;
49 double timeout;
50
51 bool valid;
52 int count;
53public:
54
56
57 void resetStat();
58 void init(int numberOfJoints);
59
61 void onRead(yarp::dev::JointStateData& v) override;
62
67 void setTimeout(const double& timeout);
68
69 // use vocab to identify the data to be read
70 // get a value for a single joint
71 bool getLastSingle(int j, int field, double *data, Stamp &stamp, double &localArrivalTime);
72 bool getLastSingle(int j, int field, int *data, Stamp &stamp, double &localArrivalTime);
73
74 // get a value for all joints
75 bool getLastVector(int field, double *data, Stamp &stamp, double &localArrivalTime);
76 bool getLastVector(int field, int *data, Stamp &stamp, double &localArrivalTime);
77 int getIterations();
78
79 // time is in ms
80 void getEstFrequency(int &ite, double &av, double &min, double &max);
81};
82
83#endif // YARP_DEV_REMOTECONTROLBOARD_STATEEXTENDEDREADER_H
define control board standard interfaces
contains the definition of a Vector type
void onRead(yarp::dev::JointStateData &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.
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.
Definition OSTestMsg.cpp:13