Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/quickster footstep provider #527

Open
wants to merge 32 commits into
base: develop
Choose a base branch
from

Conversation

stefanfasano
Copy link
Contributor

@stefanfasano stefanfasano commented Dec 10, 2024

This is the initial groundwork for the implementation of Quickster's footstep calculator into the regular walking controller via the CSG (in step generator thread).

Tests included in this PR:

  • QFPTest; this tests switching between CSG modes while walking in place and standing in place

The next steps include:

  • New message type to ensure things on the controller side know which CSG mode is in use
  • Implementation into whole body MPC scheme
  • Hardware testing on robot
  • Max speed limits along with max acceleration per step

@stefanfasano stefanfasano marked this pull request as ready for review December 13, 2024 17:08
balanceManager.computeICPPlan();
}

private boolean haveWeEntered = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am confused by this boolean. Isn't whether or not you are executing the method inside onEntry() enough information to set firstTick in the method? Why are haveWeEntered and firstTick both in handleNewFootstep()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's probably a better way to do this whole thing. They don't exactly convey the same information, since first tick could be false if it is the second+ tick or if it has not entered the state yet, and that distinction is important. It is possible for the method that relies on this boolean (handleNewFootstep()) to be called without entering the state (WalkingSingleSupportState) because I have this method tied to a listener in another class (WalkingMessageHandler), and the class that this method belongs to is instantiated twice, once for each leg. So it is possible for this to be called by the listener even if the class (and therefore single support of the proper leg) has not been called.

The thing is, this is probably redundant because I later ended up adding a check to make sure that we only proceed with the handleNewFootstep() method if we are on the proper side of the robot. So I can probably delete the logic that relies on haveWeEntered

if (feetManager.adjustHeightIfNeeded(nextFootstep))
{
walkingMessageHandler.updateVisualizationAfterFootstepAdjustement(nextFootstep);
feetManager.adjustSwingTrajectory(swingSide, nextFootstep, swingTime);
}

//
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why all the // in this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah some are so I can more easily identify where I made changes, and some are for comments that I meant to write but never did. I'll fix both of those

@@ -132,13 +136,15 @@ public class ICPController implements ICPControllerInterface
private final ICPControllerHelper helper = new ICPControllerHelper();

public ICPController(WalkingControllerParameters walkingControllerParameters,
WalkingMessageHandler walkingMessageHandler,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a fan of this change. The walking message handler is meant to be a high level thing, and the ICPController is a low level thing. I would much rather add a method to the ICPController that allows you to "override" the useCoPFeedback boolean, which is what you're doing, then have that set by a listener that you add, so that this is occuring at a high level, rather than embedded into the ICP Controller. It's a little more convoluted to write, but much more obvious than this object-oriented approach when it comes to tracing what's going on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

/**
* Enabling this boolean allows feedback control of CoP (feedback alpha < 1).
*/
public boolean useCoPFeedback()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so if this is false, but useCMPFeedback is true, it will still move the base of the pendulum around, but will do so by moving the CMP. Is that intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, should I be turning that false as well?

@@ -171,7 +171,7 @@ public LinearMomentumRateControlModule(HighLevelHumanoidControllerToolbox contro
controllerToolbox.getYoGraphicsListRegistry());
}

