Fly your altitude PID controller

You will now use the PID controller you wrote in the previous project to fly your drone!

Minor updates

Go take a look at the p3_pkg/scripts/student_pid_class.py and you’ll note that in the __init__ function we pass in a dict of params. We made this change to allow you to add your own parameters to the PID controllers if you would like to tweak or customize them.

Params are loaded in from p3_pkg/scripts/pid_terms.yml, parsed into a json dict, and the ‘z’ terms are passed to your altitude controller.

  1. Transfer the code from your Project 2 PID implementation to the p3_pkg/scripts/student_pid_class.py stencil.
  2. Update your code to use the params dict instead of individual arguments.
  3. Update your step code to adhere to the max and min values. For the altitude controller, your output should range between 1100 and 1900.
  4. Test your changes by running p3_pkg/scripts/sim.py.

Fly!!!!!

When you are happy with your changes and confident in the behavior of your PID implementation, you can fly your code! Before you do this you must

  • Have implemented and thoroughly tested student_infrared_pub.py using a ruler and the javascript interface
  • Have implemented and throroughly tested+tuned student_pid_class.py and your z pid-terms using the simulator

Go to CIT 121 to screw the z-rig mount to your drone.

CLIP

Use the extra M3 bolts that came with your motors to screw it into the 4 holes in the bottom of your drone. Make sure it’s tight!

SCREW

Mount your drone on the PVC guide rails, and put the retainer cap back on top. This will keep your drone from flying away!!! Note that the battery is mounted onto the bottom of the z-rig mount.

POLE

I’d recommend putting at least two of the legs on your drone so it stays level at the bottom of the rig.

LEGS

Use state_controller (in p3_pkg) and the javascript interface (also in p3_pkg/web/index.html) as normal to fly your drone on the rig. Wear safey glasses and stand back. Be ready to shut it off at any moment.

Test the performance of your PID by raising and lowering the setpoint (keys ‘w’ and ‘s’ in the javascripts interface). You want to make it both steady when hovering, and responsive to your control inputs. The drone should not oscilate. Tune your pid terms in scripts/pid_terms.yml to improve performance.

Checkoff

Come to TA hours to show off your drone on the rig! We will be looking for:

  • Responsive, stable flight
  • The ablity to land, wait a bit, and takeoff again without restarting state_controller (this means reset is implemented safely in your PID)