Code Monkey home page Code Monkey logo

balance_bot's Introduction

Balance Bot

For this project, I implemented a cascaded PID controller to stabilize an inverted pendulum style robot. A functional block diagram of the controller is shown below:

Controls Block Diagram

The user gives a desired velocity and/or rate of rotation with a remote controller. This reference input is integrated over time to give a reference position to the outer PID loop, which itself generates a reference body angle for the robot to acheive. This allows the robot to oscillate about an equilibrium point. The backlash present in the gearboxes used meant that the robot would not attain a perfectly stationary position.

Outer Loop Controller

All of the code for controlling the robot was written in C, and compiled and run on a BeagleBone Green board. Our team of three each developed on independent branches, and merged to master after verifying the code's performance on the robot. The program ran in a single thread, driven by interrupts from the IMU's accelerometer at 100 Hz. All necessary state information was passed by a reference to a state data structure:

struct mb_state{
    // raw sensor inputs
    float  theta;         // body angle (rad)
    float  phi;           // average wheel angle (rad)
    double heading;
    double last_heading;
    double left_pos;      // left encoder counts since last reading
    double right_pos;     // right encoder counts since last reading
    double last_pos;

    //calcs 
    float innerloopintegral;
    float outerloopintegral;
    float headingintegral;
    float headingDeltaPWM;
    float headingError;
    float theta_ref;
    float target_x;
    float target_y;
    int cur_target_idx;
    float dist_to_target;

    //outputs
    double   left_cmd;  //left wheel command [-1..1]
    double   right_cmd; //right wheel command [-1..1]

    //references
    float distance_ref;
    float psi_ref;
};

The robot was also able to successfully follow a series of waypoint coordinates, moving from one to the next when it had reached a distance threshold of 5 cm. The plot below shows the robot's own trajectory estimate, found from wheel odometry, as it completed four laps around a square. Trajectory following plot

balance_bot's People

Contributors

bkarwoski avatar

Stargazers

 avatar

Watchers

 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.