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 
18 namespace armarx
19 {
20  class SensorValue1DoFActuatorTorque;
21  class SensorValue1DoFActuatorVelocity;
22  class SensorValue1DoFActuatorPosition;
23  class ControlTarget1DoFActuatorTorque;
24  class ControlTarget1DoFActuatorVelocity;
25  class SensorValueForceTorque;
26 } // namespace armarx
27 
29 {
31 
32  TYPEDEF_PTRS_HANDLE(NJointPeriodicTSDMPForwardVelController);
33  TYPEDEF_PTRS_HANDLE(NJointPeriodicTSDMPForwardVelControllerControlData);
34 
36  {
37  public:
38  Eigen::VectorXf targetTSVel;
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,
54  const VirtualRobot::RobotPtr&);
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
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelController::setSpeed
void setSpeed(Ice::Double times, const Ice::Current &)
Definition: NJointPeriodicTSDMPForwardVelController.cpp:349
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelController::getClassName
std::string getClassName(const Ice::Current &) const
Definition: NJointPeriodicTSDMPForwardVelController.cpp:109
NJointControllerWithTripleBuffer.h
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelController::runDMP
void runDMP(const Ice::DoubleSeq &goals, double tau, const Ice::Current &)
Definition: NJointPeriodicTSDMPForwardVelController.cpp:371
armarx::NJointControllerWithTripleBuffer
Definition: NJointControllerWithTripleBuffer.h:10
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelController::controllerRun
void controllerRun()
Definition: NJointPeriodicTSDMPForwardVelController.cpp:115
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:650
armarx::control::deprecated_njoint_mp_controller::task_space
Definition: DeprecatedNJointPeriodicTSDMPCompliantController.cpp:20
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelControllerControlData::targetPose
Eigen::Matrix4f targetPose
Definition: NJointPeriodicTSDMPForwardVelController.h:39
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelController::rtRun
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration)
TODO make protected and use attorneys.
Definition: NJointPeriodicTSDMPForwardVelController.cpp:168
PeriodicTask.h
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelController::setGoals
void setGoals(const Ice::DoubleSeq &goals, const Ice::Current &)
Definition: NJointPeriodicTSDMPForwardVelController.cpp:356
armarx::NJointControllerBase::ConfigPtrT
NJointControllerConfigPtr ConfigPtrT
Definition: NJointControllerBase.h:587
armarx::CartesianVelocityControllerPtr
std::shared_ptr< CartesianVelocityController > CartesianVelocityControllerPtr
Definition: CartesianVelocityController.h:34
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelController::onDisconnectNJointController
void onDisconnectNJointController()
Definition: NJointPeriodicTSDMPForwardVelController.cpp:468
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelController::isFinished
bool isFinished(const Ice::Current &)
Definition: NJointPeriodicTSDMPForwardVelController.h:68
armarx::detail::ControlThreadOutputBufferEntry
Definition: ControlThreadOutputBuffer.h:182
armarx::VariantType::Double
const VariantTypeId Double
Definition: Variant.h:920
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelController::NJointPeriodicTSDMPForwardVelController
NJointPeriodicTSDMPForwardVelController(const RobotUnitPtr &, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
Definition: NJointPeriodicTSDMPForwardVelController.cpp:24
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelController::onPublish
virtual void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &)
Definition: NJointPeriodicTSDMPForwardVelController.cpp:394
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelController::setAmplitude
void setAmplitude(Ice::Double amp, const Ice::Current &)
Definition: NJointPeriodicTSDMPForwardVelController.cpp:364
armarx::control::deprecated_njoint_mp_controller::tsvmp
Definition: NJointTaskSpaceImpedanceDMPController.h:27
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
TaskSpaceVMP.h
CartesianVelocityController.h
CycleUtil.h
armarx::control::deprecated_njoint_mp_controller::tsvmp::TaskSpaceDMPControllerPtr
std::shared_ptr< TaskSpaceDMPController > TaskSpaceDMPControllerPtr
Definition: NJointTaskSpaceImpedanceDMPController.h:31
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelController::learnDMPFromFiles
void learnDMPFromFiles(const Ice::StringSeq &fileNames, const Ice::Current &)
Definition: NJointPeriodicTSDMPForwardVelController.cpp:339
armarx::NJointPeriodicTSDMPControllerInterface
Definition: ControllerInterface.ice:204
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelControllerControlData::targetTSVel
Eigen::VectorXf targetTSVel
Definition: NJointPeriodicTSDMPForwardVelController.h:38
armarx::NJointControllerWithTripleBuffer< NJointPeriodicTSDMPForwardVelControllerControlData >::MutexType
std::recursive_mutex MutexType
Definition: NJointControllerWithTripleBuffer.h:13
IceUtil::Handle< class RobotUnit >
IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface >
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelController::onInitNJointController
void onInitNJointController()
Definition: NJointPeriodicTSDMPForwardVelController.cpp:434
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelControllerControlData
Definition: NJointPeriodicTSDMPForwardVelController.h:35
armarx::control::deprecated_njoint_mp_controller::task_space::TYPEDEF_PTRS_HANDLE
TYPEDEF_PTRS_HANDLE(DeprecatedNJointPeriodicTSDMPCompliantController)
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelController::getCanVal
double getCanVal(const Ice::Current &)
Definition: NJointPeriodicTSDMPForwardVelController.h:79
GfxTL::Matrix3f
MatrixXX< 3, 3, float > Matrix3f
Definition: MatrixXX.h:649
armarx::SensorValueForceTorque
Definition: SensorValueForceTorque.h:32
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelController
The NJointPeriodicTSDMPForwardVelController class.
Definition: NJointPeriodicTSDMPForwardVelController.h:46
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:19
armarx::TripleBuffer< DebugBufferData >