yarp-devices
TechnosoftIposExternal.hpp
1 // -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2 
3 #ifndef __TECHNOSOFT_IPOS_EXTERNAL_HPP__
4 #define __TECHNOSOFT_IPOS_EXTERNAL_HPP__
5 
6 #include <atomic>
7 #include <mutex>
8 
9 #include "TechnosoftIposBase.hpp"
10 #include "TrapezoidalTrajectory.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 initialize() override;
30  bool synchronize(double timestamp) override;
31 
32  // --------- IControlModeRaw declarations. Implementation in IControlModeRawImpl.cpp ---------
33 
34  bool getControlModeRaw(int j, int * mode) override;
35  bool setControlModeRaw(int j, int mode) override;
36 
37  // ---------- IImpedanceControlRaw declarations. Implementation in IImpedanceControlRawImpl.cpp ----------
38 
39  bool getImpedanceRaw(int j, double * stiffness, double * damping) override;
40  bool setImpedanceRaw(int j, double stiffness, double damping) override;
41  bool setImpedanceOffsetRaw(int j, double offset) override;
42  bool getImpedanceOffsetRaw(int j, double * offset) override;
43  bool getCurrentImpedanceLimitRaw(int j, double * min_stiff, double * max_stiff, double * min_damp, double * max_damp) override;
44 
45  // ---------- IInteractionModeRaw declarations. Implementation in IInteractionModeRawImpl.cpp ----------
46 
47  bool getInteractionModeRaw(int axis, yarp::dev::InteractionModeEnum * mode) override;
48  bool setInteractionModeRaw(int axis, yarp::dev::InteractionModeEnum mode) override;
49 
50  // --------- IPidControlRaw declarations. Implementation in IPidControlRawImpl.cpp ---------
51 
52  bool setPidRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, const yarp::dev::Pid & pid) override;
53  bool setPidReferenceRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, double ref) override;
54  bool setPidErrorLimitRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, double limit) override;
55  bool getPidErrorRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, double * err) override;
56  bool getPidOutputRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, double * out) override;
57  bool getPidRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, yarp::dev::Pid * pid) override;
58  bool getPidReferenceRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, double * ref) override;
59  bool getPidErrorLimitRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, double * limit) override;
60  bool resetPidRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j) override;
61  bool disablePidRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j) override;
62  bool enablePidRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j) override;
63  bool setPidOffsetRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, double v) override;
64  bool isPidEnabledRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, bool * enabled) override;
65 
66  // ------- IPositionControlRaw declarations. Implementation in IPositionControlRawImpl.cpp -------
67 
68  bool positionMoveRaw(int j, double ref) override;
69  bool relativeMoveRaw(int j, double delta) override;
70  bool checkMotionDoneRaw(int j, bool * flag) override;
71  bool setRefSpeedRaw(int j, double sp) override;
72  bool setRefAccelerationRaw(int j, double acc) override;
73  bool getRefSpeedRaw(int j, double * ref) override;
74  bool getRefAccelerationRaw(int j, double * acc) override;
75  bool stopRaw(int j) override;
76  bool getTargetPositionRaw(int joint, double * ref) override;
77 
78  // ------- IPositionDirectRaw declarations. Implementation in IPositionDirectRawImpl.cpp -------
79 
80  bool setPositionRaw(int j, double ref) override;
81  bool getRefPositionRaw(int joint, double * ref) override;
82 
83  // ------- IRemoteVariablesRaw declarations. Implementation in IRemoteVariablesRawImpl.cpp -------
84 
85  bool getRemoteVariableRaw(std::string key, yarp::os::Bottle & val) override;
86  bool setRemoteVariableRaw(std::string key, const yarp::os::Bottle & val) override;
87  bool getRemoteVariablesListRaw(yarp::os::Bottle * listOfKeys) override;
88 
89  // --------- IVelocityControlRaw declarations. Implementation in IVelocityControlRawImpl.cpp ---------
90 
91  bool velocityMoveRaw(int j, double sp) override;
92  bool getRefVelocityRaw(int joint, double * vel) override;
93 
94 private:
95  void interpretModesOfOperation(std::int8_t modesOfOperation) override;
96  void onPositionLimitTriggered() override;
97  void reset() override;
98 
99  yarp::conf::vocab32_t initialInteractionMode {0};
100  std::atomic<yarp::dev::InteractionModeEnum> actualInteractionMode {yarp::dev::InteractionModeEnum::VOCAB_IM_UNKNOWN};
101 
102  double minStiffness {0.0};
103  double maxStiffness {0.0};
104  double minDamping {0.0};
105  double maxDamping {0.0};
106 
107  std::mutex pidMutex;
108 
109  yarp::dev::Pid * activePid {nullptr};
110  yarp::dev::Pid positionPid;
111  yarp::dev::Pid impedancePid;
112 
113  double positionReference {0.0};
114  double errorLimit {0.0};
115  double proportionalError {0.0};
116  double integralError {0.0};
117 
118  TrapezoidalTrajectory trajectory;
119 
120  std::atomic<bool> enableCsv {false};
121 };
122 
123 } // namespace roboticslab
124 
125 #endif // __TECHNOSOFT_IPOS_EXTERNAL_HPP__
Base class for all proxied TechnosoftIpos implementations.
Definition: TechnosoftIposBase.hpp:72
A TechnosoftIposBase implementation using an external (TEO board) PID.
Definition: TechnosoftIposExternal.hpp:20
bool synchronize(double timestamp) override
Perform synchronized action on CAN master's request.
Definition: ICanBusSharerImpl.cpp:17
bool initialize() override
Perform CAN node initialization.
Definition: ICanBusSharerImpl.cpp:9
Definition: TrapezoidalTrajectory.hpp:17
The main, catch-all namespace for Robotics Lab UC3M.
Definition: groups.dox:6