camera in autonomous

Sorry if this thread is bothersome but I need help. I haven’t had time to ask our mentor because of his work and our captain is too busy with getting a successful launcher. I know how to program for the RC and to get the robot to move in autonomous like forward, back, left, right, and for a certain amount of time but with adding the camera, I have no clue how to add the camera to autonomous since I have no idea about it except configuring it. So can anyone give me an example because I’m pretty good at self-learning from example. :confused:

This is assuming you have been able to make the camera work in normal mode and I am using the “bells and whistles” version of Kevin Watson’s camera code.

Copy this function into the user_routines.c then create a function prototype in user_routines.h and delete ONLY THE THINGS IN THIS FUNCTION from the user_routine.c in the Kevin Watson’s camera code form the function:
void Process_Data_From_Master_Up(void)
Leave everything else in this is function as it is.

void Camera_Control(void)
{
static unsigned char count = 0;
static unsigned char camera_menu_active = 0;
static unsigned char tracking_menu_active = 0;
unsigned char terminal_char;
unsigned char returned_value;

// send diagnostic information to the terminal, but don’t
// overwrite the camera or tracking menu if it’s active
if(camera_menu_active == 0 && tracking_menu_active == 0)
{
Tracking_Info_Terminal();
}

// This function is responsable for camera initialization
// and camera serial data interpretation. Once the camera
// is initialized and starts sending tracking data, this
// function will continuously update the global T_Packet_Data
// structure with the received tracking information.
Camera_Handler();

// This function reads data placed in the T_Packet_Data
// structure by the Camera_Handler() function and if new
// tracking data is available, attempts to keep the center
// of the tracked object in the center of the camera’s
// image using two servos that drive a pan/tilt platform.
// If the camera doesn’t have the object within it’s field
// of view, this function will execute a search algorithm
// in an attempt to find the object.
if(tracking_menu_active == 0)
{
Servo_Track();
}

// this logic guarantees that only one of the menus can be
// active at any giiven time
if(camera_menu_active == 1)
{
// This function manages the camera menu functionality,
// which is used to enter camera initialization and
// color tracking parameters.
camera_menu_active = Camera_Menu();
}
else if(tracking_menu_active == 1)
{
// This function manages the tracking menu functionality,
// which is used to enter parameters that describe how
// the pan and tilt servos will behave while in searching
// and tracking modes.
tracking_menu_active = Tracking_Menu();
}
else
{
// has the user sent any data via the terminal?
terminal_char = Read_Terminal_Serial_Port();
// check to see if any “hotkeys” have been pressed
if(terminal_char == CM_SETUP_KEY)
{
camera_menu_active = 1;
}
else if(terminal_char == TM_SETUP_KEY)
{
tracking_menu_active = 1;
}
}

// This funtion is used by the functions Camera_Menu() and
// Tracking_Menu() to manage the writing of initialization
// parameters to your robot controller’s non-volatile
// Electrically Erasable Programmable Read-Only Memory
// (EEPROM)
EEPROM_Write_Handler();
}

This is basicly just copying the camera stuff to a different function so I can call it somewhere else.
Now you can call this function from user_routines_fast.c in the autonomous code.