#include "strat_utils.h"
#include "strat_base.h"
#include "strat.h"
+#include "strat_db.h"
#include "../common/i2c_commands.h"
#include "i2c_protocol.h"
},
};
+/**********************************************************/
+/* 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,
+ },
+};
+
/**********************************************************/
strat_get_speed(&old_spdd, &old_spda);
strat_set_speed(AUTOPOS_SPEED_FAST, AUTOPOS_SPEED_FAST);
- trajectory_d_rel(&mainboard.traj, 300);
- err = wait_traj_end(END_INTR|END_TRAJ|END_BLOCKING);
+ err = strat_calib(300, END_INTR|END_TRAJ|END_BLOCKING);
if (err == END_INTR)
goto intr;
- wait_ms(100);
- strat_reset_pos(ROBOT_WIDTH/2,
+ strat_reset_pos(ROBOT_WIDTH/2 + 100,
COLOR_Y(ROBOT_HALF_LENGTH_FRONT),
COLOR_A(-90));
+ strat_hardstop();
trajectory_d_rel(&mainboard.traj, -180);
err = wait_traj_end(END_INTR|END_TRAJ);
if (err == END_INTR)
goto intr;
- trajectory_d_rel(&mainboard.traj, 300);
- err = wait_traj_end(END_INTR|END_TRAJ|END_BLOCKING);
+ err = strat_calib(300, END_INTR|END_TRAJ|END_BLOCKING);
if (err == END_INTR)
goto intr;
- wait_ms(100);
strat_reset_pos(ROBOT_HALF_LENGTH_FRONT,
DO_NOT_SET_POS,
180);
+ strat_hardstop();
trajectory_d_rel(&mainboard.traj, -170);
err = wait_traj_end(END_INTR|END_TRAJ);
/**********************************************************/
/* 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,
},
};
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";
#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";
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";