NJointJointSpaceDMPController.h
Go to the documentation of this file.
1
2#pragma once
3
4#include <VirtualRobot/VirtualRobot.h>
5
7
8#include <armarx/control/deprecated_njoint_mp_controller/joint_space/ControllerInterface.h>
9
10#include <dmp/representation/systemstatus.h>
11
12namespace armarx
13{
14 class SensorValue1DoFActuatorTorque;
15 class SensorValue1DoFActuatorVelocity;
16 class SensorValue1DoFActuatorPosition;
17 class SensorValue1DoFGravityTorque;
18 class ControlTarget1DoFActuatorTorque;
19 class ControlTarget1DoFActuatorVelocity;
20} // namespace armarx
21
22namespace DMP
23{
24 // using UMITSMPPtr = boost::shared_ptr<class UMITSMP>;
25 using UMIDMPPtr = ::boost::shared_ptr<class UMIDMP>;
26} // namespace DMP
27
29{
30
32
34
36 {
37 public:
38 double tau;
39 bool isStart;
40 };
41
42 // class SimplePID
43 // {
44 // public:
45 // float Kp = 0, Kd = 0;
46 // float lastError = 0;
47 // float update(float dt, float error);
48 // };
49
50 /**
51 * @brief The NJointJointSpaceDMPController class
52 * @ingroup Library-RobotUnit-NJointControllers
53 */
55 public NJointControllerWithTripleBuffer<NJointJointSpaceDMPControllerControlData>,
57 {
58 public:
59 using ConfigPtrT = NJointJointSpaceDMPControllerConfigPtr;
61 const NJointControllerConfigPtr& config,
63
64 // NJointControllerInterface interface
65 std::string getClassName(const Ice::Current&) const override;
66
67 // NJointController interface
68 void rtRun(const IceUtil::Time& sensorValuesTimestamp,
69 const IceUtil::Time& timeSinceLastIteration) override;
70
71 //
72 bool
73 isFinished(const Ice::Current&) override
74 {
75 return finished;
76 }
77
78 void learnDMPFromFiles(const Ice::StringSeq& fileNames, const Ice::Current&) override;
79 void setTemporalFactor(double tau, const Ice::Current&) override;
80
81 void runDMP(const Ice::DoubleSeq& goals, double tau, const Ice::Current&) override;
82
83 void showMessages(const Ice::Current&) override;
84
85 protected:
86 void rtPreActivateController() override;
87 void rtPostDeactivateController() override;
88
89 virtual void onPublish(const SensorAndControl&,
91 const DebugObserverInterfacePrx&) override;
92
93 private:
94 struct DebugBufferData
95 {
96 StringFloatDictionary latestTargetVelocities;
97 StringFloatDictionary dmpTargetState;
98 double currentCanVal;
99 double mpcFactor;
100 };
101
102 std::map<std::string, const SensorValue1DoFActuatorTorque*> torqueSensors;
103 std::map<std::string, const SensorValue1DoFGravityTorque*> gravityTorqueSensors;
104 std::map<std::string, const SensorValue1DoFActuatorPosition*> positionSensors;
105 std::map<std::string, const SensorValue1DoFActuatorVelocity*> velocitySensors;
106 std::map<std::string, ControlTarget1DoFActuatorVelocity*> targets;
107
108
109 TripleBuffer<DebugBufferData> debugOutputData;
110
111
112 std::vector<double> goals;
113 DMP::UMIDMPPtr dmpPtr;
114 bool DMPAsForwardControl;
115 double timeDuration;
116
117 double canVal;
118
119 double tau;
120 double finished;
121
122 // phaseStop parameters
123 double phaseL;
124 double phaseK;
125 double phaseDist0;
126 double phaseDist1;
127 double phaseKp;
128
129 double mpcFactor;
130
131 bool isDisturbance;
132 std::vector<std::string> dimNames;
133 DMP::Vec<DMP::DMPState> currentState;
134 DMP::DVec targetState;
135 };
136
137} // namespace armarx::control::deprecated_njoint_mp_controller::joint_space
#define TYPEDEF_PTRS_HANDLE(T)
NJointControllerWithTripleBuffer(const NJointJointSpaceDMPControllerControlData &initialCommands=NJointJointSpaceDMPControllerControlData())
A simple triple buffer for lockfree comunication between a single writer and a single reader.
virtual void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &) override
void rtPostDeactivateController() override
This function is called after the controller is deactivated.
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration) override
TODO make protected and use attorneys.
void runDMP(const Ice::DoubleSeq &goals, double tau, const Ice::Current &) override
NJointJointSpaceDMPController(RobotUnitPtr prov, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
void rtPreActivateController() override
This function is called before the controller is activated.
Brief description of class targets.
Definition targets.h:39
boost::shared_ptr< class UMIDMP > UMIDMPPtr
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
This file offers overloads of toIce() and fromIce() functions for STL container types.
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface > DebugObserverInterfacePrx
IceUtil::Handle< class RobotUnit > RobotUnitPtr
Definition FTSensor.h:34
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface > DebugDrawerInterfacePrx
detail::ControlThreadOutputBufferEntry SensorAndControl