3434import us .ihmc .humanoidRobotics .communication .packets .walking .ChestTrajectoryMessage ;
3535import us .ihmc .humanoidRobotics .frames .HumanoidReferenceFrames ;
3636import us .ihmc .robotModels .FullHumanoidRobotModel ;
37- import us .ihmc .yoVariables .variable .YoDouble ;
38- import us .ihmc .yoVariables .variable .YoInteger ;
3937import us .ihmc .robotics .geometry .FrameOrientation ;
4038import us .ihmc .robotics .math .trajectories .waypoints .MultipleWaypointsOrientationTrajectoryGenerator ;
4139import us .ihmc .robotics .math .trajectories .waypoints .SimpleSO3TrajectoryPoint ;
5048import us .ihmc .simulationconstructionset .util .simulationTesting .SimulationTestingParameters ;
5149import us .ihmc .tools .MemoryTools ;
5250import us .ihmc .tools .thread .ThreadTools ;
51+ import us .ihmc .yoVariables .variable .YoDouble ;
52+ import us .ihmc .yoVariables .variable .YoInteger ;
5353
5454public abstract class EndToEndChestTrajectoryMessageTest implements MultiRobotTestInterface
5555{
@@ -244,82 +244,82 @@ public void testSelectionMatrixWithAllAxisOffUsingSingleTrajectoryPoint() throws
244244 public void testSettingWeightMatrixUsingSingleTrajectoryPoint () throws Exception
245245 {
246246 BambooTools .reportTestStartedMessage (simulationTestingParameters .getShowWindows ());
247-
247+
248248 Random random = new Random (564574L );
249-
249+
250250 DRCObstacleCourseStartingLocation selectedLocation = DRCObstacleCourseStartingLocation .DEFAULT_BUT_ALMOST_PI ;
251-
251+
252252 drcSimulationTestHelper = new DRCSimulationTestHelper (getClass ().getSimpleName (), selectedLocation , simulationTestingParameters , getRobotModel ());
253253 SimulationConstructionSet scs = drcSimulationTestHelper .getSimulationConstructionSet ();
254-
254+
255255 ThreadTools .sleep (1000 );
256256 boolean success = drcSimulationTestHelper .simulateAndBlockAndCatchExceptions (0.5 );
257257 assertTrue (success );
258-
258+
259259 FullHumanoidRobotModel fullRobotModel = drcSimulationTestHelper .getControllerFullRobotModel ();
260260 HumanoidReferenceFrames humanoidReferenceFrames = new HumanoidReferenceFrames (fullRobotModel );
261261 ReferenceFrame pelvisZUpFrame = humanoidReferenceFrames .getPelvisZUpFrame ();
262262 humanoidReferenceFrames .updateFrames ();
263-
263+
264264 double trajectoryTime = 1.0 ;
265265 RigidBody pelvis = fullRobotModel .getPelvis ();
266266 RigidBody chest = fullRobotModel .getChest ();
267-
267+
268268 OneDoFJoint [] spineClone = ScrewTools .cloneOneDoFJointPath (pelvis , chest );
269-
269+
270270 for (int i = 0 ; i < 50 ; i ++)
271271 {
272272 ScrewTestTools .setRandomPositionsWithinJointLimits (spineClone , random );
273273 RigidBody chestClone = spineClone [spineClone .length - 1 ].getSuccessor ();
274274 FrameOrientation desiredRandomChestOrientation = new FrameOrientation (chestClone .getBodyFixedFrame ());
275275 desiredRandomChestOrientation .changeFrame (ReferenceFrame .getWorldFrame ());
276-
276+
277277 Quaternion desiredOrientation = new Quaternion ();
278278 desiredRandomChestOrientation .getQuaternion (desiredOrientation );
279-
279+
280280 ChestTrajectoryMessage chestTrajectoryMessage = new ChestTrajectoryMessage (trajectoryTime , desiredOrientation , pelvisZUpFrame , pelvisZUpFrame );
281281 chestTrajectoryMessage .setExecutionMode (ExecutionMode .OVERRIDE , -1 );
282-
282+
283283 WeightMatrix3D weightMatrix = new WeightMatrix3D ();
284-
284+
285285 double xWeight = random .nextDouble ();
286286 double yWeight = random .nextDouble ();
287287 double zWeight = random .nextDouble ();
288-
288+
289289 weightMatrix .setWeights (xWeight , yWeight , zWeight );
290290 chestTrajectoryMessage .setWeightMatrix (weightMatrix );
291291 drcSimulationTestHelper .send (chestTrajectoryMessage );
292-
292+
293293 assertTrue (drcSimulationTestHelper .simulateAndBlockAndCatchExceptions (getRobotModel ().getControllerDT () * 4.0 ));
294294 assertWeightsMatch (xWeight , yWeight , zWeight , chest , scs );
295295 }
296-
296+
297297 ScrewTestTools .setRandomPositionsWithinJointLimits (spineClone , random );
298298 RigidBody chestClone = spineClone [spineClone .length - 1 ].getSuccessor ();
299299 FrameOrientation desiredRandomChestOrientation = new FrameOrientation (chestClone .getBodyFixedFrame ());
300300 desiredRandomChestOrientation .changeFrame (ReferenceFrame .getWorldFrame ());
301-
301+
302302 Quaternion desiredOrientation = new Quaternion ();
303303 desiredRandomChestOrientation .getQuaternion (desiredOrientation );
304-
304+
305305 ChestTrajectoryMessage chestTrajectoryMessage = new ChestTrajectoryMessage (trajectoryTime , desiredOrientation , pelvisZUpFrame , pelvisZUpFrame );
306306 chestTrajectoryMessage .setExecutionMode (ExecutionMode .OVERRIDE , -1 );
307-
307+
308308 WeightMatrix3D weightMatrix = new WeightMatrix3D ();
309-
309+
310310 double xWeight = Double .NaN ;
311311 double yWeight = Double .NaN ;
312312 double zWeight = Double .NaN ;
313-
313+
314314 weightMatrix .setWeights (xWeight , yWeight , zWeight );
315315 chestTrajectoryMessage .setWeightMatrix (weightMatrix );
316316 drcSimulationTestHelper .send (chestTrajectoryMessage );
317-
317+
318318 assertTrue (drcSimulationTestHelper .simulateAndBlockAndCatchExceptions (getRobotModel ().getControllerDT () * 4.0 ));
319319 assertAngularWeightsMatchDefault (chest , scs );
320-
320+
321321 }
322-
322+
323323 private void assertAngularWeightsMatchDefault (RigidBody rigidBody , SimulationConstructionSet scs )
324324 {
325325 String prefix = rigidBody .getName () + "Taskspace" ;
@@ -332,7 +332,7 @@ private void assertAngularWeightsMatchDefault(RigidBody rigidBody, SimulationCon
332332 assertEquals (defaultAngularWeightX .getDoubleValue (), angularWeightX .getDoubleValue (), 1e-8 );
333333 assertEquals (defaultAngularWeightY .getDoubleValue (), angularWeightY .getDoubleValue (), 1e-8 );
334334 assertEquals (defaultAngularWeightZ .getDoubleValue (), angularWeightZ .getDoubleValue (), 1e-8 );
335-
335+
336336 }
337337
338338 private void assertWeightsMatch (double xWeight , double yWeight , double zWeight , RigidBody rigidBody , SimulationConstructionSet scs )
@@ -345,7 +345,7 @@ private void assertWeightsMatch(double xWeight, double yWeight, double zWeight,
345345// YoDouble linearWeightX = (YoDouble) scs.getVariable(prefix + "LinearWeightX_RO");
346346// YoDouble linearWeightY = (YoDouble) scs.getVariable(prefix + "LinearWeightY_RO");
347347// YoDouble linearWeightZ = (YoDouble) scs.getVariable(prefix + "LinearWeightZ_RO");
348-
348+
349349 assertEquals (xWeight , angularWeightX .getDoubleValue (), 1e-8 );
350350 assertEquals (yWeight , angularWeightY .getDoubleValue (), 1e-8 );
351351 assertEquals (zWeight , angularWeightZ .getDoubleValue (), 1e-8 );
@@ -968,7 +968,11 @@ public void testQueueWithWrongPreviousId() throws Exception
968968 success = drcSimulationTestHelper .simulateAndBlockAndCatchExceptions (0.05 + getRobotModel ().getControllerDT ());
969969 assertTrue (success );
970970
971- RigidBodyControlMode defaultControlMode = getRobotModel ().getWalkingControllerParameters ().getDefaultControlModeForRigidBody (chest .getName ());
971+ RigidBodyControlMode defaultControlMode = getRobotModel ().getWalkingControllerParameters ().getDefaultControlModesForRigidBodies ().get (chest .getName ());
972+ if (defaultControlMode == null )
973+ {
974+ defaultControlMode = RigidBodyControlMode .JOINTSPACE ;
975+ }
972976 assertEquals (defaultControlMode , EndToEndArmTrajectoryMessageTest .findControllerState (chest .getName (), scs ));
973977 assertNumberOfWaypoints (1 , scs , chest );
974978 }
@@ -1031,7 +1035,11 @@ public void testQueueWithUsingDifferentTrajectoryFrameWithoutOverride() throws E
10311035 LookLeftMessageWithChangeTrajFrame .setExecutionMode (ExecutionMode .QUEUE , -1 );
10321036 drcSimulationTestHelper .send (LookLeftMessageWithChangeTrajFrame );
10331037 assertTrue (drcSimulationTestHelper .simulateAndBlockAndCatchExceptions (getRobotModel ().getControllerDT () * 2.0 ));
1034- RigidBodyControlMode defaultControlMode = getRobotModel ().getWalkingControllerParameters ().getDefaultControlModeForRigidBody (chest .getName ());
1038+ RigidBodyControlMode defaultControlMode = getRobotModel ().getWalkingControllerParameters ().getDefaultControlModesForRigidBodies ().get (chest .getName ());
1039+ if (defaultControlMode == null )
1040+ {
1041+ defaultControlMode = RigidBodyControlMode .JOINTSPACE ;
1042+ }
10351043 assertEquals (defaultControlMode , EndToEndArmTrajectoryMessageTest .findControllerState (chest .getName (), scs ));
10361044 assertNumberOfWaypoints (1 , scs , chest );
10371045
@@ -1293,7 +1301,11 @@ public void testStopAllTrajectory() throws Exception
12931301
12941302 Quaternion desiredOrientationAfterStop = findControllerDesiredOrientation (scs , chest );
12951303
1296- RigidBodyControlMode defaultControlMode = getRobotModel ().getWalkingControllerParameters ().getDefaultControlModeForRigidBody (chest .getName ());
1304+ RigidBodyControlMode defaultControlMode = getRobotModel ().getWalkingControllerParameters ().getDefaultControlModesForRigidBodies ().get (chest .getName ());
1305+ if (defaultControlMode == null )
1306+ {
1307+ defaultControlMode = RigidBodyControlMode .JOINTSPACE ;
1308+ }
12971309 assertEquals (defaultControlMode , EndToEndArmTrajectoryMessageTest .findControllerState (chest .getName (), scs ));
12981310 assertNumberOfWaypoints (1 , scs , chest );
12991311
0 commit comments