Coder Social home page Coder Social logo

giulioturrisi / self-balancing-robot Goto Github PK

View Code? Open in Web Editor NEW
26.0 0.0 4.0 13.17 MB

Control algorithms for a self balancing robot (two wheeled inverted pendulum) using ROS2

Python 95.73% C 4.27%
robotics coppeliasim ros2 control simulation real-robots optimization ros self-balancing-robot

self-balancing-robot's Introduction

Overview

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

List of available controllers

  1. PID
  2. Linear Quadratic Regulator
  3. Linear Quadratic Integral Regulator
  4. Least Square Linear Quadratic Regulator
  5. Adaptive Linear Quadratic Regulator (MIT rule)
  6. Sliding Mode
  7. RL policy via IsaacGym
  8. Nonlinear MPC via Acados
  9. Iterative Linear Quadratic Regulator
  10. Iterative Linear Quadratic Regulator via Crocoddyl
  11. Predictive Sampling

List of available state estimators

  1. Extended Kalman Filter

Repository structure

It includes the following folders and subfolders:

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

  2. coppeliasim_simulation: scenes used for simulating the robot

  3. ros2_ws: collection of ROS2 nodes for controlling the robot and some external folders such as simExtROS2 and ros2_bubble_rob(dependencies for CoppeliaSim)

Dependencies

  1. ROS2 Humble

  2. CoppeliaSim for simulations

Build on Linux

  1. clone the repo recursively
git clone --recurse-submodules https://github.com/giulioturrisi/Self-Balancing-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 twip_env && source your_path_to/Self-Balancing-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/Self-Balancing-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/Self-Balancing-Robot/python_scripts/controllers/acados/lib"
export ACADOS_SOURCE_DIR="/your_path_to/Self-Balancing-Robot/python_scripts/controllers/acados"

How to run the simulation

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

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

  1. to command the robot with a joystick
ros2 launch teleop_twist_joy teleop-launch.py joy_config:='xbox'

Status

Still working in progress, the real robot does not exist yet. Recently added IsaacGym to learn an RL policy (Self-Balancing-Robot-IsaacGym)!

self-balancing-robot's People

Contributors

giulioturrisi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

self-balancing-robot's Issues

Can't launch the simulation with CoppeliaSim 4.6

Hi, I'm trying to use the simulation, through docker, following the readme but I get the error :

./coppeliaSim.sh -s self_balancing_robot.ttt 
the argument ('/home/coppeliasim_simulation/self_balancing_robot.ttt') for option '--auto-start' is invalid

when running the command :
./coppeliaSim.sh -s self_balancing_robot.ttt

I don't understand what the coppeliaSim.sh script does, but I belive my path file is ok.

Any hint ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.