Example 4: The Robot Walker - ihmcrobotics/ihmc-open-robotics-software-tutorials GitHub Wiki

Introduction

In this final example we will be looking at a bipedal robot simulation as it moves through a quasi-static gait. Start the simulation by running the RobotWalkerFourSimulation as Java application.

walker

Understanding the Contents of the Project

Let's look at robot-walker-four project in the package explorer. The files included in this project should be as follows:

  1. M2RobotDefinition.java creates the physical model definition for the simulated robot.
  2. RobotWalkerFour.java creates an instance of the robot according to the M2RobotDefinition for the controller. This robot instance has to be an independent "twin" of the "simulated robot" (i.e., the instance of the robot created in the simulation). The class also offers a different set of features such as a method to update the inverse dynamics of the robot.
  3. RobotWalkerFourOptimizationSettings.java contains all of the relevant parameters for configuring the optimization solver.
  4. RobotWalkerFourSimulation.java as always, sets up and starts the simulation environment.
  5. RobotWalkerFourController.java implements a small controller that uses the IHMC WBCC to make the M2Robot achieve quasi-static walking. In this controller, we use an additional set of features with respect to the previous examples: PlaneContactStateCommand requests the controller core to use a rigid-body for supporting the body weight (controls which foot is going to support the robot weight at a given time), CenterOfMassFeedbackControlCommand controls the robot's center of mass position, SpatialAccelerationCommand directly controls the rigid-body acceleration, and StateMachine creates a state machine framework that manages the different possible states of the robot and sets transitions to go from one controller to another. In this example, there are 5 different states the robot could be in:
  • STANDING: double support phase (both legs are supporting the robot) that maintains the robot's standing position.
  • TRANSFER_TO_LEFT: double support phase that moves the center of mass from the right foot to the left foot.
  • TRANSFER_TO_RIGHT: double support phase that moves the center of mass from the left foot to the right foot.
  • LEFT_SUPPORT: single support phase (only the left leg is supporting the robot) where the center of mass stays still while the right leg is swung to the desired footstep location.
  • RIGHT_SUPPORT: single support phase (only the right leg is supporting the robot) where the center of mass stays still while the left leg is swung to the desired footstep location.

The transitions between states are displayed through the following diagram:

newStateMachine

Notice how the simulation starts in the STANDING state. As soon as the variable walk is set to true in the simulation GUI, the state machine will leave the STANDING state and transition into the TRANSFER_TO_LEFT state, causing the robot to start walking. The transitions from that point forward all happen "automatically" in the code once the needed changes in the state are completed. When the current state becomes RIGHT_SUPPORT, the machine transitions back to the TRANSFER_TO_LEFT state in order to create the continuous walking motion.

Now would be a good time to examine the code to fully understand how the the overall project is working.

Run the Simulation

Now let's run the RobotWalkerFourSimulation class to obtain the following simulation:

walker2

To make the robot to start walking, search for the variable walk and set it to true. To follow the robot as it moves out of frame, use the "A", "D", "W", and "S" keys to move the frame left, move the frame right, zoom in to the frame, and zoom out of the frame respectively. To see the state transitions, look up stateMachineCurrentState and drag it into a graph. In the bottom of the generated graph, you should see the current value of the variable, i.e., the state name. By monitoring the current state, you can see the transitions between states.

This walking controller is obviously far from being natural looking, dynamic, or robust, but its implementation is very simple and a great starting point for those interested in creating more complex controllers!