YARP
Yet Another Robot Platform
stateExtendedReader.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 #ifndef YARP_DEV_REMOTECONTROLBOARD_STATEEXTENDEDREADER_H
10 #define YARP_DEV_REMOTECONTROLBOARD_STATEEXTENDEDREADER_H
11 
12 
13 #include <yarp/os/PortablePair.h>
14 #include <yarp/os/BufferedPort.h>
15 #include <yarp/os/Time.h>
16 #include <yarp/os/Network.h>
17 #include <yarp/os/Thread.h>
18 #include <yarp/os/Vocab.h>
19 #include <yarp/os/Stamp.h>
20 #include <yarp/os/Log.h>
21 
22 #include <yarp/sig/Vector.h>
23 
25 #include <yarp/dev/PolyDriver.h>
29 
31 
32 #include <cstring>
33 #include <mutex>
34 
35 // encoders should arrive at least every 0.5s to be considered valide
36 // getEncoders will return false otherwise.
37 
38 using namespace yarp::os;
39 using namespace yarp::dev;
40 using namespace yarp::sig;
41 
43  public yarp::os::BufferedPort<yarp::dev::impl::jointData>
44 {
46  std::mutex mutex;
47  Stamp lastStamp;
48  double deltaT;
49  double deltaTMax;
50  double deltaTMin;
51  double now;
52  double prev;
53  double timeout;
54 
55  bool valid;
56  int count;
57 public:
58 
60 
61  void resetStat();
62  void init(int numberOfJoints);
63 
65  void onRead(yarp::dev::impl::jointData &v) override;
66 
71  void setTimeout(const double& timeout);
72 
73  // use vocab to identify the data to be read
74  // get a value for a single joint
75  bool getLastSingle(int j, int field, double *data, Stamp &stamp, double &localArrivalTime);
76  bool getLastSingle(int j, int field, int *data, Stamp &stamp, double &localArrivalTime);
77 
78  // get a value for all joints
79  bool getLastVector(int field, double *data, Stamp &stamp, double &localArrivalTime);
80  bool getLastVector(int field, int *data, Stamp &stamp, double &localArrivalTime);
81  int getIterations();
82 
83  // time is in ms
84  void getEstFrequency(int &ite, double &av, double &min, double &max);
85 };
86 
87 #endif // YARP_DEV_REMOTECONTROLBOARD_STATEEXTENDEDREADER_H
Network.h
StateExtendedInputPort
Definition: stateExtendedReader.h:44
Vector.h
contains the definition of a Vector type
yarp::sig
Signal processing.
Definition: Image.h:25
IPreciselyTimed.h
ControlBoardHelpers.h
ControlBoardInterfaces.h
define control board standard interfaces
PortablePair.h
yarp::os::Time::now
double now()
Return the current time in seconds, relative to an arbitrary starting point.
Definition: Time.cpp:124
yarp::dev
An interface for the device drivers.
Definition: audioBufferSizeData.cpp:17
yarp::dev::impl::jointData
Definition: jointData.h:29
yarp::os::BufferedPort
A mini-server for performing network communication in the background.
Definition: BufferedPort.h:64
Log.h
PolyDriver.h
Stamp.h
Thread.h
BufferedPort.h
yarp::os::Stamp
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:25
jointData.h
yarp::os
An interface to the operating system, including Port based communication.
Definition: AbstractCarrier.h:17
Vocab.h
ControlBoardInterfacesImpl.h
Time.h