Implementation of a reactive walking controller for quadruped robots. Architecture mainly in Python with some parts in C++ with bindings to Python.
-
Install a Python 3 version (for instance Python 3.6)
-
For the following installations each time you see something like "py36", replace it by your Python version ("py35" for instance)
-
Install Pinocchio: https://stack-of-tasks.github.io/pinocchio/download.html
-
Install Gepetto Viewer:
sudo apt install robotpkg-py36-qt4-gepetto-viewer-corba
-
Install robot data:
sudo apt install robotpkg-example-robot-data
-
Install Scipy, Numpy, Matplotlib, IPython:
python3.6 -m pip install --user numpy scipy matplotlib ipython
-
Install PyBullet:
pip3 install --user pybullet
-
Install OSQP solver: [https://osqp.org/docs/get_started/sources.html#build-the-binaries]
- git clone --recursive https://github.com/oxfordcontrol/osqp
- cd osqp
- Edit CMakeLists.txt
- Add
set(PRINTING OFF)
just abovemessage(STATUS "Printing is ${PRINTING}")
- Add
set(PROFILING OFF)
just abovemessage(STATUS "Profiling is ${PROFILING}")
- Turn DLONG off
option (DLONG "Use long integers (64bit) for indexing" OFF)
- mkdir build
- cd build
- cmake .. -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=~/install -DPYTHON_EXECUTABLE=$(which python3.6) -DPYTHON_STANDARD_LAYOUT=ON (to install in ~/install folder)
- make install
-
Install YAML parser for C++: [https://github.com/jbeder/yaml-cpp]
-
Install package that handles the gamepad:
pip3 install --user inputs
-
Install eiquadprog:
sudo apt install robotpkg-eiquadprog
-
Install TSID: [https://github.com/stack-of-tasks/tsid#installation] You can put the repo in another folder if you want, like
cd ~/install/
instead ofcd $DEVEL/openrobots/src/
for the first line. -
Clone interface repository: in
/scripts
,git clone https://github.com/paLeziart/solopython
-
Initialize the cmake submodule:
git submodule init
-
Update the cmake submodule:
git submodule udpdate
-
Create a build folder:
mkdir build
-
Get inside and cmake:
cd build
thencmake .. -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=~/install -DPYTHON_EXECUTABLE=$(which python3.6) -DPYTHON_STANDARD_LAYOUT=ON
-
Compile Python bindings:
make
-
Copy them to the script folder so that the scripts can access the compiled code:
cp python/quadruped_reactive_walking/libquadruped_reactive_walking.so ../scripts/
-
Run
python3.6 main_solo12_control.py -i test
while being in thescripts
folder -
Sometimes the parallel process that runs the MPC does not end properly so it will keep running in the background forever, you can manually end all python processes with
pkill -9 python3
-
In
main_solo12_control.py
, you can change some of the parameters defined at the beginning of thecontrol_loop
function. -
Set
envID
to 1 to load obstacles and stairs. -
Set
use_flat_plane
to False to load a ground with lots of small bumps. -
If you have a gamepad you can control the robot with two joysticks by turning
predefined_vel
to False inmain_solo12_control.py
. Velocity limits with the joystick are defined inJoystick.py
byself.VxScale
(maximul lateral velocity),self.VyScale
(maximum forward velocity) andself.vYawScale
(maximum yaw velocity). -
If
predefined_vel = True
the robot follows the reference velocity pattern velID. Velocity patterns are defined inJoystick.py
, you can modify them or add new ones. Each profile defines forward, lateral and yaw velocities that should be reached at the associated loop iterations (inself.k_switch
). There is an automatic interpolation between milestones to have a smooth reference velocity command. -
You can define a new gait in
src/Planner.cpp
usingcreate_trot
orcreate_walk
as models. Create a new function (likecreate_bounding
for a bounding gait) and call it inside the Planner constructor beforecreate_gait_f()
. -
You can modify the swinging feet apex height in
include/quadruped-reactive-control/Planner.hpp
withmaxHeight_
or the lock time before touchdown withlockTime_
(to lock the target location on the ground before touchdown). -
For the MPC QP problem you can tune weights of the Q and P matrices in the
create_weight_matrices
function ofsrc/MPC.cpp
. -
Remember that if you modify C++ code you need to recompile the library.