16-311 Introduction to Robotics
         Main         Schedule         Homework         Labs         Links

  16-311 Lab 4: Controls

Lab 4: Controls

Challenge Statement

Create a two-wheeled inverted pendulum capable of balancing itself using LEGO sensors.

Lab Goals

  1. Implement an inverted pendulum.
  2. Use control principles to enable the vehicle to stay upright.
  3. Gain experience tuning controller gains to create a robot that can stay upright in a very small area.
  4. Demonstrate a non-standard robot configuration.



You may have to combat the following while developing your machines:

    PID Control

    PID control, which stands for Proportional-Integral-Derivative control, is an extremely flexible and powerful control method. An output signal u can be generated by summing the three components:


    The constants Kp, Ki, and Kd are referred to as the proportional, integral, and derivative constants, or sometimes the PID tuning constants. e(t) is the error from the desired output at time t. While these exist in continuous space, more practical implementations can be considered below:

    e[t] = curr_position-goal_position;

    The derivative component can be implemented as the difference between the current and the previous errors, divided by the time between the two. However, in most practical applications the time sampling rate is constant, so we do not divide by a constant and instead modulate Kd.

    de[t] = e[t]-e[t-1];

    The integral component is somewhat straightforward, as we can simply sum all the elements in our array (this works especially well if uninitialized values are set to 0). However, for various reasons, we may not actually want an integral term in our system. Depending on the implementation of the integral error, it could dominate the controller over time, or add undesired effects near the beginning of the curve (before the error has had sufficient time to settle).

    sum_e = 0;

    sum_e[t] = sum_e+e[t]

Lab Requirements

The 2018 Specifications for Lab 4 are presented in the following document. This will be the most up-to-date resource for lab requirements.

Lab 4 Presentation

Lab 4 Grading Sheet

Lab 4 Demonstration Sign Up Sheet

Previous year's writeup

Starting Code for Plotting


Last updated 02/07/2018 by Hannah Lyness
(c) 1999-2018: Howie Choset, Carnegie Mellon