NJointBimanualCartesianAdmittanceController.h
Go to the documentation of this file.
1 #pragma once
2 
3 
4 #include <VirtualRobot/VirtualRobot.h>
5 
8 
11 
13 #include <armarx/control/deprecated_njoint_mp_controller/adaptive/ControllerInterface.h>
14 #include <armarx/control/deprecated_njoint_mp_controller/bimanual/CartesianAdmittanceControllerInterface.h>
15 
16 namespace armarx
17 {
18  class SensorValue1DoFActuatorTorque;
19  class SensorValue1DoFActuatorVelocity;
20  class SensorValue1DoFActuatorPosition;
21  class ControlTarget1DoFActuatorTorque;
22  class SensorValueForceTorque;
23 } // namespace armarx
24 
25 namespace DMP
26 {
28 }
29 
31 {
33 
34  TYPEDEF_PTRS_HANDLE(NJointBimanualCartesianAdmittanceController);
35  TYPEDEF_PTRS_HANDLE(NJointBimanualObjLevelControlData);
36 
38  public NJointController,
40  {
41  public:
43  const NJointControllerConfigPtr& config,
44  const VirtualRobot::RobotPtr&);
45 
46  // NJointController interface
47  std::string getClassName(const Ice::Current&) const override;
48  void rtRun(const IceUtil::Time& sensorValuesTimestamp,
49  const IceUtil::Time& timeSinceLastIteration) override;
50 
51  //set config
52  void setConfig(const NJointBimanualCartesianAdmittanceControllerConfigPtr& ptr,
53  const Ice::Current& = Ice::emptyCurrent) override;
54  void setDesiredJointValuesLeft(const Ice::FloatSeq& vals,
55  const Ice::Current& = Ice::emptyCurrent) override;
56  void setDesiredJointValuesRight(const Ice::FloatSeq& vals,
57  const Ice::Current& = Ice::emptyCurrent) override;
59  const Ice::Current& = Ice::emptyCurrent) override;
61  const Ice::Current& = Ice::emptyCurrent) override;
64  const Ice::Current& = Ice::emptyCurrent) override;
67  const Ice::Current& = Ice::emptyCurrent) override;
68  //control
69  Eigen::Matrix4f getBoxPose(const Ice::Current& = Ice::emptyCurrent) const override;
70  void setBoxPose(const Eigen::Matrix4f& pose,
71  const Ice::Current& = Ice::emptyCurrent) override;
72  void setBoxWidth(float w, const Ice::Current& = Ice::emptyCurrent) override;
73  void setBoxVelocity(const Eigen::Vector3f& velXYZ,
74  const Eigen::Vector3f& velRPY,
75  const Ice::Current& = Ice::emptyCurrent) override;
76  void setBoxPoseAndVelocity(const Eigen::Matrix4f& pose,
77  const Eigen::Vector3f& velXYZ,
78  const Eigen::Vector3f& velRPY,
79  const Ice::Current& = Ice::emptyCurrent) override;
80  void moveBoxPose(const Eigen::Matrix4f& pose,
81  const Ice::Current& = Ice::emptyCurrent) override;
82  void moveBoxPosition(const Eigen::Vector3f& pos,
83  const Ice::Current& = Ice::emptyCurrent) override;
84 
85  protected:
87  void updateDesiredJointValuesLeft(const Ice::FloatSeq& cfg);
88  void updateDesiredJointValuesRight(const Ice::FloatSeq& cfg);
95 
96  protected:
97  virtual void onPublish(const SensorAndControl&,
100 
101  // void onInitNJointController();
102  // void onDisconnectNJointController();
103  // void controllerRun(); //runs dmp controller
104 
105  private:
106  struct Target
107  {
108  Eigen::Matrix4f pose;
109  Eigen::Vector6f vel;
110  };
111 
112  mutable std::recursive_mutex targBufWriteMutex;
114 
115  struct PreprocessedCfg
116  {
117  float boxWidth;
118 
119  Eigen::Vector6f KmAdmittance;
120  Eigen::Vector6f KpAdmittance;
121  Eigen::Vector6f KdAdmittance;
122 
123  float ftCalibrationTime;
124 
125  Eigen::Vector12f KpImpedance;
126  Eigen::Vector12f KdImpedance;
127 
128  float massLeft;
129  Eigen::Vector3f CoMVecLeft;
130  Eigen::Vector3f forceOffsetLeft;
131  Eigen::Vector3f torqueOffsetLeft;
132 
133  float massRight;
134  Eigen::Vector3f CoMVecRight;
135  Eigen::Vector3f forceOffsetRight;
136  Eigen::Vector3f torqueOffsetRight;
137 
138  Eigen::VectorXf desiredJointValuesLeft;
139  Eigen::VectorXf desiredJointValuesRight;
140 
141  float knull;
142  float dnull;
143 
144  float torqueLimit;
145 
146  Eigen::Vector12f targetWrench;
147 
148  float filterCoeff;
149 
150  Eigen::Vector6f forceThreshold;
151  };
152 
153  mutable std::recursive_mutex cfgBufWriteMutex;
155 
156  struct RTData
157  {
158  struct Arm
159  {
160  std::vector<ControlTarget1DoFActuatorTorque*> targets;
161  std::vector<const SensorValue1DoFActuatorVelocity*> velocitySensors;
162  std::vector<const SensorValue1DoFActuatorPosition*> positionSensors;
164  VirtualRobot::DifferentialIKPtr IK;
165 
166  std::vector<std::string> jointNames;
167  VirtualRobot::RobotNodeSetPtr rns;
168  VirtualRobot::RobotNodePtr tcp;
169  VirtualRobot::RobotNodePtr frameFTSensor;
170 
172  };
173 
174  Arm left;
175  Arm right;
176 
177  double ftcalibrationTimer = 0;
178  // Eigen::Vector12f ftOffset = Eigen::Vector12f::Zero();
179  bool firstLoop = true;
180 
181  Eigen::Vector6f virtualAcc = Eigen::Vector6f::Zero();
182  Eigen::Vector6f virtualVel = Eigen::Vector6f::Zero();
184 
185  Eigen::Vector12f filteredOldValue = Eigen::Vector12f::Zero();
186  };
187 
188  RTData rt;
189 
190  struct DebugBufferData
191  {
192  Eigen::Matrix4f currentBoxPose;
193 
194  StringFloatDictionary desired_torques;
195 
196  float virtualPose_x;
197  float virtualPose_y;
198  float virtualPose_z;
199 
200  float objPose_x;
201  float objPose_y;
202  float objPose_z;
203 
204  float objForce_x;
205  float objForce_y;
206  float objForce_z;
207  float objTorque_x;
208  float objTorque_y;
209  float objTorque_z;
210 
211  float deltaPose_x;
212  float deltaPose_y;
213  float deltaPose_z;
214  float deltaPose_rx;
215  float deltaPose_ry;
216  float deltaPose_rz;
217 
218  float objVel_x;
219  float objVel_y;
220  float objVel_z;
221  float objVel_rx;
222  float objVel_ry;
223  float objVel_rz;
224 
225  float modifiedPoseRight_x;
226  float modifiedPoseRight_y;
227  float modifiedPoseRight_z;
228  float currentPoseLeft_x;
229  float currentPoseLeft_y;
230  float currentPoseLeft_z;
231 
232  float modifiedPoseLeft_x;
233  float modifiedPoseLeft_y;
234  float modifiedPoseLeft_z;
235  float currentPoseRight_x;
236  float currentPoseRight_y;
237  float currentPoseRight_z;
238 
239  float dmpBoxPose_x;
240  float dmpBoxPose_y;
241  float dmpBoxPose_z;
242 
243  float dmpTwist_x;
244  float dmpTwist_y;
245  float dmpTwist_z;
246 
247  float modifiedTwist_lx;
248  float modifiedTwist_ly;
249  float modifiedTwist_lz;
250  float modifiedTwist_rx;
251  float modifiedTwist_ry;
252  float modifiedTwist_rz;
253 
254  float rx;
255  float ry;
256  float rz;
257 
258  // Eigen::VectorXf wrenchDMP;
259  // Eigen::VectorXf computedBoxWrench;
260 
261  Eigen::VectorXf forceImpedance;
262  Eigen::VectorXf forcePID;
263  Eigen::VectorXf forcePIDControlValue;
264  Eigen::VectorXf poseError;
265  Eigen::VectorXf wrenchesConstrained;
266  Eigen::VectorXf wrenchesMeasuredInRoot;
267  };
268 
269  mutable std::recursive_mutex debugOutputDataReadMutex;
270  TripleBuffer<DebugBufferData> debugOutputData;
271 
272  // struct rt2ControlData
273  // {
274  // double currentTime;
275  // double deltaT;
276  // Eigen::Matrix4f currentPose;
277  // Eigen::VectorXf currentTwist;
278  // };
279  // TripleBuffer<rt2ControlData> rt2ControlBuffer;
280 
281  // struct ControlInterfaceData
282  // {
283  // Eigen::Matrix4f currentLeftPose;
284  // Eigen::Matrix4f currentRightPose;
285  // };
286 
287  // TripleBuffer<ControlInterfaceData> controlInterfaceBuffer;
288 
289  // float torqueLimit;
290 
291 
292  // TaskSpaceDMPControllerPtr objectDMP;
293 
294 
295  // Eigen::Matrix4f leftInitialPose;
296  // Eigen::Matrix4f rightInitialPose;
297  // Eigen::Matrix4f boxInitialPose;
298 
299 
300  // std::vector<PIDControllerPtr> forcePIDControllers;
301 
302  // filter parameters
303  // bool finished;
304  // bool dmpStarted;
305  protected:
307  };
308 
309 } // namespace armarx::control::deprecated_njoint_mp_controller::bimanual
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::RTData::Arm::positionSensors
std::vector< const SensorValue1DoFActuatorPosition * > positionSensors
Definition: NJointBimanualCartesianAdmittanceController.h:162
armarx::navigation::platform_controller::platform_global_trajectory::Target
Twist2D Target
Definition: PlatformGlobalTrajectoryController.h:82
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::getClassName
std::string getClassName(const Ice::Current &) const override
Definition: NJointBimanualCartesianAdmittanceController.cpp:210
armarx::detail::NJBmanCartAdmCtrl::Nullspace
Definition: CartesianAdmittanceControllerInterface.ice:44
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::rtPreActivateController
void rtPreActivateController()
This function is called before the controller is activated.
Definition: NJointBimanualCartesianAdmittanceController.cpp:170
armarx::detail::NJBmanCartAdmCtrl::Admittance
Definition: CartesianAdmittanceControllerInterface.ice:60
NJointControllerWithTripleBuffer.h
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::setImpedanceConfig
void setImpedanceConfig(const detail::NJBmanCartAdmCtrl::Impedance &left, const detail::NJBmanCartAdmCtrl::Impedance &right, const Ice::Current &=Ice::emptyCurrent) override
Definition: NJointBimanualCartesianAdmittanceController.cpp:916
boost::shared_ptr< class UMIDMP >
armarx::NJointBimanualCartesianAdmittanceControllerConfig
Definition: CartesianAdmittanceControllerInterface.ice:86
DMP
Definition: NJointTaskSpaceAdaptiveDMPController.h:24
armarx::SynchronousNJointController
Definition: NJointControllerBase.h:1146
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::RTData::Arm::rns
VirtualRobot::RobotNodeSetPtr rns
Definition: NJointBimanualCartesianAdmittanceController.h:167
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:650
armarx::NJointBimanualCartesianAdmittanceControllerInterface
Definition: CartesianAdmittanceControllerInterface.ice:108
armarx::NJointBimanualCartesianAdmittanceControllerInterface::getBoxPose
Eigen::Matrix4f getBoxPose()
PeriodicTask.h
DMP::UMIDMPPtr
boost::shared_ptr< class UMIDMP > UMIDMPPtr
Definition: NJointTaskSpaceAdaptiveDMPController.h:27
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::updateDesiredJointValuesLeft
void updateDesiredJointValuesLeft(const Ice::FloatSeq &cfg)
Definition: NJointBimanualCartesianAdmittanceController.cpp:943
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::updateConfig
void updateConfig(const NJointBimanualCartesianAdmittanceControllerConfig &cfg)
Definition: NJointBimanualCartesianAdmittanceController.cpp:927
armarx::detail::NJBmanCartAdmCtrl::Force
Definition: CartesianAdmittanceControllerInterface.ice:70
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::setBoxPose
void setBoxPose(const Eigen::Matrix4f &pose, const Ice::Current &=Ice::emptyCurrent) override
Definition: NJointBimanualCartesianAdmittanceController.cpp:782
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::moveBoxPose
void moveBoxPose(const Eigen::Matrix4f &pose, const Ice::Current &=Ice::emptyCurrent) override
Definition: NJointBimanualCartesianAdmittanceController.cpp:831
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::setDesiredJointValuesRight
void setDesiredJointValuesRight(const Ice::FloatSeq &vals, const Ice::Current &=Ice::emptyCurrent) override
Definition: NJointBimanualCartesianAdmittanceController.cpp:875
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::setForceConfig
void setForceConfig(const detail::NJBmanCartAdmCtrl::Force &left, const detail::NJBmanCartAdmCtrl::Force &right, const Ice::Current &=Ice::emptyCurrent) override
Definition: NJointBimanualCartesianAdmittanceController.cpp:905
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::RTData::Arm::sensorFrame2TcpFrame
Eigen::Matrix4f sensorFrame2TcpFrame
Definition: NJointBimanualCartesianAdmittanceController.h:171
armarx::detail::ControlThreadOutputBufferEntry
Definition: ControlThreadOutputBuffer.h:182
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::RTData::Arm::frameFTSensor
VirtualRobot::RobotNodePtr frameFTSensor
Definition: NJointBimanualCartesianAdmittanceController.h:169
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:570
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::RTData::Arm::jointNames
std::vector< std::string > jointNames
Definition: NJointBimanualCartesianAdmittanceController.h:166
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::updateAdmittanceConfig
void updateAdmittanceConfig(const detail::NJBmanCartAdmCtrl::Admittance admittanceObject)
Definition: NJointBimanualCartesianAdmittanceController.cpp:975
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::setNullspaceConfig
void setNullspaceConfig(const detail::NJBmanCartAdmCtrl::Nullspace &nullspace, const Ice::Current &=Ice::emptyCurrent) override
Definition: NJointBimanualCartesianAdmittanceController.cpp:885
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::RTData::Arm
Definition: NJointBimanualCartesianAdmittanceController.h:158
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::updateForceConfig
void updateForceConfig(const detail::NJBmanCartAdmCtrl::Force &left, const detail::NJBmanCartAdmCtrl::Force &right)
Definition: NJointBimanualCartesianAdmittanceController.cpp:991
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::NJointBimanualCartesianAdmittanceController
NJointBimanualCartesianAdmittanceController(const RobotUnitPtr &, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
Definition: NJointBimanualCartesianAdmittanceController.cpp:36
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::rtRun
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration) override
TODO make protected and use attorneys.
Definition: NJointBimanualCartesianAdmittanceController.cpp:243
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::moveBoxPosition
void moveBoxPosition(const Eigen::Vector3f &pos, const Ice::Current &=Ice::emptyCurrent) override
Definition: NJointBimanualCartesianAdmittanceController.cpp:842
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::updateImpedanceConfig
void updateImpedanceConfig(const detail::NJBmanCartAdmCtrl::Impedance &left, const detail::NJBmanCartAdmCtrl::Impedance &right)
Definition: NJointBimanualCartesianAdmittanceController.cpp:1016
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::setBoxWidth
void setBoxWidth(float w, const Ice::Current &=Ice::emptyCurrent) override
Definition: NJointBimanualCartesianAdmittanceController.cpp:792
armarx::control::deprecated_njoint_mp_controller::tsvmp
Definition: NJointTaskSpaceImpedanceDMPController.h:27
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::onPublish
virtual void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &)
Definition: NJointBimanualCartesianAdmittanceController.cpp:679
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::RTData::Arm::tcp
VirtualRobot::RobotNodePtr tcp
Definition: NJointBimanualCartesianAdmittanceController.h:168
armarx::detail::NJBmanCartAdmCtrl::Impedance
Definition: CartesianAdmittanceControllerInterface.ice:52
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
TaskSpaceVMP.h
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::updateDesiredJointValuesRight
void updateDesiredJointValuesRight(const Ice::FloatSeq &cfg)
Definition: NJointBimanualCartesianAdmittanceController.cpp:953
CycleUtil.h
PIDController.h
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController
Definition: NJointBimanualCartesianAdmittanceController.h:37
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::setConfig
void setConfig(const NJointBimanualCartesianAdmittanceControllerConfigPtr &ptr, const Ice::Current &=Ice::emptyCurrent) override
Definition: NJointBimanualCartesianAdmittanceController.cpp:852
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::RTData::Arm::forceTorque
const SensorValueForceTorque * forceTorque
Definition: NJointBimanualCartesianAdmittanceController.h:163
IceUtil::Handle< class RobotUnit >
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::setBoxVelocity
void setBoxVelocity(const Eigen::Vector3f &velXYZ, const Eigen::Vector3f &velRPY, const Ice::Current &=Ice::emptyCurrent) override
Definition: NJointBimanualCartesianAdmittanceController.cpp:801
IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface >
armarx::Arm
Definition: RobotNameHelper.h:39
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::setBoxPoseAndVelocity
void setBoxPoseAndVelocity(const Eigen::Matrix4f &pose, const Eigen::Vector3f &velXYZ, const Eigen::Vector3f &velRPY, const Ice::Current &=Ice::emptyCurrent) override
Definition: NJointBimanualCartesianAdmittanceController.cpp:814
armarx::WriteBufferedTripleBuffer< Target >
Eigen::Matrix< float, 6, 1 >
armarx::SensorValueForceTorque
Definition: SensorValueForceTorque.h:32
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::setDesiredJointValuesLeft
void setDesiredJointValuesLeft(const Ice::FloatSeq &vals, const Ice::Current &=Ice::emptyCurrent) override
Definition: NJointBimanualCartesianAdmittanceController.cpp:865
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::RTData::Arm::IK
VirtualRobot::DifferentialIKPtr IK
Definition: NJointBimanualCartesianAdmittanceController.h:164
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::updateNullspaceConfig
void updateNullspaceConfig(const detail::NJBmanCartAdmCtrl::Nullspace &nullspace)
Definition: NJointBimanualCartesianAdmittanceController.cpp:963
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::setAdmittanceConfig
void setAdmittanceConfig(const detail::NJBmanCartAdmCtrl::Admittance &admittanceObject, const Ice::Current &=Ice::emptyCurrent) override
Definition: NJointBimanualCartesianAdmittanceController.cpp:895
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:19
armarx::control::deprecated_njoint_mp_controller::bimanual
Definition: NJointBimanualCartesianAdmittanceController.cpp:30
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::RTData::Arm::targets
std::vector< ControlTarget1DoFActuatorTorque * > targets
Definition: NJointBimanualCartesianAdmittanceController.h:160
armarx::TripleBuffer< DebugBufferData >
armarx::control::deprecated_njoint_mp_controller::bimanual::NJointBimanualCartesianAdmittanceController::RTData::Arm::velocitySensors
std::vector< const SensorValue1DoFActuatorVelocity * > velocitySensors
Definition: NJointBimanualCartesianAdmittanceController.h:161
armarx::control::deprecated_njoint_mp_controller::bimanual::TYPEDEF_PTRS_HANDLE
TYPEDEF_PTRS_HANDLE(NJointBimanualCartesianAdmittanceController)