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 
10 #include <yarp/os/PortablePair.h>
11 #include <yarp/os/BufferedPort.h>
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 
35 using namespace yarp::os;
36 using namespace yarp::dev;
37 using 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;
54 public:
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
A mini-server for performing network communication in the background.
Definition: BufferedPort.h:61
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:22
An interface for the device drivers.
double now()
Return the current time in seconds, relative to an arbitrary starting point.
Definition: Time.cpp:121
An interface to the operating system, including Port based communication.
Signal processing.
Definition: Image.h:22