Closed-Loop Go To Goal

Let’s now add closed-loop (feedback) control to our robot. We’ll start by using a proportional controller to make our robots more reliably move to a target location.

What you will learn

  • How to implement proportional control
  • How to convert controller output to motor commands

Terminology

closed-loop (feedback) control
a control system that uses feedback to change its actions
proportional control
a simple control system that produces an output proportional to the current error between desired and measured values

Lecture

Errors in the video:

  • I never update left-time or right-time. They should be set to now after we compute time-delta

This video covers proportional control. Specifically, the following equation:

\[ u = K_p e \]

This equation is related to a few electrical concepts (e.g., PWM) and the code implementation. Here’s a table to help you understand the relationships:

Symbol Description Scale
\(u\) output of proportional control algorithm \([-∞, ∞]\)
speed-factor scaled speed (sign indicates direction; magnitude indicates throttle) \([-1, 1]\)
PWM Duty Factor signal sent to motor driver \([0, 1]\)

Consider using \(u\) directly as the speed-factor for the motor. What happens when \(e = 0\)?

Scenario \(e\) \(u\) speed-factor
Going the desired speed 0 0 needs to maintain speed (not 0)
Going to slow + + needs to increase to increase speed
Going to fast - - needs to decrease to decrease speed

If \(u\) is too high we will try to change our speed to fast, which is not good for the motors. Likewise, we must constrain speed-factor to \([-1, 1]\) to ensure we don’t make the robot go beyond its capabilities.

Exercise

For this exercise you will repeat the go-to-goal task from chapter 6.

You will submit your responses on gradescope. Only one partner should submit. The submitter will add the other partner through the gradescope interface.

Additional details for using gradescope can be found here:

You should open the gradescope assignment now so that you know what to work complete.

Grading

I will grade all exercises using a scale of “Nailed It” / “Not Yet”. See the course grading policy for more information, and check gradescope for deadlines.

Overview

Every team will write a program for the following task:

Make your robot move forward 3 meters using closed-loop control.

We will mark starting and target locations on the floor in the the lab (on tile) and in the hallway (on carpet). Everyone will record 5 trials for each surface and record their results in this spreadsheet.

Some things to consider:

  • It is OK if your wheel diameter is the same for each trial
  • You can vary the distance traveled by adjusting the speed value and/or the duration
  • Your trials do not need to appear in sequential rows

It is not vital for this exercise, but you will eventually want to:

  • tune your values for \(k_p\) (separately for the left and right motors)
  • tune your value for max-speed-step
  • measure your value for max-speed

Wrap-Up

Next week we will take a step back and understand how all of these pieces (microcontroller, WiFi, motors, etc.) work together.

Resources