Main Page | Data Structures | Directories | File List | Data Fields | Globals

rosetta.c

Go to the documentation of this file.
00001 #include <config.h>
00002 
00003 #include <string.h>
00004 #include <math.h>
00005 
00006 #include <cartcomm/cframe.h>
00007 #include <drivers/drivers.h>
00008 #include <recorder.h>
00009 
00010 #define DEG_TO_RAD (3.14159 / 180.0)
00011 #define CART_WHEEL_BASE 1.667
00012 
00013 typedef struct {
00014     int counter;
00015 } state_t;
00016 
00017 void *driver_rosetta_alloc(void) {
00018     state_t *state;
00019 
00020     state = malloc(sizeof(state_t));
00021     if(state == NULL)
00022         return NULL;
00023 
00024     state->counter = 0;
00025 
00026     return state;
00027 }
00028 
00029 void driver_rosetta_free(void *data) {
00030     free(data);
00031 }
00032 
00033 int driver_rosetta(cframe_t *cf, void *data) {
00034     state_t *state = (state_t *) data;
00035 
00036     recorder_add(cf);
00037 
00038     if(strcmp(cf->cur_mode, "auto") != 0)
00039         return 0;
00040 
00041     state->counter = (state->counter + 1) % 100;
00042 
00043     if(state->counter < 30) {
00044         cf->cmd_irad = sin(35.0 * DEG_TO_RAD) / CART_WHEEL_BASE;
00045         cf->cmd_speed = 2.5;
00046     } else if(state->counter < 70) {
00047         cf->cmd_irad = 0;
00048         cf->cmd_speed = 4.5;
00049     } else {
00050         cf->cmd_irad = -sin(35.0 * DEG_TO_RAD) / CART_WHEEL_BASE;
00051         cf->cmd_speed = 1.5;
00052     }
00053 
00054     return 0;
00055 }

Generated on Thu Sep 6 13:13:11 2007 for driver by  doxygen 1.3.9.1