yarp-devices
TechnosoftIposEmbedded.hpp
1 // -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2 
3 #ifndef __TECHNOSOFT_IPOS_EMBEDDED_HPP__
4 #define __TECHNOSOFT_IPOS_EMBEDDED_HPP__
5 
6 #include <atomic>
7 #include <bitset>
8 
9 #include "TechnosoftIposBase.hpp"
10 #include "embedded-pid/InterpolatedPositionBuffer.hpp"
11 
12 namespace roboticslab
13 {
14 
20 {
21 public:
22  // --------- DeviceDriver declarations. Implementation in DeviceDriverImpl.cpp ---------
23 
24  bool open(yarp::os::Searchable & config) override;
25  bool close() override;
26 
27  // --------- ICanBusSharer declarations. Implementation in ICanBusSharerImpl.cpp ---------
28 
29  bool synchronize(double timestamp) override;
30 
31  // --------- IControlModeRaw declarations. Implementation in IControlModeRawImpl.cpp ---------
32 
33  bool getControlModeRaw(int j, int * mode) override;
34  bool setControlModeRaw(int j, int mode) override;
35 
36  // ------- IPositionControlRaw declarations. Implementation in IPositionControlRawImpl.cpp -------
37 
38  bool positionMoveRaw(int j, double ref) override;
39  bool relativeMoveRaw(int j, double delta) override;
40  bool checkMotionDoneRaw(int j, bool * flag) override;
41  bool setRefSpeedRaw(int j, double sp) override;
42  bool setRefAccelerationRaw(int j, double acc) override;
43  bool getRefSpeedRaw(int j, double * ref) override;
44  bool getRefAccelerationRaw(int j, double * acc) override;
45  bool stopRaw(int j) override;
46  bool getTargetPositionRaw(int joint, double * ref) override;
47 
48  // ------- IPositionDirectRaw declarations. Implementation in IPositionDirectRawImpl.cpp -------
49 
50  bool setPositionRaw(int j, double ref) override;
51  bool getRefPositionRaw(int joint, double * ref) override;
52 
53  // ------- IRemoteVariablesRaw declarations. Implementation in IRemoteVariablesRawImpl.cpp -------
54 
55  bool getRemoteVariableRaw(std::string key, yarp::os::Bottle & val) override;
56  bool setRemoteVariableRaw(std::string key, const yarp::os::Bottle & val) override;
57  bool getRemoteVariablesListRaw(yarp::os::Bottle * listOfKeys) override;
58 
59  // --------- IVelocityControlRaw declarations. Implementation in IVelocityControlRawImpl.cpp ---------
60 
61  bool velocityMoveRaw(int j, double sp) override;
62  bool getRefVelocityRaw(int joint, double * vel) override;
63 
64 private:
65  void interpretModesOfOperation(std::int8_t modesOfOperation) override;
66  void interpretIpStatus(std::uint16_t ipStatus) override;
67  void onPositionLimitTriggered() override;
68  void reset() override;
69 
70  InterpolatedPositionBuffer * ipBuffer {nullptr};
71  std::string ipMode;
72  int ipPeriodMs {0};
73 
74  std::bitset<16> ipStatus;
75 
76  std::atomic<bool> ipMotionStarted {false};
77  std::atomic<bool> ipBufferFilled {false};
78  std::atomic<bool> ipBufferEnabled {false};
79 
80  std::atomic<bool> enableSync {false};
81  std::atomic<bool> enableCsv {false};
82 
83  std::atomic<double> targetPosition {0.0};
84  std::atomic<double> targetVelocity {0.0};
85 };
86 
87 } // namespace roboticslab
88 
89 #endif // __TECHNOSOFT_IPOS_EMBEDDED_HPP__
Base class for a PT/PVT buffer of setpoints.
Definition: InterpolatedPositionBuffer.hpp:23
Base class for all proxied TechnosoftIpos implementations.
Definition: TechnosoftIposBase.hpp:72
A TechnosoftIposBase implementation using the firmware-embedded PID.
Definition: TechnosoftIposEmbedded.hpp:20
bool synchronize(double timestamp) override
Perform synchronized action on CAN master's request.
Definition: ICanBusSharerImpl.cpp:9
The main, catch-all namespace for Robotics Lab UC3M.
Definition: groups.dox:6