Here are the steps:
All components are required to receive full credit for the project.
Modify your main function such that it is structured as follows (you will of course need to add other code). Here is an outline for the code:
int main(void) {
int16_t counter = 0;
int16_t heading, heading_goal, heading_error;
int16_t theta1, theta2;
int16_t rotation_rate, distance_left, distance_right;
uint8_t state = STATE_START;
#APPROPRIATE VARIABLE DECLARATIONS HERE#
#APPROPRIATE INITIALIZATIONS HERE#
theta1 = get_orientation();
theta2 = ####
middle_thrust_dir(1);
while(1) {
heading = get_orientation();
heading_error = compute_error(heading_goal, heading);
rotation_rate = get_rotation_rate();
distance_left = get_left_sensor();
distance_right = get_right_sensor();
// Display
if(#SWITCH OPEN#) {
display_orient(heading);
}else{
display_orient(heading_error);
}
// Steer away from obstacles
status = steering_control(distance_left, distance_right, rotation_rate, #PICK SOME SMALL VALUE#);
if(status == -1) {
// No obstacles: steer to desired direction
pd_control(heading_error, rotation_rate, #PICK THE SAME SMALL VALUE#);
}
// Note that "status" will be useful for detecting some FSM events
// Finite state machine
switch(state) {
case STATE_START:
:
break;
case STATE_NAVIGATE_1:
:
break;
:
:
default:
// this should never happen
#Shut down craft#
while(1){};
}
// Increment time
++counter;
// Wait for the flag to be set (once every 50 ms)
while(flag == 0) {};
// Clear the flag for next time.
flag = 0;
}
}
Remember that documentation is about helping you and others looking at your code to understand what it is doing. Therefore, it will generally describe the logic of the code (and not-necessarily the low-level details). For this class:
See an example.
Grades for individuals will be based on the group grade, but weighted by the assessed contributions of the group members.
Last modified: Sun Apr 18 23:38:35 2010