kinematics-dynamics
StreamingDevice.hpp
1 #ifndef __STREAMING_DEVICE_HPP__
2 #define __STREAMING_DEVICE_HPP__
3 
4 #include <string>
5 #include <vector>
6 
7 #include <yarp/os/Searchable.h>
8 #include <yarp/os/Value.h>
9 #include <yarp/dev/PolyDriver.h>
10 
11 #include "ICartesianControl.h"
12 #include "CentroidTransform.hpp"
13 
14 namespace roboticslab
15 {
16 
17 class StreamingDevice;
18 class CentroidTransform;
19 
26 {
27 public:
34  static StreamingDevice * makeDevice(const std::string & deviceName, yarp::os::Searchable & config);
35 
36 private:
38 };
39 
45 class StreamingDevice : protected yarp::dev::PolyDriver
46 {
47  friend CentroidTransform;
48 
49 public:
50  using PolyDriver::isValid;
51 
56  StreamingDevice(yarp::os::Searchable & config);
57 
59  virtual ~StreamingDevice();
60 
65  virtual bool acquireInterfaces() = 0;
66 
75  virtual bool initialize(bool usingStreamingPreset)
76  {
77  return true;
78  }
79 
84  virtual bool acquireData() = 0;
85 
91  virtual bool transformData(double scaling);
92 
98  virtual int getActuatorState()
99  {
100  return actuatorState;
101  }
102 
108  virtual bool hasValidMovementData() const;
109 
114  virtual void sendMovementCommand(double timestamp) = 0;
115 
119  virtual void stopMotion() = 0;
120 
126  {
127  this->iCartesianControl = iCartesianControl;
128  }
129 
130 protected:
131  ICartesianControl * iCartesianControl;
132 
133  std::vector<double> data;
134  std::vector<bool> fixedAxes;
135 
136  int actuatorState;
137 
138 private:
142  void configureFixedAxes(const yarp::os::Value & v);
143 };
144 
153 {
154 public:
157  : StreamingDevice(yarp::os::Value::getNullValue())
158  {}
159 
160  bool acquireInterfaces() override
161  {
162  return false;
163  }
164 
165  bool acquireData() override
166  {
167  return false;
168  }
169 
170  void sendMovementCommand(double timestamp) override
171  {}
172 
173  void stopMotion() override
174  {}
175 };
176 
177 } // namespace roboticslab
178 
179 #endif // __STREAMING_DEVICE_HPP__
Contains roboticslab::ICartesianControl and related vocabs.
Definition: CentroidTransform.hpp:22
Abstract base class for a cartesian controller.
Definition: ICartesianControl.h:146
Represents an invalid device.
Definition: StreamingDevice.hpp:153
void stopMotion() override
Sends a movement command that would stop motion.
Definition: StreamingDevice.hpp:173
bool acquireInterfaces() override
Acquires plugin interfaces.
Definition: StreamingDevice.hpp:160
bool acquireData() override
Acquires data from remote device.
Definition: StreamingDevice.hpp:165
void sendMovementCommand(double timestamp) override
Sends movement command to the cartesian controller.
Definition: StreamingDevice.hpp:170
InvalidDevice()
Creates an invalid device.
Definition: StreamingDevice.hpp:156
Factory class for creating instances of StreamingDevice.
Definition: StreamingDevice.hpp:26
static StreamingDevice * makeDevice(const std::string &deviceName, yarp::os::Searchable &config)
Creates a new YARP device handle.
Definition: StreamingDevice.cpp:15
Abstract class for a YARP streaming device.
Definition: StreamingDevice.hpp:46
virtual bool transformData(double scaling)
Performs required operations on stored data.
Definition: StreamingDevice.cpp:62
virtual bool acquireData()=0
Acquires data from remote device.
virtual void stopMotion()=0
Sends a movement command that would stop motion.
virtual bool hasValidMovementData() const
Checks whether the device may forward acquired and processed data to the controller.
Definition: StreamingDevice.cpp:79
virtual int getActuatorState()
If actuator command data is available, return its current state.
Definition: StreamingDevice.hpp:98
virtual void sendMovementCommand(double timestamp)=0
Sends movement command to the cartesian controller.
virtual bool acquireInterfaces()=0
Acquires plugin interfaces.
void setCartesianControllerHandle(ICartesianControl *iCartesianControl)
Stores handle to an ICartesianControl instance.
Definition: StreamingDevice.hpp:125
virtual bool initialize(bool usingStreamingPreset)
Perform any custom initialization needed. This method is called after the successful creation of the ...
Definition: StreamingDevice.hpp:75
virtual ~StreamingDevice()
Destructor.
Definition: StreamingDevice.cpp:57
void configureFixedAxes(const yarp::os::Value &v)
Stores vector of values representing axes that are always fixed.
Definition: StreamingDevice.cpp:97
StreamingDevice(yarp::os::Searchable &config)
Constructor.
Definition: StreamingDevice.cpp:46
The main, catch-all namespace for Robotics Lab UC3M.
Definition: groups.dox:6