Skip to content

Commit 880dde5

Browse files
author
gwiedebach
committed
Removed argument from method getDefaultControlModeForRigidBody in the WalkingControllerParameters.
1 parent 64459cd commit 880dde5

File tree

6 files changed

+67
-55
lines changed

6 files changed

+67
-55
lines changed

Atlas/src/us/ihmc/atlas/parameters/AtlasWalkingControllerParameters.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -488,16 +488,11 @@ private PID3DGains createHandPositionControlGains()
488488

489489
/** {@inheritDoc} */
490490
@Override
491-
public RigidBodyControlMode getDefaultControlModeForRigidBody(String bodyName)
491+
public Map<String, RigidBodyControlMode> getDefaultControlModesForRigidBodies()
492492
{
493-
if (bodyName.equals(jointMap.getChestName()))
494-
{
495-
return RigidBodyControlMode.TASKSPACE;
496-
}
497-
else
498-
{
499-
return RigidBodyControlMode.JOINTSPACE;
500-
}
493+
Map<String, RigidBodyControlMode> defaultControlModes = new HashMap<>();
494+
defaultControlModes.put(jointMap.getChestName(), RigidBodyControlMode.TASKSPACE);
495+
return defaultControlModes;
501496
}
502497

503498
/** {@inheritDoc} */

CommonWalkingControlModules/src/us/ihmc/commonWalkingControlModules/configurations/WalkingControllerParameters.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,16 +237,20 @@ public List<ImmutableTriple<String, PID3DGains, List<String>>> getTaskspacePosit
237237
}
238238

239239
/**
240-
* Returns the default control mode for a rigid body. The modes are defined in {@link RigidBodyControlMode}
241-
* and by default the mode should be {@link RigidBodyControlMode#JOINTSPACE}. In some cases (e.g. the chest)
242-
* it makes more sense to use the default mode {@link RigidBodyControlMode#TASKSPACE}.
240+
* Returns a map with default control modes for each rigid body.
241+
* <p>
242+
* The key of the map is the rigid body name as defined in the joint map. Possible
243+
* control modes are defined in {@link RigidBodyControlMode}. By default (if a body
244+
* is not contained in the map) {@link RigidBodyControlMode#JOINTSPACE} will be used
245+
* for the body. In some cases (e.g. the chest) it makes more sense to use the default
246+
* mode {@link RigidBodyControlMode#TASKSPACE}.
247+
* </p>
243248
*
244-
* @param bodyName is the name of the {@link RigidBody}
245249
* @return the default control mode of the body
246250
*/
247-
public RigidBodyControlMode getDefaultControlModeForRigidBody(String bodyName)
251+
public Map<String, RigidBodyControlMode> getDefaultControlModesForRigidBodies()
248252
{
249-
return RigidBodyControlMode.JOINTSPACE;
253+
return new HashMap<>();
250254
}
251255

252256
/**

CommonWalkingControlModules/src/us/ihmc/commonWalkingControlModules/controlModules/rigidBody/RigidBodyControlManager.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ public void setGains(Map<String, YoPIDGains> jointspaceGains, YoPID3DGains tasks
153153

154154
public void setDefaultControlMode(RigidBodyControlMode defaultControlMode)
155155
{
156+
if (defaultControlMode == null)
157+
{
158+
this.defaultControlMode.set(RigidBodyControlMode.JOINTSPACE);
159+
return;
160+
}
161+
156162
if (defaultControlMode == RigidBodyControlMode.TASKSPACE && homePose == null)
157163
{
158164
throw new RuntimeException("Need to define home pose if default control mode for body " + bodyName + " is set to TASKSPACE.");

CommonWalkingControlModules/src/us/ihmc/commonWalkingControlModules/highLevelHumanoidControl/factories/HighLevelControlManagerFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public RigidBodyControlManager getOrCreateRigidBodyManager(RigidBody bodyToContr
164164

165165
ContactablePlaneBody contactableBody = controllerToolbox.getContactableBody(bodyToControl);
166166
YoGraphicsListRegistry graphicsListRegistry = controllerToolbox.getYoGraphicsListRegistry();
167-
RigidBodyControlMode defaultControlModeForRigidBody = walkingControllerParameters.getDefaultControlModeForRigidBody(bodyName);
167+
RigidBodyControlMode defaultControlModeForRigidBody = walkingControllerParameters.getDefaultControlModesForRigidBodies().get(bodyName);
168168

169169
RigidBodyControlManager manager = new RigidBodyControlManager(bodyToControl, baseBody, elevator, homeConfiguration, homePose, positionControlledJoints,
170170
integrationSettings, trajectoryFrames, controlFrame, baseFrame, contactableBody, yoTime, graphicsListRegistry, registry);

IHMCAvatarInterfaces/test/us/ihmc/avatar/controllerAPI/EndToEndChestTrajectoryMessageTest.java

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
import us.ihmc.humanoidRobotics.communication.packets.walking.ChestTrajectoryMessage;
3535
import us.ihmc.humanoidRobotics.frames.HumanoidReferenceFrames;
3636
import us.ihmc.robotModels.FullHumanoidRobotModel;
37-
import us.ihmc.yoVariables.variable.YoDouble;
38-
import us.ihmc.yoVariables.variable.YoInteger;
3937
import us.ihmc.robotics.geometry.FrameOrientation;
4038
import us.ihmc.robotics.math.trajectories.waypoints.MultipleWaypointsOrientationTrajectoryGenerator;
4139
import us.ihmc.robotics.math.trajectories.waypoints.SimpleSO3TrajectoryPoint;
@@ -50,6 +48,8 @@
5048
import us.ihmc.simulationconstructionset.util.simulationTesting.SimulationTestingParameters;
5149
import us.ihmc.tools.MemoryTools;
5250
import us.ihmc.tools.thread.ThreadTools;
51+
import us.ihmc.yoVariables.variable.YoDouble;
52+
import us.ihmc.yoVariables.variable.YoInteger;
5353

5454
public 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

Valkyrie/src/us/ihmc/valkyrie/parameters/ValkyrieWalkingControllerParameters.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -431,16 +431,11 @@ private PID3DGains createHandPositionControlGains()
431431

432432
/** {@inheritDoc} */
433433
@Override
434-
public RigidBodyControlMode getDefaultControlModeForRigidBody(String bodyName)
434+
public Map<String, RigidBodyControlMode> getDefaultControlModesForRigidBodies()
435435
{
436-
if (bodyName.equals(jointMap.getChestName()))
437-
{
438-
return RigidBodyControlMode.TASKSPACE;
439-
}
440-
else
441-
{
442-
return RigidBodyControlMode.JOINTSPACE;
443-
}
436+
Map<String, RigidBodyControlMode> defaultControlModes = new HashMap<>();
437+
defaultControlModes.put(jointMap.getChestName(), RigidBodyControlMode.TASKSPACE);
438+
return defaultControlModes;
444439
}
445440

446441
/** {@inheritDoc} */

0 commit comments

Comments
 (0)