4 #include <VirtualRobot/IK/DifferentialIK.h>
5 #include <VirtualRobot/Robot.h>
12 #include <RobotAPI/interface/units/RobotUnit/NJointTaskSpaceDMPController.h>
13 #include <RobotAPI/libraries/DMPController/TaskSpaceDMPController.h>
17 #include <dmp/representation/dmp/umitsmp.h>
41 using ConfigPtrT = NJointBimanualCCDMPControllerConfigPtr;
43 const NJointControllerConfigPtr& config,
55 void learnDMPFromFiles(
const std::string&,
const Ice::StringSeq&,
const Ice::Current&);
62 void runDMP(
const Ice::DoubleSeq& leftGoals,
63 const Ice::DoubleSeq& rightGoals,
66 void setGoals(
const Ice::DoubleSeq& goals,
const Ice::Current&);
92 Eigen::VectorXf getControlWrench(
const Eigen::VectorXf& twist,
99 getLocalPose(
const std::vector<double>& newCoordinateVec,
100 const std::vector<double>& globalTargetPoseVec)
103 VirtualRobot::MathTools::quat2eigen4f(newCoordinateVec.at(4),
104 newCoordinateVec.at(5),
105 newCoordinateVec.at(6),
106 newCoordinateVec.at(3));
107 newCoordinate(0, 3) = newCoordinateVec.at(0);
108 newCoordinate(1, 3) = newCoordinateVec.at(1);
109 newCoordinate(2, 3) = newCoordinateVec.at(2);
112 VirtualRobot::MathTools::quat2eigen4f(globalTargetPoseVec.at(4),
113 globalTargetPoseVec.at(5),
114 globalTargetPoseVec.at(6),
115 globalTargetPoseVec.at(3));
116 globalTargetPose(0, 3) = globalTargetPoseVec.at(0);
117 globalTargetPose(1, 3) = globalTargetPoseVec.at(1);
118 globalTargetPose(2, 3) = globalTargetPoseVec.at(2);
120 return getLocalPose(newCoordinate, globalTargetPose);
123 struct DebugBufferData
125 StringFloatDictionary desired_torques;
126 StringFloatDictionary constrained_force;
127 float leftTargetPose_x;
128 float leftTargetPose_y;
129 float leftTargetPose_z;
130 float rightTargetPose_x;
131 float rightTargetPose_y;
132 float rightTargetPose_z;
134 float leftCurrentPose_x;
135 float leftCurrentPose_y;
136 float leftCurrentPose_z;
137 float rightCurrentPose_x;
138 float rightCurrentPose_y;
139 float rightCurrentPose_z;
158 TripleBuffer<DebugBufferData> debugDataInfo;
160 struct NJointBimanualCCDMPControllerSensorData
166 Eigen::VectorXf currentLeftTwist;
167 Eigen::VectorXf currentRightTwist;
169 TripleBuffer<NJointBimanualCCDMPControllerSensorData> controllerSensorData;
172 std::vector<ControlTarget1DoFActuatorTorque*> leftTargets;
173 std::vector<const SensorValue1DoFActuatorAcceleration*> leftAccelerationSensors;
174 std::vector<const SensorValue1DoFActuatorVelocity*> leftVelocitySensors;
175 std::vector<const SensorValue1DoFActuatorPosition*> leftPositionSensors;
177 std::vector<ControlTarget1DoFActuatorTorque*> rightTargets;
178 std::vector<const SensorValue1DoFActuatorAcceleration*> rightAccelerationSensors;
179 std::vector<const SensorValue1DoFActuatorVelocity*> rightVelocitySensors;
180 std::vector<const SensorValue1DoFActuatorPosition*> rightPositionSensors;
182 const SensorValueForceTorque* rightForceTorque;
183 const SensorValueForceTorque* leftForceTorque;
185 NJointBimanualCCDMPControllerConfigPtr cfg;
186 VirtualRobot::DifferentialIKPtr leftIK;
187 VirtualRobot::DifferentialIKPtr rightIK;
189 std::vector<TaskSpaceDMPControllerPtr> leftGroup;
190 std::vector<TaskSpaceDMPControllerPtr> rightGroup;
191 std::vector<TaskSpaceDMPControllerPtr> bothLeaderGroup;
194 std::string leaderName;
196 VirtualRobot::RobotNodePtr tcpLeft;
197 VirtualRobot::RobotNodePtr tcpRight;
204 Eigen::VectorXf leftDesiredJointValues;
205 Eigen::VectorXf rightDesiredJointValues;
212 Eigen::VectorXf forceC_des;
215 Eigen::Vector3f kpos;
216 Eigen::Vector3f kori;
217 Eigen::Vector3f dpos;
218 Eigen::Vector3f dori;
225 std::vector<std::string> leftJointNames;
226 std::vector<std::string> rightJointNames;
229 VirtualRobot::RobotNodeSetPtr leftRNS;
230 VirtualRobot::RobotNodeSetPtr rightRNS;
231 VirtualRobot::RobotNodeSetPtr rnsLeftBody;
232 VirtualRobot::RobotNodeSetPtr rnsRightBody;
234 Eigen::Vector3f filtered_leftForce;
235 Eigen::Vector3f filtered_leftTorque;
236 Eigen::Vector3f filtered_rightForce;
237 Eigen::Vector3f filtered_rightTorque;
238 float filterTimeConstant;
240 std::vector<PIDControllerPtr> ftPIDController;
242 Eigen::Vector3f offset_leftForce;
243 Eigen::Vector3f offset_leftTorque;
244 Eigen::Vector3f offset_rightForce;
245 Eigen::Vector3f offset_rightTorque;
247 bool isForceCompensateDone;