Skip to content

In this project, you will explore Control Systems (LQR Controller) and build a Self-Balancing Inverted Pendulum Bot in hardware. LQR Controller in Action: https://youtu.be/9dd4eDvZAoc

License

Notifications You must be signed in to change notification settings

vrnimje/Inverted-LQR-Bot-Eklavya

Repository files navigation

About This Project

Control systems form the basis for ensuring that every automatic system performs its ordained task accurately, efficiently and quickly (optimally) despite being subjected to varying environmental conditions.

In this project, we explore one of these control systems, i.e., LQR (Linear Quadratic Regulator) Controller, which is a type of controller in which we try to minimise a cost function by optimising the various factors involved in the physical system. Then, we apply LQR to the classical problem of an Inverted Pendulum on Rails, which is used as a benchmark for testing control strategies, both in simulation and hardware.

image

1. Research Topics

  • Linear Algebra, for representation of various aspects of physical systems, like, current state, stability, etc.. (Notes for the same)
  • A thorough understanding of Control Systems. (Notes for the same)

2. List of Software Used

3. List of Hardware Used

  • NEMA-17 Stepper Motor (Notes for the same)
  • DRV8825 Motor Driver
  • Rails, on which the cart moves
  • Timing belt
  • Custom-designed laser-cut cart, made of acrylic, and has screw-holes for the wheels (bearings) (Drawing file for the plates)
  • ESP32 microcontroller
  • MPU6050, the IMU used for measuring the deviation of the pendulum from the normal
  • 9 bearings
    • 8 in the cart (acting as wheels)
    • 1 inserted in the pendulum
  • Pendulum rod, having comparable weight to the cart

Modelling the system in Octave

We first model the physical system by considering it's parameters (like mass of cart, pendulum rod, length of rod, etc.) and the dynamics equations.

image

Then, we linearise the system about it's equilibrium point, $(\pi, 0)$. Then, we represent the system as: $$\dot{x} = Ax + Bu$$ where 'u' is our input to the system.

For the linearised system, we then define the system using the 'ss()' function. Using the 'c2d()' function, we discretise the system, and then we get the feedback matrix K, by using the function 'dlqr()'. Octave File for reference

The input, $$u = -Kx$$ is then applied to the system, so as to minimise the LQR Cost function. The output is: Screencast-from-29-09-22-061416

Using the 'step()' function, this is the plot generated for the step response of the linearised system in terms of the state variables, i.e., $[\theta, \dot{\theta}, x, \dot{x}]$ with respect to time.

Step Response

Implementation of Inverted Pendulum in Hardware

First, we used the rails which were part of a CNC machine, and were firmly held in place. Then, the cart, fitted with the bearings, is then places around the rails. The stepper motor and the free pulley are mounted aside the rails, and both of which drive a timing belt, which itself drives the cart. The MPU6050 is mounted on the rod, with the help of screws, near the pivot point. The rod itself contains a bearing, which allows it to rotate about the screw. The screw is held in place on the cart by means of a mount.

My first board(1)

image

These are some of the issues we faced during the setup and testing process of the system, along with their solutions.

This is one of our best runs:

WhatsApp.Video.2022-10-14.at.17.24.47.mp4

Future Work

  • Improve balancing
  • Add swing up controller
  • Implement LQR on self-balancing bot on wheels

Contributors

Acknowledgements and Resources

About

In this project, you will explore Control Systems (LQR Controller) and build a Self-Balancing Inverted Pendulum Bot in hardware. LQR Controller in Action: https://youtu.be/9dd4eDvZAoc

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published