X-Git-Url: http://git.droids-corp.org/?p=aversive.git;a=blobdiff_plain;f=projects%2Fmicrob2010%2Fmainboard%2Fcommands_traj.c;h=1898bd8f69ce65e22a1f8f9d2506eb8248beb0d9;hp=be9150b3b2fa6bdfff3bef92a5d325a93332c190;hb=dab083b5d263fdf9675362bfe5a85f993a43a6c6;hpb=78150017ab8c5615af414df706a0525fe7c262ae diff --git a/projects/microb2010/mainboard/commands_traj.c b/projects/microb2010/mainboard/commands_traj.c index be9150b..1898bd8 100644 --- a/projects/microb2010/mainboard/commands_traj.c +++ b/projects/microb2010/mainboard/commands_traj.c @@ -59,6 +59,7 @@ #include "strat_utils.h" #include "strat_base.h" #include "strat.h" +#include "strat_db.h" #include "../common/i2c_commands.h" #include "i2c_protocol.h" @@ -441,6 +442,63 @@ parse_pgm_inst_t cmd_track_show = { }, }; +/**********************************************************/ +/* centrifugal configuration */ + +/* this structure is filled when cmd_centrifugal is parsed successfully */ +struct cmd_centrifugal_result { + fixed_string_t arg0; + fixed_string_t arg1; + float val; +}; + +/* function called when cmd_centrifugal is parsed successfully */ +static void cmd_centrifugal_parsed(void * parsed_result, void * data) +{ + struct cmd_centrifugal_result * res = parsed_result; + + if (!strcmp_P(res->arg1, PSTR("set"))) { + position_set_centrifugal_coef(&mainboard.pos, res->val); + } + printf_P(PSTR("centrifugal set %f\r\n"), mainboard.pos.centrifugal_coef); +} + +prog_char str_centrifugal_arg0[] = "centrifugal"; +parse_pgm_token_string_t cmd_centrifugal_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_centrifugal_result, arg0, str_centrifugal_arg0); +prog_char str_centrifugal_arg1[] = "set"; +parse_pgm_token_string_t cmd_centrifugal_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_centrifugal_result, arg1, str_centrifugal_arg1); +parse_pgm_token_num_t cmd_centrifugal_val = TOKEN_NUM_INITIALIZER(struct cmd_centrifugal_result, val, FLOAT); + +prog_char help_centrifugal[] = "Set centrifugal coef"; +parse_pgm_inst_t cmd_centrifugal = { + .f = cmd_centrifugal_parsed, /* function to call */ + .data = NULL, /* 2nd arg of func */ + .help_str = help_centrifugal, + .tokens = { /* token list, NULL terminated */ + (prog_void *)&cmd_centrifugal_arg0, + (prog_void *)&cmd_centrifugal_arg1, + (prog_void *)&cmd_centrifugal_val, + NULL, + }, +}; + +/* show */ + +prog_char str_centrifugal_show_arg[] = "show"; +parse_pgm_token_string_t cmd_centrifugal_show_arg = TOKEN_STRING_INITIALIZER(struct cmd_centrifugal_result, arg1, str_centrifugal_show_arg); + +prog_char help_centrifugal_show[] = "Show centrifugal"; +parse_pgm_inst_t cmd_centrifugal_show = { + .f = cmd_centrifugal_parsed, /* function to call */ + .data = NULL, /* 2nd arg of func */ + .help_str = help_centrifugal_show, + .tokens = { /* token list, NULL terminated */ + (prog_void *)&cmd_centrifugal_arg0, + (prog_void *)&cmd_centrifugal_show_arg, + NULL, + }, +}; + /**********************************************************/ @@ -765,6 +823,7 @@ static void auto_position(void) interrupt_traj_reset(); strat_get_speed(&old_spdd, &old_spda); strat_set_speed(AUTOPOS_SPEED_FAST, AUTOPOS_SPEED_FAST); + strat_set_acc(3, 3); err = strat_calib(300, END_INTR|END_TRAJ|END_BLOCKING); if (err == END_INTR) @@ -779,11 +838,13 @@ static void auto_position(void) if (err == END_INTR) goto intr; + time_wait_ms(250); trajectory_a_rel(&mainboard.traj, COLOR_A(-90)); err = wait_traj_end(END_INTR|END_TRAJ); if (err == END_INTR) goto intr; + time_wait_ms(250); err = strat_calib(300, END_INTR|END_TRAJ|END_BLOCKING); if (err == END_INTR) goto intr; @@ -796,13 +857,13 @@ static void auto_position(void) err = wait_traj_end(END_INTR|END_TRAJ); if (err == END_INTR) goto intr; - wait_ms(100); + time_wait_ms(250); trajectory_a_rel(&mainboard.traj, COLOR_A(-110)); err = wait_traj_end(END_INTR|END_TRAJ); if (err == END_INTR) goto intr; - wait_ms(100); + time_wait_ms(250); strat_set_speed(old_spdd, old_spda); return; @@ -891,37 +952,37 @@ parse_pgm_inst_t cmd_position_set = { /**********************************************************/ /* strat configuration */ -/* this structure is filled when cmd_strat_infos is parsed successfully */ -struct cmd_strat_infos_result { +/* this structure is filled when cmd_strat_db is parsed successfully */ +struct cmd_strat_db_result { fixed_string_t arg0; fixed_string_t arg1; }; -/* function called when cmd_strat_infos is parsed successfully */ -static void cmd_strat_infos_parsed(void *parsed_result, void *data) +/* function called when cmd_strat_db is parsed successfully */ +static void cmd_strat_db_parsed(void *parsed_result, void *data) { - struct cmd_strat_infos_result *res = parsed_result; + struct cmd_strat_db_result *res = parsed_result; if (!strcmp_P(res->arg1, PSTR("reset"))) { - strat_reset_infos(); + strat_db_init(); } - strat_infos.dump_enabled = 1; - strat_dump_infos(__FUNCTION__); + strat_db.dump_enabled = 1; + strat_db_dump(__FUNCTION__); } -prog_char str_strat_infos_arg0[] = "strat_infos"; -parse_pgm_token_string_t cmd_strat_infos_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_strat_infos_result, arg0, str_strat_infos_arg0); -prog_char str_strat_infos_arg1[] = "show#reset"; -parse_pgm_token_string_t cmd_strat_infos_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_strat_infos_result, arg1, str_strat_infos_arg1); +prog_char str_strat_db_arg0[] = "strat_db"; +parse_pgm_token_string_t cmd_strat_db_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_strat_db_result, arg0, str_strat_db_arg0); +prog_char str_strat_db_arg1[] = "show#reset"; +parse_pgm_token_string_t cmd_strat_db_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_strat_db_result, arg1, str_strat_db_arg1); -prog_char help_strat_infos[] = "reset/show strat_infos"; -parse_pgm_inst_t cmd_strat_infos = { - .f = cmd_strat_infos_parsed, /* function to call */ +prog_char help_strat_db[] = "reset/show strat_db"; +parse_pgm_inst_t cmd_strat_db = { + .f = cmd_strat_db_parsed, /* function to call */ .data = NULL, /* 2nd arg of func */ - .help_str = help_strat_infos, + .help_str = help_strat_db, .tokens = { /* token list, NULL terminated */ - (prog_void *)&cmd_strat_infos_arg0, - (prog_void *)&cmd_strat_infos_arg1, + (prog_void *)&cmd_strat_db_arg0, + (prog_void *)&cmd_strat_db_arg1, NULL, }, }; @@ -939,9 +1000,8 @@ struct cmd_strat_conf_result { static void cmd_strat_conf_parsed(void *parsed_result, void *data) { // struct cmd_strat_conf_result *res = parsed_result; - - strat_infos.dump_enabled = 1; - strat_dump_conf(); + strat_conf.dump_enabled = 1; + strat_conf_dump(__FUNCTION__); } prog_char str_strat_conf_arg0[] = "strat_conf"; @@ -1002,12 +1062,12 @@ static void cmd_strat_conf2_parsed(void *parsed_result, void *data) #endif if (on) - strat_infos.conf.flags |= bit; + strat_conf.flags |= bit; else - strat_infos.conf.flags &= (~bit); + strat_conf.flags &= (~bit); - strat_infos.dump_enabled = 1; - strat_dump_conf(); + strat_conf.dump_enabled = 1; + strat_conf_dump(__FUNCTION__); } prog_char str_strat_conf2_arg0[] = "strat_conf"; @@ -1050,32 +1110,32 @@ static void cmd_strat_conf3_parsed(void *parsed_result, void *data) if (!strcmp_P(res->arg1, PSTR("scan_opponent_min_time"))) { if (res->arg2 > 90) res->arg2 = 90; - strat_infos.conf.scan_opp_min_time = res->arg2; + strat_conf.scan_opp_min_time = res->arg2; } else if (!strcmp_P(res->arg1, PSTR("delay_between_opponent_scan"))) { if (res->arg2 > 90) res->arg2 = 90; - strat_infos.conf.delay_between_opp_scan = res->arg2; + strat_conf.delay_between_opp_scan = res->arg2; } else if (!strcmp_P(res->arg1, PSTR("scan_our_min_time"))) { if (res->arg2 > 90) res->arg2 = 90; - strat_infos.conf.scan_our_min_time = res->arg2; + strat_conf.scan_our_min_time = res->arg2; } else if (!strcmp_P(res->arg1, PSTR("delay_between_our_scan"))) { if (res->arg2 > 90) res->arg2 = 90; - strat_infos.conf.delay_between_our_scan = res->arg2; + strat_conf.delay_between_our_scan = res->arg2; } else if (!strcmp_P(res->arg1, PSTR("wait_opponent"))) { - strat_infos.conf.wait_opponent = res->arg2; + strat_conf.wait_opponent = res->arg2; } else if (!strcmp_P(res->arg1, PSTR("lintel_min_time"))) { - strat_infos.conf.lintel_min_time = res->arg2; + strat_conf.lintel_min_time = res->arg2; } #endif - strat_infos.dump_enabled = 1; - strat_dump_conf(); + strat_conf.dump_enabled = 1; + strat_conf_dump(__FUNCTION__); } prog_char str_strat_conf3_arg0[] = "strat_conf";