public LinearMomentumRateControlModule(CenterOfMassStateProvider centerOfMassStateProvider,
public LinearMomentumRateControlModule(HighLevelHumanoidControllerToolbox controllerToolbox,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The LinearMomentumRateControlModule was written in such a way that it could be removed from the control thread. By adding the controller toolbox here, that gets messed up. I think the right thing to do would be to add the method to ICPController, like I said, then add that override cop feedback command as a field to the momentum rate input, such that the field is getting set in the motion control stuff based on some listener that's attached to the walking message handler, and then sent to this control module and used. Then you don't have to add the control toolbox or walking message handler to this class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, will do

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

maxICPErrorBeforeSingleSupportX += 0.3;
maxICPErrorBeforeSingleSupportY += 0.3;
}

normalizedICPError.set(MathTools.square(icpError2d.getX() / maxICPErrorBeforeSingleSupportX)
+ MathTools.square(icpError2d.getY() / maxICPErrorBeforeSingleSupportY));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would likely be cleaner to instead just set the normalizedICPError to zero in that if statement.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -460,7 +460,7 @@ private void setupStepGeneratorThread()
else
{
JoystickBasedSteppingPluginFactory joystickPluginFactory = new JoystickBasedSteppingPluginFactory();
if (heightMapForFootstepZ.hasValue())
if (heightMapForFootstepZ.hasValue() && heightMapForFootstepZ.get() != null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this captures how the height map will work on hardware. THe height map should be continuously streamed to the robot. Right now, the step generator will only take a single instance of the height map at construction. This is out of scope of this PR, but I'm pointing out that this won't work as intended on the robot.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good, I'm guessing this isn't specific to the change I made, but an existing issue with this particular implementation right?

private final FramePoint3D vertexInWorld = new FramePoint3D();
private final FrameConvexPolygon2D allowableAreaForCoPInFoot = new FrameConvexPolygon2D();

public ErrorBasedStepAdjustmentController(WalkingControllerParameters walkingControllerParameters,
WalkingMessageHandler walkingMessageHandler,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also be passed in functionally, and not done through the walking message handler. In reality, in the state where you're calling the step adjustment, you should just be able to write an if block there, rather than turning it off inside the step adjustment controller.

Also I don't believe this class is actually used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, so to clarify, basically do what you suggested for ICPController right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


if (swingSide == RobotSide.LEFT)
if (currentCSGMode.getEnumValue() == ContinuousStepGeneratorMode.QFP && quicksterFootstepProvider.hasValue())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a FIXME note to delete this once you've done the rollout stuff inside the QFP?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -9,6 +9,9 @@ byte TRAJECTORY_TYPE_OBSTACLE_CLEARANCE = 1
byte TRAJECTORY_TYPE_CUSTOM = 2
byte TRAJECTORY_TYPE_WAYPOINTS = 3

byte CSG_MODE_STANDARD = 0
byte CSG_MODE_QFP = 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make more sense for all this stuff to go into the data list message, rather than the message of each individual footstep? It seems like this is either true for the entire list of steps, or its true for none of them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the current implementation, the FootstepDataList is a mix of QFP and standard (first one QFP, the rest are standard). I know we want to make the change such that multiple/all steps in the plan are computed with QFP, but I still think there could be instances perhaps when we switch between the two footstep providers, where the list will become mixed again. I'd rather leave this here because I feel it provides a more granular level of control over the timing of the parameter adjustments

bool should_check_for_reachability false

# If the desired footstep is for walking in place with zero forward or lateral velocity
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to make a note that this is only used if the csg_mode is QFP

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

trackingStiffness = new DoubleParameter(namePrefix + "TrackingStiffness", registry, 200.0);
trackingZeta = new DoubleParameter(namePrefix + "TrackingZeta", registry, 0.8);
trackingStiffness = new YoDouble(namePrefix + "TrackingStiffness", registry);
trackingStiffness.set(defaultTrackingStiffness);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would assume the answer is yes, but I want to make sure that you checked all the parameter files to make sure this didn't change anything?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call, are you referring to the xml param files? Which one(s) do you reckon these parameters would live in?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


private final MatrixExponentialCalculator matrixExponentialCalculator = new MatrixExponentialCalculator(2);
private final DMatrixRMaj closedLoopStateMatrix = new DMatrixRMaj(2, 2);
private final DMatrixRMaj scaledClosedLoopStateMatrix = new DMatrixRMaj(2, 2);
private final DMatrixRMaj stateTransitionMatrix = new DMatrixRMaj(2, 2);

private final double defaultTrackingStiffness = 200.0;
private final double defaultTrackingZeta = 0.8;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can these be static?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -28,6 +29,7 @@ public class FootstepDataCommand implements Command<FootstepDataCommand, Footste
private long sequenceId;
private RobotSide robotSide;
private TrajectoryType trajectoryType = TrajectoryType.DEFAULT;
private ContinuousStepGeneratorMode csgMode = ContinuousStepGeneratorMode.STANDARD;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if they get moved in the message, they should be moved here, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants