build details

Show: section status errors & todos local changes recent changes last change in-page changes feedback controls

Appendix A: Altitude Tuning

Modified 2020-11-04 by Sean Hastings

In this part, you will be transferring the altitude PID you created in part 1 onto your drone. You will then tune the PID gains on your drone as you did in the simulator.

Flying with Your Altitude PID!

Modified 2020-11-04 by Sean Hastings

You will now be using your altitude PID to control the height of the drone. To tune your altitude PID, you will first use the Ziegler-Nichols tuning method to generate an initial set of tuning parameters. You will then fine tune these parameters similar to how you tuned the drone in simulation.

To use your PID, you’ll be running student_pid_controller.py instead of pid_controller.py. This will allow your PID to run alongside our planar PIDs; your PID will be responsible for keeping the drone flying steady vertically.

Setup
Change directories to ~/ws/src. Run git clone https://github.com/h2r/project-pid-implementation-yourGithubName.git. In your repo, change “pidrone_project3_pid” to “project-pid-implementation-yourGithubName” in package.xml and “project(pidrone_project3_pid)” to “project(project-pid-implementation-yourGithubName)” in CMakeLists.txt. Also remove the msg folder, and comment out “add_message_files” in CMakeLists.txt. Then change directories back to ~/ws/ and run catkin_make --pkg project-pid-implementation-yourGitHubName.

OR

Use the scp command to transfer student_pid_class.py, student_pid_controller.py, and z_pid.yaml from the repo on your base station to the scripts folder of your drone (~/ws/src/pidrone_pkg/scripts/). In the instructions below, instead of using rosrun, you may use python to execute your scripts.

Change directories into ~/ws/src/pidrone_pkg and modify pi.screenrc to start up with your altitude pid by changing python pid_controller.py\n to rosrun project-pid-implementation-yourGitHubName student_pid_controller.py\n. Prepare your drone to fly and then navigate to `4 of the screen. Press ctrl-c to quit student_pid_controller.

In this screen (`4), modify ~/ws/src/project-pid-implementation-yourGitHubName/z_pid.yaml by setting K to 1250 and the rest of the gain constants to 0. Now run rosrun project-pid-implementation-yourGitHubName student_pid_controller.py to fly with your altitude PID.

Exercises

Fly your drone and observe its flight. Tune K_p by slowly increasing its value between flights until you can see the drone moving up and down with uniform oscillations. Each time you will need to quit the controller, edit ~/ws/src/project-pid-implementation-yourGitHubName/z_pid.yaml, and then run rosrun project-pid-implementation-yourGitHubName student_pid_controller.py again to use the new PID gains.

  1. Record your final K_p value that causes uniform oscillations as K_u , the ultimate gain.
  2. Fly your drone and pause the altitude graph on the web interface when you see two peaks. Find the time difference between these two peaks and record this value as T_u , the ultimate period.
  3. Use your K_u and T_u values to compute K_p , K_i , and K_d . Refer to the equations in the Ziegler-Nichols section in the introduction to this project. Record these values and change z_pid.yaml accordingly.
Footnotes

2 Use the graph on the web interface to observe the drone’s behavior as it oscillates around the 0.3m setpoint the drone’s ability to hover at the setpoint. When observing the drone itself, try to get eye-level with the drone to just focus on the the altitude and ignore the planar motion; it is easier to focus on one axis at a time when tuning the PIDs. The planar axes can be re-tuned after you tune your altitude pid if need be.