Git Product home page Git Product logo

balance-robot's Introduction

Self Balancing Robot

In this repository is code that (attempts) to make a robot balance on two wheels.

Theory of Operation

PID

The classic control algorithm for an inverted pendulum system like a balancing robot is the PID Controller. The Wikipedia page does a pretty good job of explaining it, but the gist of it is that it takes three terms and returns an output that is fed to the motor driver to achieve balance based on the current error (how far off are we), current error derivative (how fast are we accumulating error), and the integral of the error (how much accumulated error do we have over time).

Implementations of this algorithm in this application use an accelerometer or inertial measurement unit to determine the error. Assuming a balance point of zero degrees (or 90° from horizontal) the user calculates the P, I and D values. Each value is then multiplied them each by a tuning coefficient that controls how much sway (npi) that value has over the output, and the three are then summed and passed on to a drive system.


There are many variations and implementations of PID controllers, and systems can get complicated rather quickly with multiple cascading PIDs. In my experience, the more complicated the system the harder it is to tune.

Enter DPA

One of my heroes is David P. Anderson, who is a professor at Southern Methodist University. He builds robots and is kind enough to share them with us all on the Internet!

One of his robots is nBot, a self-balancing robot. He published the control theory in a text file on the Internet it 2002, and it is one of the simplest and most effective algorithms I've seen in the space to date so I chose to implement it here. It's a dual PD controller, and skips the integral term altogether. I urge you to take a look at the text file - it's far simpler to understand than most PID papers, and I've included a copy in this repository.

Required Libraries

The Balancing Robot

I put together a large (30" high) balancing robot out of Actobotics parts and some Yumo encoders. The total cost to build it was quite a lot, but it serves as a great platform for hacking on balancing algorithms.

At its heart is an Arduino Pro Mega.

There is no wish list for the large balancing robot... yet.

The miniature version of the balbot

This is the smaller version of the balancing robot that I tried to make for a cost of $150 or less. It uses a 9DoF single-chip IMU and an inexpensive set of motors and encoders, as well as a $9 motor driver. The platform is a large piece of prototyping board, and everything is held together with a bit of tape, some solder and a healthy amount of jumper wires.

Check out the SparkFun Wish List for a list of parts used on the mini balance bot.

Front

Front Image

2/3rds View

Front Image

balance-robot's People

Contributors

stilldavid avatar

Watchers

James Cloos avatar  avatar

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.