NJointPeriodicTSDMPForwardVelController.h
Go to the documentation of this file.
1#pragma once
2
3
4// Simox
5#include <VirtualRobot/VirtualRobot.h>
6
7// armarx
10
13
14// control
16#include <armarx/control/deprecated_njoint_mp_controller/task_space/ControllerInterface.h>
17
18namespace armarx
19{
20 class SensorValue1DoFActuatorTorque;
21 class SensorValue1DoFActuatorVelocity;
22 class SensorValue1DoFActuatorPosition;
23 class ControlTarget1DoFActuatorTorque;
24 class ControlTarget1DoFActuatorVelocity;
26} // namespace armarx
27
29{
30 namespace tsvmp = armarx::control::deprecated_njoint_mp_controller::tsvmp;
31
34
36 {
37 public:
38 Eigen::VectorXf targetTSVel;
39 Eigen::Matrix4f targetPose;
40 };
41
42 /**
43 * @brief The NJointPeriodicTSDMPForwardVelController class
44 * @ingroup Library-RobotUnit-NJointControllers
45 */
47 public NJointControllerWithTripleBuffer<NJointPeriodicTSDMPForwardVelControllerControlData>,
49 {
50 public:
51 using ConfigPtrT = NJointPeriodicTSDMPControllerConfigPtr;
53 const NJointControllerConfigPtr& config,
55
56 // NJointControllerInterface interface
57 std::string getClassName(const Ice::Current&) const;
58
59 // NJointController interface
60
61 void rtRun(const IceUtil::Time& sensorValuesTimestamp,
62 const IceUtil::Time& timeSinceLastIteration);
63
64 // NJointPeriodicTSDMPForwardVelControllerInterface interface
65 void learnDMPFromFiles(const Ice::StringSeq& fileNames, const Ice::Current&);
66
67 bool
68 isFinished(const Ice::Current&)
69 {
70 return finished;
71 }
72
73 void runDMP(const Ice::DoubleSeq& goals, double tau, const Ice::Current&);
74 void setSpeed(Ice::Double times, const Ice::Current&);
75 void setGoals(const Ice::DoubleSeq& goals, const Ice::Current&);
76 void setAmplitude(Ice::Double amp, const Ice::Current&);
77
78 double
79 getCanVal(const Ice::Current&)
80 {
81 return dmpCtrl->canVal;
82 }
83
84 protected:
85 virtual void onPublish(const SensorAndControl&,
88
91 void controllerRun();
92
93 private:
94 struct DebugBufferData
95 {
96 StringFloatDictionary latestTargetVelocities;
97 StringFloatDictionary currentPose;
98 double currentCanVal;
99 double mpcFactor;
100 double error;
101 double phaseStop;
102 double posError;
103 double oriError;
104 double deltaT;
105 };
106
107 TripleBuffer<DebugBufferData> debugOutputData;
108
109 struct RTToControllerData
110 {
111 double currentTime;
112 double deltaT;
113 Eigen::Matrix4f currentPose;
114 Eigen::VectorXf currentTwist;
115 };
116
118
119 struct RTToUserData
120 {
121 Eigen::Matrix4f currentTcpPose;
122 float waitTimeForCalibration;
123 };
124
125 TripleBuffer<RTToUserData> rt2UserData;
126
127
129
130 std::vector<const SensorValue1DoFActuatorVelocity*> velocitySensors;
131 std::vector<const SensorValue1DoFActuatorPosition*> positionSensors;
132 std::vector<ControlTarget1DoFActuatorVelocity*> targets;
133
134 // velocity ik controller parameters
135 CartesianVelocityControllerPtr tcpController;
136 std::string nodeSetName;
137
138 // dmp parameters
139 bool finished;
140 bool started;
141 bool dmpRunning;
142 bool firstRun;
143
144 VirtualRobot::DifferentialIKPtr ik;
145 VirtualRobot::RobotNodePtr tcp;
146
147 NJointPeriodicTSDMPControllerConfigPtr cfg;
148 mutable MutexType controllerMutex;
150
151 Eigen::Matrix4f targetPose;
152
153
154 const SensorValueForceTorque* forceSensor;
155 Eigen::Vector3f filteredForce;
156 Eigen::Vector3f forceOffset;
157 Eigen::Matrix3f toolTransform;
158 Eigen::Vector3f oriToolDir;
159
160 struct UserToRTData
161 {
162 float targetForce;
163 };
164
165 TripleBuffer<UserToRTData> user2rtData;
166 float kpf;
167
168 // NJointPeriodicTSDMPControllerInterface interface
169 };
170
171} // namespace armarx::control::deprecated_njoint_mp_controller::task_space
#define TYPEDEF_PTRS_HANDLE(T)
NJointControllerWithTripleBuffer(const NJointPeriodicTSDMPForwardVelControllerControlData &initialCommands=NJointPeriodicTSDMPForwardVelControllerControlData())
IceUtil::Handle< PeriodicTask< T > > pointer_type
Shared pointer type for convenience.
A simple triple buffer for lockfree comunication between a single writer and a single reader.
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration)
TODO make protected and use attorneys.
NJointPeriodicTSDMPForwardVelController(const RobotUnitPtr &, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
virtual void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &)
Brief description of class targets.
Definition targets.h:39
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
std::shared_ptr< CartesianVelocityController > CartesianVelocityControllerPtr
IceUtil::Handle< class RobotUnit > RobotUnitPtr
Definition FTSensor.h:34
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface > DebugDrawerInterfacePrx
detail::ControlThreadOutputBufferEntry SensorAndControl