5 #include <VirtualRobot/Robot.h>
6 #include <VirtualRobot/IK/DifferentialIK.h>
9 #include <dmp/general/simoxhelpers.h>
10 #include <dmp/representation/dmp/umitsmp.h>
11 #include <dmp/representation/dmp/umidmp.h>
24 #include <armarx/control/deprecated_njoint_mp_controller/bimanual/ControllerInterface.h>
35 using ViaPoint = std::pair<double, DMP::DVec >;
61 using ConfigPtrT = NJointBimanualCCDMPVelocityControllerConfigPtr;
65 std::string
getClassName(
const Ice::Current&)
const override;
72 void learnDMPFromFiles(
const std::string&,
const Ice::StringSeq&,
const Ice::Current&)
override;
73 void learnDMPFromBothFiles(
const Ice::StringSeq&,
const Ice::StringSeq&,
const Ice::Current&)
override;
80 void setRatios(
const Ice::DoubleSeq& ratios,
const Ice::Current&)
override;
82 void runDMP(
const Ice::DoubleSeq& leftGoals,
const Ice::DoubleSeq& rightGoals,
const Ice::Current&)
override;
84 void setGoals(
const Ice::DoubleSeq& goals,
const Ice::Current&)
override;
110 Eigen::Matrix4f getLocalPose(
const std::vector<double>& newCoordinateVec,
const std::vector<double>& globalTargetPoseVec)
112 Eigen::Matrix4f newCoordinate = VirtualRobot::MathTools::quat2eigen4f(newCoordinateVec.at(4), newCoordinateVec.at(5), newCoordinateVec.at(6), newCoordinateVec.at(3));
113 newCoordinate(0, 3) = newCoordinateVec.at(0);
114 newCoordinate(1, 3) = newCoordinateVec.at(1);
115 newCoordinate(2, 3) = newCoordinateVec.at(2);
117 Eigen::Matrix4f globalTargetPose = VirtualRobot::MathTools::quat2eigen4f(globalTargetPoseVec.at(4), globalTargetPoseVec.at(5), globalTargetPoseVec.at(6), globalTargetPoseVec.at(3));
118 globalTargetPose(0, 3) = globalTargetPoseVec.at(0);
119 globalTargetPose(1, 3) = globalTargetPoseVec.at(1);
120 globalTargetPose(2, 3) = globalTargetPoseVec.at(2);
122 return getLocalPose(newCoordinate, globalTargetPose);
126 struct DebugBufferData
128 StringFloatDictionary desired_velocities;
129 StringFloatDictionary constrained_force;
130 float leftTargetPose_x;
131 float leftTargetPose_y;
132 float leftTargetPose_z;
133 float rightTargetPose_x;
134 float rightTargetPose_y;
135 float rightTargetPose_z;
137 float leftCurrentPose_x;
138 float leftCurrentPose_y;
139 float leftCurrentPose_z;
140 float rightCurrentPose_x;
141 float rightCurrentPose_y;
142 float rightCurrentPose_z;
144 float leftControlSignal_x;
145 float leftControlSignal_y;
146 float leftControlSignal_z;
147 float leftControlSignal_ro;
148 float leftControlSignal_pi;
149 float leftControlSignal_ya;
151 float rightControlSignal_x;
152 float rightControlSignal_y;
153 float rightControlSignal_z;
154 float rightControlSignal_ro;
155 float rightControlSignal_pi;
156 float rightControlSignal_ya;
165 struct NJointBimanualCCDMPVelocityControllerSensorData
171 Eigen::VectorXf currentLeftTwist;
172 Eigen::VectorXf currentRightTwist;
177 struct NJointBimanualCCDMPVelocityControllerInterfaceData
182 Eigen::VectorXf currentLeftJointVals;
183 Eigen::VectorXf currentRightJointVals;
186 TripleBuffer<NJointBimanualCCDMPVelocityControllerInterfaceData> interfaceData;
189 std::vector<ControlTarget1DoFActuatorVelocity*> leftTargets;
190 std::vector<const SensorValue1DoFActuatorAcceleration*> leftAccelerationSensors;
191 std::vector<const SensorValue1DoFActuatorVelocity*> leftVelocitySensors;
192 std::vector<const SensorValue1DoFActuatorPosition*> leftPositionSensors;
194 std::vector<ControlTarget1DoFActuatorVelocity*> rightTargets;
195 std::vector<const SensorValue1DoFActuatorAcceleration*> rightAccelerationSensors;
196 std::vector<const SensorValue1DoFActuatorVelocity*> rightVelocitySensors;
197 std::vector<const SensorValue1DoFActuatorPosition*> rightPositionSensors;
199 const SensorValueForceTorque* rightForceTorque;
200 const SensorValueForceTorque* leftForceTorque;
202 NJointBimanualCCDMPVelocityControllerConfigPtr cfg;
203 VirtualRobot::DifferentialIKPtr leftIK;
204 VirtualRobot::DifferentialIKPtr rightIK;
206 std::vector<tsvmp::TaskSpaceDMPControllerPtr > leftGroup;
207 std::vector<tsvmp::TaskSpaceDMPControllerPtr > rightGroup;
208 std::vector<tsvmp::TaskSpaceDMPControllerPtr > bothLeaderGroup;
209 DMP::UMIDMPPtr leftJointDMP;
210 DMP::UMIDMPPtr rightJointDMP;
211 bool isLeftJointLearned;
212 bool isRightJointLearned;
215 std::string leaderName;
217 VirtualRobot::RobotNodePtr tcpLeft;
218 VirtualRobot::RobotNodePtr tcpRight;
225 Eigen::VectorXf leftDesiredJointValues;
226 Eigen::VectorXf rightDesiredJointValues;
228 Eigen::Vector3f leftKpos;
229 Eigen::Vector3f leftKori;
230 Eigen::Vector3f leftDpos;
231 Eigen::Vector3f leftDori;
233 Eigen::Vector3f rightKpos;
234 Eigen::Vector3f rightKori;
235 Eigen::Vector3f rightDpos;
236 Eigen::Vector3f rightDori;
242 std::vector<std::string> leftJointNames;
243 std::vector<std::string> rightJointNames;
246 VirtualRobot::RobotNodeSetPtr leftRNS;
247 VirtualRobot::RobotNodeSetPtr rightRNS;
249 Eigen::VectorXf leftNullSpaceCoefs;
250 Eigen::VectorXf rightNullSpaceCoefs;
262 DMP::Vec<DMP::DMPState> currentLeftJointState;
263 DMP::Vec<DMP::DMPState> currentRightJointState;