5 #include <VirtualRobot/Robot.h>
6 #include <VirtualRobot/IK/DifferentialIK.h>
9 #include <dmp/representation/dmp/umitsmp.h>
22 #include <armarx/control/deprecated_njoint_mp_controller/bimanual/ControllerInterface.h>
33 using ViaPoint = std::pair<double, DMP::DVec >;
57 using ConfigPtrT = NJointBimanualCCDMPControllerConfigPtr;
61 std::string
getClassName(
const Ice::Current&)
const override;
68 void learnDMPFromFiles(
const std::string&,
const Ice::StringSeq&,
const Ice::Current&)
override;
74 void runDMP(
const Ice::DoubleSeq& leftGoals,
const Ice::DoubleSeq& rightGoals,
const Ice::Current&)
override;
76 void setGoals(
const Ice::DoubleSeq& goals,
const Ice::Current&)
override;
102 Eigen::Matrix4f getLocalPose(
const std::vector<double>& newCoordinateVec,
const std::vector<double>& globalTargetPoseVec)
104 Eigen::Matrix4f newCoordinate = VirtualRobot::MathTools::quat2eigen4f(newCoordinateVec.at(4), newCoordinateVec.at(5), newCoordinateVec.at(6), newCoordinateVec.at(3));
105 newCoordinate(0, 3) = newCoordinateVec.at(0);
106 newCoordinate(1, 3) = newCoordinateVec.at(1);
107 newCoordinate(2, 3) = newCoordinateVec.at(2);
109 Eigen::Matrix4f globalTargetPose = VirtualRobot::MathTools::quat2eigen4f(globalTargetPoseVec.at(4), globalTargetPoseVec.at(5), globalTargetPoseVec.at(6), globalTargetPoseVec.at(3));
110 globalTargetPose(0, 3) = globalTargetPoseVec.at(0);
111 globalTargetPose(1, 3) = globalTargetPoseVec.at(1);
112 globalTargetPose(2, 3) = globalTargetPoseVec.at(2);
114 return getLocalPose(newCoordinate, globalTargetPose);
118 struct DebugBufferData
120 StringFloatDictionary desired_torques;
121 StringFloatDictionary constrained_force;
122 float leftTargetPose_x;
123 float leftTargetPose_y;
124 float leftTargetPose_z;
125 float rightTargetPose_x;
126 float rightTargetPose_y;
127 float rightTargetPose_z;
129 float leftCurrentPose_x;
130 float leftCurrentPose_y;
131 float leftCurrentPose_z;
132 float rightCurrentPose_x;
133 float rightCurrentPose_y;
134 float rightCurrentPose_z;
136 float leftControlSignal_x;
137 float leftControlSignal_y;
138 float leftControlSignal_z;
139 float leftControlSignal_ro;
140 float leftControlSignal_pi;
141 float leftControlSignal_ya;
144 float rightControlSignal_x;
145 float rightControlSignal_y;
146 float rightControlSignal_z;
147 float rightControlSignal_ro;
148 float rightControlSignal_pi;
149 float rightControlSignal_ya;
174 struct NJointBimanualCCDMPControllerSensorData
180 Eigen::VectorXf currentLeftTwist;
181 Eigen::VectorXf currentRightTwist;
186 struct NJointBimanualCCDMPControllerInterfaceData
192 TripleBuffer<NJointBimanualCCDMPControllerInterfaceData> interfaceData;
195 std::vector<ControlTarget1DoFActuatorTorque*> leftTargets;
196 std::vector<const SensorValue1DoFActuatorAcceleration*> leftAccelerationSensors;
197 std::vector<const SensorValue1DoFActuatorVelocity*> leftVelocitySensors;
198 std::vector<const SensorValue1DoFActuatorPosition*> leftPositionSensors;
200 std::vector<ControlTarget1DoFActuatorTorque*> rightTargets;
201 std::vector<const SensorValue1DoFActuatorAcceleration*> rightAccelerationSensors;
202 std::vector<const SensorValue1DoFActuatorVelocity*> rightVelocitySensors;
203 std::vector<const SensorValue1DoFActuatorPosition*> rightPositionSensors;
205 const SensorValueForceTorque* rightForceTorque;
206 const SensorValueForceTorque* leftForceTorque;
208 NJointBimanualCCDMPControllerConfigPtr cfg;
209 VirtualRobot::DifferentialIKPtr leftIK;
210 VirtualRobot::DifferentialIKPtr rightIK;
212 std::vector<tsvmp::TaskSpaceDMPControllerPtr > leftGroup;
213 std::vector<tsvmp::TaskSpaceDMPControllerPtr > rightGroup;
214 std::vector<tsvmp::TaskSpaceDMPControllerPtr > bothLeaderGroup;
217 std::string leaderName;
219 VirtualRobot::RobotNodePtr tcpLeft;
220 VirtualRobot::RobotNodePtr tcpRight;
227 Eigen::VectorXf leftDesiredJointValues;
228 Eigen::VectorXf rightDesiredJointValues;
230 Eigen::Vector3f leftKpos;
231 Eigen::Vector3f leftKori;
232 Eigen::Vector3f leftDpos;
233 Eigen::Vector3f leftDori;
235 Eigen::Vector3f rightKpos;
236 Eigen::Vector3f rightKori;
237 Eigen::Vector3f rightDpos;
238 Eigen::Vector3f rightDori;
244 std::vector<std::string> leftJointNames;
245 std::vector<std::string> rightJointNames;
248 VirtualRobot::RobotNodeSetPtr leftRNS;
249 VirtualRobot::RobotNodeSetPtr rightRNS;
251 Eigen::VectorXf leftNullSpaceCoefs;
252 Eigen::VectorXf rightNullSpaceCoefs;
255 float startReduceTorque;