Skip to content

vvv-school/assignment_control-pid

Repository files navigation

Design a simple PID to control a robot head

Gitpod

Prerequisites

You are supposed to know something on what a PID controller can do for you and why it is so versatile and effective 😉

If that's not the case yet, here's below an eclectic incomplete not-at-all curated list of quick or semi-quick refreshers on the argument:

Some academic resources (take them more seriously 😏):

But stop loafing around now 🔨 and heat up the skills that made you a great PID human-tuner 💪

Assignment

There is a robot standing in a world far away, whose body is fully anchored to the ground. Fortunately, the robot can still gaze around. There is also a magic red ball sticking out from the grey landscape. The ball floats insanely in front of the robot, moving along unpredictable trajectories and even teleporting from one place to another.

Given that the robot observes the world through its 320x240 couple of cameras, your task is "simply" 😆 to let the robot look constantly at the floating ball, as fast as possible, controlling both the eyes and the neck.

Thereby, you have to tune a bunch of PID velocity controllers that will drive the joint motors and in turn we will assign you points incrementally, as you meet the two sets of requirements below.

R1. Requirements to satisfy when the ball beams up into a new location

  1. The x pixel coordinate of the ball in the left camera image shall approach the center: ul ≈ 160.
  2. The y pixel coordinate of the ball in the left camera image shall approach the center: vl ≈ 120.
  3. The x pixel coordinate of the ball in the right camera image shall approach the center: ur ≈ 160.
  4. The y pixel coordinate of the ball in the right camera image shall approach the center: vr ≈ 120.
  5. The robot shall keep the eyes tilt close to 0 degrees: eyes-tilt ≈ 0 [deg].
  6. The robot shall keep the eyes pan close to 0 degrees: eyes-pan ≈ 0 [deg].

R2. Requirements to satisfy when the ball moves at constant speed

  1. The x pixel coordinate of the ball in the left camera image shall approach the center: ul ≈ 160.
  2. The y pixel coordinate of the ball in the left camera image shall approach the center: vl ≈ 120.

Score map

Requirements Points
R1.1 4
R1.2 1
R1.3 4
R1.4 1
R1.5 2
R1.6 2
R2.1 8
R2.2 4

The maximum score you can achieve is therefore 26 🏆

Expected output

If you'll do your job correctly, the outcome should look like the animation below 😎

How to proceed

We provide you with a starter code (see src/controller.cpp) that contains missing gaps you have to fill in. Don't panic, most of the software to detect the ball and deal with the module infrastructure is already done. Just focus on the control part, possibly refining and extending what you'll find therein.

Once done, you can test your code in two ways:

  1. Manually: running the yarpmanager scripts provided from within app/scripts. This will help you tune the PID gains smoothly.
  2. Automatically: running the script test.sh in the smoke-test directory. This will give you an idea of how many points you might score.

To better inspect the quality of your control, you can plot the position of the ball in the image planes along with the angles of the eyes joints as they evolve over time.

We can achieve that using Octave. Just launch:

$ ./plot.sh

You will obtain temporal diagrams like this one ✨

Once done, type quit to return to the shell.