yarp-devices
Loading...
Searching...
No Matches
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
12namespace roboticslab
13{
14
20{
21public:
22 using TechnosoftIposBase::TechnosoftIposBase;
23
24 // --------- DeviceDriver declarations. Implementation in DeviceDriverImpl.cpp ---------
25
26 bool open(yarp::os::Searchable & config) override;
27 bool close() override;
28
29 // --------- ICanBusSharer declarations. Implementation in ICanBusSharerImpl.cpp ---------
30
31 bool initialize() override;
32 bool synchronize(double timestamp) override;
33
34 // --------- IControlModeRaw declarations. Implementation in IControlModeRawImpl.cpp ---------
35
36 bool getControlModeRaw(int j, int * mode) override;
37 bool setControlModeRaw(int j, int mode) override;
38
39 // ---------- IImpedanceControlRaw declarations. Implementation in IImpedanceControlRawImpl.cpp ----------
40
41 bool getImpedanceRaw(int j, double * stiffness, double * damping) override;
42 bool setImpedanceRaw(int j, double stiffness, double damping) override;
43 bool setImpedanceOffsetRaw(int j, double offset) override;
44 bool getImpedanceOffsetRaw(int j, double * offset) override;
45 bool getCurrentImpedanceLimitRaw(int j, double * min_stiff, double * max_stiff, double * min_damp, double * max_damp) override;
46
47 // ---------- IInteractionModeRaw declarations. Implementation in IInteractionModeRawImpl.cpp ----------
48
49 bool getInteractionModeRaw(int axis, yarp::dev::InteractionModeEnum * mode) override;
50 bool setInteractionModeRaw(int axis, yarp::dev::InteractionModeEnum mode) override;
51
52 // --------- IPidControlRaw declarations. Implementation in IPidControlRawImpl.cpp ---------
53
54 bool setPidRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, const yarp::dev::Pid & pid) override;
55 bool setPidReferenceRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, double ref) override;
56 bool setPidErrorLimitRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, double limit) override;
57 bool getPidErrorRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, double * err) override;
58 bool getPidOutputRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, double * out) override;
59 bool getPidRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, yarp::dev::Pid * pid) override;
60 bool getPidReferenceRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, double * ref) override;
61 bool getPidErrorLimitRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, double * limit) override;
62 bool resetPidRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j) override;
63 bool disablePidRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j) override;
64 bool enablePidRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j) override;
65 bool setPidOffsetRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, double v) override;
66 bool isPidEnabledRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, bool * enabled) override;
67
68 // ------- IPositionControlRaw declarations. Implementation in IPositionControlRawImpl.cpp -------
69
70 bool positionMoveRaw(int j, double ref) override;
71 bool relativeMoveRaw(int j, double delta) override;
72 bool checkMotionDoneRaw(int j, bool * flag) override;
73 bool setRefSpeedRaw(int j, double sp) override;
74 bool setRefAccelerationRaw(int j, double acc) override;
75 bool getRefSpeedRaw(int j, double * ref) override;
76 bool getRefAccelerationRaw(int j, double * acc) override;
77 bool stopRaw(int j) override;
78 bool getTargetPositionRaw(int joint, double * ref) override;
79
80 // ------- IPositionDirectRaw declarations. Implementation in IPositionDirectRawImpl.cpp -------
81
82 bool setPositionRaw(int j, double ref) override;
83 bool getRefPositionRaw(int joint, double * ref) override;
84
85 // ------- IRemoteVariablesRaw declarations. Implementation in IRemoteVariablesRawImpl.cpp -------
86
87 bool getRemoteVariableRaw(std::string key, yarp::os::Bottle & val) override;
88 bool setRemoteVariableRaw(std::string key, const yarp::os::Bottle & val) override;
89 bool getRemoteVariablesListRaw(yarp::os::Bottle * listOfKeys) override;
90
91 // --------- IVelocityControlRaw declarations. Implementation in IVelocityControlRawImpl.cpp ---------
92
93 bool velocityMoveRaw(int j, double sp) override;
94 bool getRefVelocityRaw(int joint, double * vel) override;
95
96private:
97 void interpretModesOfOperation(std::int8_t modesOfOperation) override;
98 void onPositionLimitTriggered() override;
99 void reset() override;
100
101 yarp::conf::vocab32_t initialInteractionMode {0};
102 std::atomic<yarp::dev::InteractionModeEnum> actualInteractionMode {yarp::dev::InteractionModeEnum::VOCAB_IM_UNKNOWN};
103
104 std::mutex pidMutex;
105
106 yarp::dev::Pid * activePid {nullptr};
107 yarp::dev::Pid positionPid;
108 yarp::dev::Pid impedancePid;
109
110 double positionReference {0.0};
111 double errorLimit {0.0};
112 double proportionalError {0.0};
113 double integralError {0.0};
114
115 TrapezoidalTrajectory trajectory;
116
117 std::atomic<bool> enableCsv {false};
118};
119
120} // namespace roboticslab
121
122#endif // __TECHNOSOFT_IPOS_EXTERNAL_HPP__
Base class for all proxied TechnosoftIpos implementations.
Definition TechnosoftIposBase.hpp:74
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