Skip to content

selim-cm/stable-humanoid

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stable Walking for humanoid robot

This project provides an implementation of an MPC for bipedal robot walking. The controller allows the robot to maintain its balance while walking at different speeds. The controller also features robustness against disturbances and the ability to react to changes in the environment. The key steps in the MPC approach are:

  1. Prediction: Based on the current state of the robot and the control inputs, the MPC predicts the future states of the robot using the system model.
  2. Optimization: The MPC formulates an optimization problem to minimize the difference between the predicted state and the desired state. The optimization problem includes minimization of the jerk, velocity and proximity to reference trajectories.
  3. Implementation: The MPC applies the optimal control actions to the robot.

After the MPC is used to generate the stable walking trajectory, we use inverse kinematics via the pink library to control the joints of the robot and simulate walking.

Requirements

  • Python 3.10
  • Additional dependencies are listed below

Dependencies

The following packages are required:

  • qpsolvers
  • loop_rate_limiters
  • pinocchio
  • pink
  • meshcat_shapes
  • matplotlib
  • h5py
  • robot_descriptions

To install these dependencies, you can run the following command:

pip install -r requirements.txt

How to Run the MPC and inverse Kinematics for humanoid robot

Arguments

  • trajectory_type (required): The type of trajectory for the humanoid robot. Must be one of forward, upwards, or upwards_turning.
  • --debug (optional): Include this flag to show intermediate plots during the simulation.
  • --store (optional): Include this flag to store the QP (Quadratic Programming) data generated during the simulation.
  • --filename (optional): Specify a filename (e.g., output.txt) to save the QP data. If not provided, the QP data will not be saved.

Usage

Navigate to the directory containing main.py and run the script with the following command:

./main.py trajectory_type [--debug] [--store] [--filename FILENAME]

Examples

  1. To simulate a forward walking trajectory without debugging plots:

./main.py forward

  1. To simulate an upwards walking trajectory and save the QP data with a specific filename:

./main.py upwards --store --filename UpwardsWalk

  1. To simulate an upwards turning trajectory with debugging plots:

./main.py upwards_turning --debug

N.B:

There is also a circle scenario which is not implemented yet with the inverse kinematics. To run it

./no-viz-circle.py

Results on existing scenarios

Moving Forward:

Moving Forward 1 Moving Forward 2
Moving Forward 3 Moving Forward 4

Moving Upwards:

Moving Forward 1 Moving Forward 2
Moving Forward 3 Moving Forward 4

Moving Upwards and Turning:

g
Moving Forward 1 Moving Forward 2
Moving Forward 3 Moving Forward 4

Circular Trajectory:

Moving Forward 1 Moving Forward 2
Moving Forward 3 Moving Forward 4

How to run the benchmark

Firstly if not done install qpsolvers_benchmark

You can install the benchmark and its dependencies in an isolated environment using conda:

conda create -f environment.yaml
conda activate qpsolvers_benchmark

Alternatively, you can install the benchmark on your system using pip:

pip install qpsolvers_benchmark

By default, the benchmark will run all supported solvers it finds.

Then run the benchmark with the following command:

qpsolvers_benchmark src/mpc_qp.py run

This will run the benchmark on the scenarios stored as hdf5 files in the data folder. The results will be stored in the results folder. For significant results change the error tolerances in mpc_qp.py based on the specific scenario.

Project Hierarchy

src/bezier_curve.py :

Generates the curve between two points using the Bezier curve algorithm, which is used for the path of the foot

src/com_task.py :

The pink task used to track the center of mass of the robot

src/controller.py:

The MPC controller that generates the optimal control actions for the robot

src/footstep_planner.py:

Offers different footstep planning algorithms for the robot, currently it offers : forward, upwards, upwards_turning, circle(Not stable for inverse kinematics), interactive(Not completely stable) Could be extended either by merging the existing scenarios or by adding new ones.

src/main.py:

Main script that runs the MPC and inverse kinematics for the robot

src/move_foot.py:

Applies inverse kinematics on foot to move it to the desired position

src/mpc.py:

Benchmarking script for the MPC

src/mpc_qp.py:

Benchmarking script for the MPC and inverse kinematics

src/no-viz.py:

Script that runs the MPC without inverse kinematics

src/no-viz-circle.py:

Script that runs the MPC without inverse kinematics for the circular trajectory

src/perturbation.py:

A class that allows adding perturbations to the robot during the simulation

src/qp.py:

Bechmarking script for the inverse kinematics

src/robot.py:

Class that represents a simplified version of the robot.

src/scenarios.py:

Holds different functions for generating usual COP reference trajectories

src/step.py:

Represent a step of the robot during a certain time

src/utils.py:

Contains different utility functions used for the MPC

src/visuals.py:

Contains multiple visualization functions

Notes on continuing the project

  • The adaptation of the footsteps is in the branch adapting-3, it is mostly implemented, but the solution is not stable yet. The reason is most likely because there should be an additional constraint on the Y of the robot so it doesn't choose the trivial solution of 0 as a solution.
  • The inverse kinematics of the circular trajectory is not stable. To solve the issue check the dimensions of the foot and the initial position of the com.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%