Skip to content

Commit e667743

Browse files
authored
Bugfix/fix pelvis rotation on delays (#1106)
* started working on a fix for pelvis rotationd elays * rolled back on how the time in the phase is found, and started adding a decay factor so the feedforward values dont go to the moon * fixed a bound inclusiveness problem
1 parent 36e9422 commit e667743

File tree

6 files changed

+38
-12
lines changed

6 files changed

+38
-12
lines changed

ihmc-common-walking-control-modules/src/main/java/us/ihmc/commonWalkingControlModules/capturePoint/ContactStateManager.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ public void initialize()
114114

115115
public void initializeForStanding()
116116
{
117-
118117
inSingleSupport.set(false);
119118
inStanding.set(true);
120119

@@ -136,6 +135,7 @@ public void initializeForStanding()
136135
public void initializeForTransfer(double transferDuration, double swingDuration)
137136
{
138137
timeAtStartOfSupportSequence.set(time.getValue());
138+
139139
timeInSupportSequence.set(0.0);
140140
currentStateDuration.set(transferDuration);
141141
totalStateDuration.set(transferDuration + swingDuration);
@@ -159,14 +159,14 @@ public void initializeForSingleSupport(double transferDuration, double swingDura
159159

160160
double stepDuration = transferDuration + swingDuration;
161161
timeAtStartOfSupportSequence.set(time.getValue() - transferDuration);
162+
162163
timeInSupportSequence.set(transferDuration);
163164
currentStateDuration.set(stepDuration);
164165
totalStateDuration.set(stepDuration);
165166
remainingTimeInContactSequence.set(swingDuration);
166167
adjustedRemainingTimeUnderDisturbance.set(swingDuration);
167168
offsetTimeInState.set(transferDuration);
168169

169-
170170
adjustedTimeInSupportSequence.set(transferDuration);
171171
totalTimeAdjustment.set(0.0);
172172

@@ -176,6 +176,7 @@ public void initializeForSingleSupport(double transferDuration, double swingDura
176176
public void initializeForTransferToStanding(double finalTransferDuration )
177177
{
178178
timeAtStartOfSupportSequence.set(time.getValue());
179+
179180
timeInSupportSequence.set(0.0);
180181
currentStateDuration.set(finalTransferDuration);
181182
totalStateDuration.set(finalTransferDuration);

ihmc-common-walking-control-modules/src/main/java/us/ihmc/commonWalkingControlModules/highLevelHumanoidControl/highLevelStates/WalkingHighLevelHumanoidController.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import us.ihmc.commonWalkingControlModules.momentumBasedController.optimization.ControllerCoreOptimizationSettings;
4747
import us.ihmc.commonWalkingControlModules.momentumBasedController.optimization.JointLimitEnforcement;
4848
import us.ihmc.commonWalkingControlModules.momentumBasedController.optimization.JointLimitParameters;
49+
import us.ihmc.commonWalkingControlModules.referenceFrames.WalkingTrajectoryPath;
4950
import us.ihmc.commonWalkingControlModules.staticEquilibrium.StabilityMarginRegionCalculator;
5051
import us.ihmc.commonWalkingControlModules.staticEquilibrium.WholeBodyContactState;
5152
import us.ihmc.commons.lists.RecyclingArrayList;
@@ -589,10 +590,12 @@ public void initialize()
589590

590591
private void initializeWalkingTrajectoryPath()
591592
{
592-
controllerToolbox.getWalkingTrajectoryPath().clearFootsteps();
593-
controllerToolbox.getWalkingTrajectoryPath().reset();
594-
controllerToolbox.getWalkingTrajectoryPath().initializeDoubleSupport();
595-
controllerToolbox.getWalkingTrajectoryPath().updateTrajectory(FootControlModule.ConstraintType.FULL, FootControlModule.ConstraintType.FULL);
593+
WalkingTrajectoryPath walkingTrajectoryPath = controllerToolbox.getWalkingTrajectoryPath();
594+
walkingTrajectoryPath.clearFootsteps();
595+
walkingTrajectoryPath.reset();
596+
walkingTrajectoryPath.initializeDoubleSupport();
597+
walkingTrajectoryPath.updateTrajectory(FootControlModule.ConstraintType.FULL,
598+
FootControlModule.ConstraintType.FULL);
596599
}
597600

598601
private void initializeManagers()

ihmc-common-walking-control-modules/src/main/java/us/ihmc/commonWalkingControlModules/highLevelHumanoidControl/highLevelStates/walkingController/states/TransferToStandingState.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ public void doAction(double timeInState)
5959
{
6060
balanceManager.computeICPPlan();
6161
controllerToolbox.getWalkingTrajectoryPath()
62-
.updateTrajectory(feetManager.getCurrentConstraintType(RobotSide.LEFT), feetManager.getCurrentConstraintType(RobotSide.RIGHT));
62+
.updateTrajectory(feetManager.getCurrentConstraintType(RobotSide.LEFT),
63+
feetManager.getCurrentConstraintType(RobotSide.RIGHT));
6364

6465
switchToPointToeOffIfAlreadyInLine();
6566

ihmc-common-walking-control-modules/src/main/java/us/ihmc/commonWalkingControlModules/highLevelHumanoidControl/highLevelStates/walkingController/states/WalkingSingleSupportState.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ private void updateWalkingTrajectoryPath()
256256
walkingTrajectoryPath.clearFootsteps();
257257
walkingTrajectoryPath.addFootstep(nextFootstep, footstepTiming);
258258
walkingTrajectoryPath.addFootsteps(walkingMessageHandler);
259-
walkingTrajectoryPath.updateTrajectory(feetManager.getCurrentConstraintType(RobotSide.LEFT), feetManager.getCurrentConstraintType(RobotSide.RIGHT));
259+
walkingTrajectoryPath.updateTrajectory(feetManager.getCurrentConstraintType(RobotSide.LEFT),
260+
feetManager.getCurrentConstraintType(RobotSide.RIGHT));
260261
}
261262

262263
@Override

ihmc-common-walking-control-modules/src/main/java/us/ihmc/commonWalkingControlModules/referenceFrames/WalkingTrajectoryPath.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
import us.ihmc.yoVariables.euclid.referenceFrame.YoFramePoint3D;
4646
import us.ihmc.yoVariables.euclid.referenceFrame.YoFrameVector3D;
4747
import us.ihmc.yoVariables.filters.AlphaFilterTools;
48-
import us.ihmc.yoVariables.filters.AlphaFilteredYoVariable;
4948
import us.ihmc.yoVariables.math.YoMatrix;
5049
import us.ihmc.yoVariables.parameters.DoubleParameter;
5150
import us.ihmc.yoVariables.providers.DoubleProvider;
@@ -77,6 +76,7 @@ public class WalkingTrajectoryPath implements SCS2YoGraphicHolder
7776
private static final ReferenceFrame worldFrame = ReferenceFrame.getWorldFrame();
7877
private static final String WALKING_TRAJECTORY_PATH_FRAME_NAME = "walkingTrajectoryPathFrame";
7978
public static final int WALKING_TRAJECTORY_FRAME_ID = WALKING_TRAJECTORY_PATH_FRAME_NAME.hashCode();
79+
private static final double DECAY_RATE = 10.0;
8080

8181
private static final int MAX_NUMBER_OF_FOOTSTEPS = 2;
8282

@@ -105,6 +105,9 @@ public class WalkingTrajectoryPath implements SCS2YoGraphicHolder
105105
private final YoDouble currentYawAcceleration = new YoDouble(namePrefix + "CurrentYawAcceleration", registry);
106106
private final YoDouble finalTransferDuration = new YoDouble(namePrefix + "FinalTransferDuration", registry);
107107

108+
private final YoDouble decayRate = new YoDouble(namePrefix + "DecayRate", registry);
109+
private final YoDouble decayFactor = new YoDouble(namePrefix + "DecayFactor", registry);
110+
108111
private final YoFrameVector3D initialLinearVelocity = new YoFrameVector3D(namePrefix + "InitialLinearVelocity", worldFrame, registry);
109112
private final YoDouble initialYawRate = new YoDouble(namePrefix + "InitialYawRate", registry);
110113

@@ -154,6 +157,7 @@ public WalkingTrajectoryPath(DoubleProvider time,
154157
this.soleFrames = soleFrames;
155158

156159
trajectoryManager = new TrajectoryManager(registry);
160+
decayRate.set(DECAY_RATE);
157161
YoGraphicsList yoGraphicList;
158162

159163
if (yoGraphicsListRegistry != null)
@@ -349,7 +353,16 @@ public void updateTrajectory(ConstraintType leftFootConstraintType, ConstraintTy
349353
if (updateWaypoints)
350354
updateWaypoints();
351355

352-
double currentTime = MathTools.clamp(time.getValue() - startTime.getValue(), 0.0, totalDuration.getValue());
356+
double maxTime = totalDuration.getDoubleValue();
357+
if (!footsteps.isEmpty())
358+
{
359+
if (isInDoubleSupport.getBooleanValue())
360+
maxTime = Math.min(footstepTimings.getFirst().getTransferTime(), maxTime);
361+
else
362+
maxTime = Math.min(footstepTimings.getFirst().getSwingTime(), maxTime);
363+
}
364+
double timeInState = time.getValue() - startTime.getDoubleValue();
365+
double currentTime = MathTools.clamp(timeInState, 0.0, maxTime);
353366

354367
trajectoryManager.initialize(initialLinearVelocity, initialYawRate.getValue(), waypoints, isLastWaypointOpen.getValue());
355368
trajectoryManager.computePosition(currentTime, currentPosition);
@@ -359,6 +372,12 @@ public void updateTrajectory(ConstraintType leftFootConstraintType, ConstraintTy
359372
currentYawRate.set(trajectoryManager.computeYawRate(currentTime));
360373
currentYawAcceleration.set(trajectoryManager.computeYawAcceleration(currentTime));
361374

375+
// If we've overshot when this was supposed to end, decay the rate and acceleration
376+
double overageTime = timeInState - currentTime;
377+
decayFactor.set(Math.exp(-decayRate.getDoubleValue() * overageTime));
378+
currentYawRate.mul(decayFactor.getDoubleValue());
379+
currentYawAcceleration.mul(decayFactor.getDoubleValue() * decayFactor.getDoubleValue());
380+
362381
walkingTrajectoryPathFrame.update();
363382
walkingTrajectoryAcceleration.getLinearPart().setMatchingFrame(currentLinearAcceleration);
364383
walkingTrajectoryAcceleration.getAngularPart().set(0.0, 0.0, currentYawAcceleration.getValue());

ihmc-robotics-toolkit/src/main/java/us/ihmc/robotics/math/trajectories/generators/MultiCubicSpline1DSolver.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,9 +465,10 @@ public double computeVelocity(double time, DMatrixRMaj solution)
465465

466466
public double computeAcceleration(double time, DMatrixRMaj solution)
467467
{
468-
if (time <= 0.0)
468+
// We don't want these bounds to be inclusive. The position and velocity bounds are not inclusive, as they return this trajectory at those bounds.
469+
if (time < 0.0)
469470
return 0.0;
470-
if (time >= 1.0)
471+
if (time > 1.0)
471472
return 0.0;
472473

473474
int index = findSolutionOffsetIndex(time, solution);

0 commit comments

Comments
 (0)