Skip to content

Latest commit

 

History

History
100 lines (67 loc) · 2.95 KB

README.md

File metadata and controls

100 lines (67 loc) · 2.95 KB

Overview

This repo contains the code for controlling both a real and a simulated flywheel pendulum robot via ROS2.

List of available controllers

  1. Feedback Linearization
  2. Linear Quadratic Regulator
  3. Adaptive Linear Quadratic Regulator
  4. Nonlinear MPC via Acados
  5. Nonlinear MPC via Casadi
  6. Iterative Linear Quadratic Regulator

Repository structure

It includes the following folders:

  1. python_scripts: most of the ROS2 nodes call some classes here

  2. coppeliasim_simulation: scenes used for simulating the robot with CoppeliaSim

  3. ros2_ws: collection of ROS2 nodes for controlling the robot

Dependencies

  1. ROS2 Humble

  2. CoppeliaSim

Build on Linux

  1. clone the repo recursively
git clone --recurse-submodules https://github.com/giulioturrisi/Flywheel-Pendulum-Robot.git
  1. install miniforge (x86_64)

  2. create an environment using the file in the folder installation/conda:

    conda env create -f mamba_environment.yml
  1. follow the instruction here to install ros-humble

  2. download CoppeliaSim

  3. add in your .bashrc

alias twip_env="conda activate flywheel_env && source your_path_to/Flywheel-Pendulum-Robot/ros2_ws/install/setup.bash"
export COPPELIASIM_ROOT_DIR=your_path_to/CoppeliaSim
  1. start your environment and go in ros2_ws
twip_env
cd your_path_to/Flywheel-Pendulum-Robot/ros2_ws
rosdep install -y -r -q --from-paths src --ignore-src --rosdistro humble
ulimit -s unlimited
colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release
  1. if you need acados, go inside the acados/acados folder and press
mkdir build
cd build
cmake -DACADOS_WITH_QPOASES=ON  -DACADOS_WITH_OSQP=ON ..
make install -j4
pip install -e ./../interfaces/acados_template

then in your .bashrc, add

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"/your_path_to/Flywheel-Pendulum-Robot/python_scripts/controllers/acados/lib"
export ACADOS_SOURCE_DIR="/your_path_to/Flywheel-Pendulum-Robot/python_scripts/controllers/acados"

How to run the simulation

  1. Open Coppeliasim and run the scene scene.ttt in the folder coppeliasim_simulation
./coppeliaSim.sh -f your_path_to/Flywheel-Pendulum-Robot/coppeliasim_simulation/scene.ttt 
  1. on a new terminal
ros2 run controllers <control_node>                     

where in <control_node> you can choose the type of controller you want.

Real Robot

The CAD files are from the wonderful project based on SimpleFoc