NJointPeriodicTSDMPForwardVelController.h
Go to the documentation of this file.
1 #pragma once
2 
3 
4 // Simox
5 #include <VirtualRobot/Robot.h>
6 #include <VirtualRobot/IK/DifferentialIK.h>
7 
8 // armarx
16 
17 // control
18 #include <armarx/control/deprecated_njoint_mp_controller/task_space/ControllerInterface.h>
20 
21 
23 {
25 
26  TYPEDEF_PTRS_HANDLE(NJointPeriodicTSDMPForwardVelController);
27  TYPEDEF_PTRS_HANDLE(NJointPeriodicTSDMPForwardVelControllerControlData);
28 
30  {
31  public:
32  Eigen::VectorXf targetTSVel;
34  };
35 
36  /**
37  * @brief The NJointPeriodicTSDMPForwardVelController class
38  * @ingroup Library-RobotUnit-NJointControllers
39  */
41  public NJointControllerWithTripleBuffer<NJointPeriodicTSDMPForwardVelControllerControlData>,
43  {
44  public:
45  using ConfigPtrT = NJointPeriodicTSDMPControllerConfigPtr;
46  NJointPeriodicTSDMPForwardVelController(const RobotUnitPtr&, const NJointControllerConfigPtr& config, const VirtualRobot::RobotPtr&);
47 
48  // NJointControllerInterface interface
49  std::string getClassName(const Ice::Current&) const;
50 
51  // NJointController interface
52 
53  void rtRun(const IceUtil::Time& sensorValuesTimestamp, const IceUtil::Time& timeSinceLastIteration);
54 
55  // NJointPeriodicTSDMPForwardVelControllerInterface interface
56  void learnDMPFromFiles(const Ice::StringSeq& fileNames, const Ice::Current&);
57  bool isFinished(const Ice::Current&)
58  {
59  return finished;
60  }
61 
62  void runDMP(const Ice::DoubleSeq& goals, double tau, const Ice::Current&);
63  void setSpeed(Ice::Double times, const Ice::Current&);
64  void setGoals(const Ice::DoubleSeq& goals, const Ice::Current&);
65  void setAmplitude(Ice::Double amp, const Ice::Current&);
66 
67 
68  double getCanVal(const Ice::Current&)
69  {
70  return dmpCtrl->canVal;
71  }
72 
73  protected:
75 
78  void controllerRun();
79 
80  private:
81  struct DebugBufferData
82  {
83  StringFloatDictionary latestTargetVelocities;
84  StringFloatDictionary currentPose;
85  double currentCanVal;
86  double mpcFactor;
87  double error;
88  double phaseStop;
89  double posError;
90  double oriError;
91  double deltaT;
92  };
93 
94  TripleBuffer<DebugBufferData> debugOutputData;
95 
96  struct RTToControllerData
97  {
98  double currentTime;
99  double deltaT;
100  Eigen::Matrix4f currentPose;
101  Eigen::VectorXf currentTwist;
102  };
104 
105  struct RTToUserData
106  {
107  Eigen::Matrix4f currentTcpPose;
108  float waitTimeForCalibration;
109  };
110  TripleBuffer<RTToUserData> rt2UserData;
111 
112 
114 
115  std::vector<const SensorValue1DoFActuatorVelocity*> velocitySensors;
116  std::vector<const SensorValue1DoFActuatorPosition*> positionSensors;
117  std::vector<ControlTarget1DoFActuatorVelocity*> targets;
118 
119  // velocity ik controller parameters
120  CartesianVelocityControllerPtr tcpController;
121  std::string nodeSetName;
122 
123  // dmp parameters
124  bool finished;
125  bool started;
126  bool dmpRunning;
127  bool firstRun;
128 
129  VirtualRobot::DifferentialIKPtr ik;
130  VirtualRobot::RobotNodePtr tcp;
131 
132  NJointPeriodicTSDMPControllerConfigPtr cfg;
133  mutable MutexType controllerMutex;
135 
136  Eigen::Matrix4f targetPose;
137 
138 
139  const SensorValueForceTorque* forceSensor;
140  Eigen::Vector3f filteredForce;
141  Eigen::Vector3f forceOffset;
142  Eigen::Matrix3f toolTransform;
143  Eigen::Vector3f oriToolDir;
144  struct UserToRTData
145  {
146  float targetForce;
147  };
148  TripleBuffer<UserToRTData> user2rtData;
149  float kpf;
150 
151  // NJointPeriodicTSDMPControllerInterface interface
152 
153  };
154 
155 } // namespace armarx
156 
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelController::setSpeed
void setSpeed(Ice::Double times, const Ice::Current &)
Definition: NJointPeriodicTSDMPForwardVelController.cpp:338
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelController::getClassName
std::string getClassName(const Ice::Current &) const
Definition: NJointPeriodicTSDMPForwardVelController.cpp:96
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelController::runDMP
void runDMP(const Ice::DoubleSeq &goals, double tau, const Ice::Current &)
Definition: NJointPeriodicTSDMPForwardVelController.cpp:361
armarx::NJointControllerWithTripleBuffer
Definition: NJointControllerWithTripleBuffer.h:10
RobotUnit.h
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelController::controllerRun
void controllerRun()
Definition: NJointPeriodicTSDMPForwardVelController.cpp:102
armarx::control::deprecated_njoint_mp_controller::task_space
Definition: DeprecatedNJointPeriodicTSDMPCompliantController.cpp:6
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelControllerControlData::targetPose
Eigen::Matrix4f targetPose
Definition: NJointPeriodicTSDMPForwardVelController.h:33
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:156
SensorValueForceTorque.h
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelController::setGoals
void setGoals(const Ice::DoubleSeq &goals, const Ice::Current &)
Definition: NJointPeriodicTSDMPForwardVelController.cpp:346
armarx::NJointControllerBase::ConfigPtrT
NJointControllerConfigPtr ConfigPtrT
Definition: NJointControllerBase.h:586
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:459
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelController::isFinished
bool isFinished(const Ice::Current &)
Definition: NJointPeriodicTSDMPForwardVelController.h:57
armarx::detail::ControlThreadOutputBufferEntry
Definition: ControlThreadOutputBuffer.h:177
armarx::VariantType::Double
const VariantTypeId Double
Definition: Variant.h:919
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelController::NJointPeriodicTSDMPForwardVelController
NJointPeriodicTSDMPForwardVelController(const RobotUnitPtr &, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
Definition: NJointPeriodicTSDMPForwardVelController.cpp:11
ControlTarget1DoFActuator.h
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelController::onPublish
virtual void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &)
Definition: NJointPeriodicTSDMPForwardVelController.cpp:385
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelController::setAmplitude
void setAmplitude(Ice::Double amp, const Ice::Current &)
Definition: NJointPeriodicTSDMPForwardVelController.cpp:354
armarx::control::deprecated_njoint_mp_controller::tsvmp
Definition: NJointTaskSpaceImpedanceDMPController.h:20
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
TaskSpaceVMP.h
CartesianVelocityController.h
CycleUtil.h
NJointController.h
armarx::control::deprecated_njoint_mp_controller::tsvmp::TaskSpaceDMPControllerPtr
std::shared_ptr< TaskSpaceDMPController > TaskSpaceDMPControllerPtr
Definition: NJointTaskSpaceImpedanceDMPController.h:24
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelController::learnDMPFromFiles
void learnDMPFromFiles(const Ice::StringSeq &fileNames, const Ice::Current &)
Definition: NJointPeriodicTSDMPForwardVelController.cpp:328
armarx::NJointPeriodicTSDMPControllerInterface
Definition: ControllerInterface.ice:206
GfxTL::Matrix3f
MatrixXX< 3, 3, float > Matrix3f
Definition: MatrixXX.h:600
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelControllerControlData::targetTSVel
Eigen::VectorXf targetTSVel
Definition: NJointPeriodicTSDMPForwardVelController.h:32
armarx::NJointControllerWithTripleBuffer< NJointPeriodicTSDMPForwardVelControllerControlData >::MutexType
std::recursive_mutex MutexType
Definition: NJointControllerWithTripleBuffer.h:13
IceUtil::Handle
Definition: forward_declarations.h:29
IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface >
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelController::onInitNJointController
void onInitNJointController()
Definition: NJointPeriodicTSDMPForwardVelController.cpp:425
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelControllerControlData
Definition: NJointPeriodicTSDMPForwardVelController.h:29
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:68
armarx::SensorValueForceTorque
Definition: SensorValueForceTorque.h:31
armarx::control::deprecated_njoint_mp_controller::task_space::NJointPeriodicTSDMPForwardVelController
The NJointPeriodicTSDMPForwardVelController class.
Definition: NJointPeriodicTSDMPForwardVelController.h:40
SensorValue1DoFActuator.h
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
armarx::TripleBuffer< DebugBufferData >