Project 3: Orientation Control

All components of the project are due by Thursday, April 16th at 5:00pm (or close of the lab, whichever is later).

Project Goals

At the end of this project, you should be able to:

Project Overview

For this project, you will be creating a control program to maintain the orientation of helicopter at a specified compass heading (i.e., you will be doing yaw control). In brief, your craft must:


Project Components

All components are required to receive full credit for the project.

Part 1: Application Programming Interface

Implement the following functions:

Part 2: Proportional-Derivative Controller

Create a proportional-derivative controller that will bring the craft's heading to a specified goal orientation. In essence, you will implement the following:

yaw_command = yaw_center + Kp * clip(heading_error) - Kv * heading_derivative

where Kp and Kv are gain parameters that you must select (start small!), and yaw_center is the yaw command that corresponds to "no yaw acceleration" (128).

Notes:

Your main loop template (start from here!):
#define STATE_THROTTLE_UP 0
#define STATE_HOVER 1
#define STATE_THROTTLE_DOWN 2
#define STATE_DONE 3

void main_loop(void) {
       int16_t counter = 0;
       uint8_t state = STATE_THROTTLE_UP;
       uint8_t throttle = 20;

       #APPROPRIATE VARIABLE DECLARATIONS HERE#
       
       heading_current = #HOW SHOULD THIS BE INITIALIZED?#
       heading_goal = #HOW SHOULD THIS BE INITIALIZED?#
       while(1) {
           heading_last = heading_current;
           heading_current = get_heading();
           heading_error = compute_error(heading_goal, heading_current);
           heading_derivative = compute_derivative(heading_last, heading_current);

           // Display
           if(#COMMAND INPUT LINE#) {
                display_orient(heading_current);
           }else{
                display_orient(heading_error);
           }
           display_derivative(heading_derivative);

           // PD controller
           yaw_command = yaw_center +
                     Kp * clip(heading_error) - Kv * heading_derivative;
           set_yaw(yaw_command);

           // Finite State Machine for height control
           switch(state) {
                case STATE_THROTTLE_UP:
                     if((counter % 10) == 0) {
                          // True once every second
                          // Increase throttle
                          throttle += 5;
                          set_throttle(throttle);
                          // Are we at max throttle?
                          if(throttle >= 150) {
                               // Yes: change to the hover state
                               state = STATE_HOVER;
                               counter = 0;
                          }
                     }
                     break;
                case STATE_HOVER:
                     if(counter >= 600) {
                         // We have hovered for 1 minute
                         state = STATE_THROTTLE_DOWN;
                         counter = 0;
                     };
                     break;
                case STATE_THROTTLE_DOWN:
                     if((counter % 10) == 0) {
                          // True once every second
                          // Decrease throttle
                          throttle -= 5;
                          set_throttle(throttle);
                          // Are we throttled down?
                          if(throttle <= 20) {
                               // Yes: change to the done state
                               set_throttle(0);
                               state = STATE_DONE;
                               counter = 0;
                          }
                     }
                     break;
                case STATE_DONE:
                     // Do something to indicate that you are done
                     break;
           };

           // Increment time
           ++counter;

           // Give us approximately 100 ms steps
           delay_ms(100);
       }
}



References and Hints


What to Hand In

All components of the project are due by Thursday, April 16th at 5:00pm (or close of lab, whichever is later).

Grading

Group grade distribution:

Grades for individuals will be based on the group grade, but weighted by the assessed contributions of the group members.


fagg [[at]] cs.ou.edu

Last modified: Thu Apr 16 00:10:36 2009