From 894e8307503e67088b114cbbe644f58c7c2aa089 Mon Sep 17 00:00:00 2001 From: Florent Duchon Date: Thu, 28 Mar 2013 22:14:27 +0100 Subject: digital/beacon: rework of opponents and apb robot structures --- digital/beacon/src/position.c | 42 ++++++++---------------------------------- digital/beacon/src/position.h | 18 +++++++++--------- digital/beacon/src/recovery.c | 2 +- digital/beacon/src/recovery.h | 2 +- digital/beacon/src/trust.c | 2 +- digital/beacon/src/update.c | 2 +- 6 files changed, 21 insertions(+), 47 deletions(-) diff --git a/digital/beacon/src/position.c b/digital/beacon/src/position.c index 1966513e..67a0ba36 100644 --- a/digital/beacon/src/position.c +++ b/digital/beacon/src/position.c @@ -34,8 +34,8 @@ #include "misc.h" beacon_s beacon[MAX_BEACON+1]; -opponent_s opponent[MAX_OBSTACLE+1]; -apb_s apb_pos; +robot_s opponent[MAX_OBSTACLE+1]; +robot_s my_robot; /* This function is used to initialize all needed structures */ void position_init_struct(void) @@ -58,11 +58,11 @@ void position_init_struct(void) opponent[i].trust = 100; } - apb_pos.x = 0; - apb_pos.y = 0; - apb_pos.angle[1] = 0; - apb_pos.angle[2] = 0; - apb_pos.angle[3] = 0; + my_robot.x = 0; + my_robot.y = 0; + my_robot.angle[POV_BEACON_1] = 0; + my_robot.angle[POV_BEACON_2] = 0; + my_robot.angle[POV_BEACON_3] = 0; } /* This function update the opponent position when a new angle is avalaible */ @@ -207,30 +207,4 @@ int16_t position_get_coord(TOpponent_ID id, TCoord_type type) int8_t position_get_trust(TOpponent_ID id) { return opponent[id].trust; -} - -void formula_update_apb_position(uint16_t x,uint16_t y) -{ - if(color_get_value() == COLOR_RIGHT) - { - apb_pos.x = LONGUEUR_TABLE - x; - apb_pos.y = LARGEUR_TABLE - y; - } - else - { - apb_pos.x = x; - apb_pos.y = y; - } - - apb_pos.angle[1] = atan(apb_pos.x / (LARGEUR_TABLE - apb_pos.y)); - apb_pos.angle[2] = atan(apb_pos.x/apb_pos.y); - - if(y <= LARGEUR_DEMI_TABLE) - { - apb_pos.angle[3] = atan((LONGUEUR_TABLE - apb_pos.x) / (LARGEUR_DEMI_TABLE - apb_pos.y)); - } - else - { - apb_pos.angle[3] = M_PI/2 + atan((apb_pos.y - LARGEUR_DEMI_TABLE) / (LONGUEUR_TABLE-apb_pos.x)); - } -} +} \ No newline at end of file diff --git a/digital/beacon/src/position.h b/digital/beacon/src/position.h index dec4f1f9..d8a6d011 100644 --- a/digital/beacon/src/position.h +++ b/digital/beacon/src/position.h @@ -45,6 +45,13 @@ typedef enum{ OPPONENT_2 } TOpponent_ID; +typedef enum{ + POV_BEACON_1 = 1, + POV_BEACON_2, + POV_BEACON_3 +} TBeacon_ID; + + typedef enum{ X, Y @@ -59,21 +66,14 @@ typedef struct float angle[MAX_OBSTACLE+1]; }beacon_s; -/* Obstacle structure */ +/* Robot structure */ typedef struct { int16_t x; int16_t y; int8_t trust; -}opponent_s; - -/* Obstacle structure */ -typedef struct -{ - int16_t x; - int16_t y; float angle[MAX_BEACON+1]; -}apb_s; +}robot_s; /* Coordinates structure */ diff --git a/digital/beacon/src/recovery.c b/digital/beacon/src/recovery.c index 891e35ed..ddb89322 100644 --- a/digital/beacon/src/recovery.c +++ b/digital/beacon/src/recovery.c @@ -30,7 +30,7 @@ #include "debug_simu.h" /* This function is used to calculate all obstacle positions from sractch */ -TRecoveryStatus recovery(coord_s * new_point,opponent_s opp[MAX_OBSTACLE]) +TRecoveryStatus recovery(coord_s * new_point,robot_s opp[MAX_OBSTACLE]) { /* Declare variables */ int i = 0; diff --git a/digital/beacon/src/recovery.h b/digital/beacon/src/recovery.h index a50310d1..525ef957 100644 --- a/digital/beacon/src/recovery.h +++ b/digital/beacon/src/recovery.h @@ -40,6 +40,6 @@ typedef enum } TRecoveryStatus; /* This function is used to calculate all obstacle positions from sractch */ -TRecoveryStatus recovery(coord_s * new_point,opponent_s result[MAX_OBSTACLE]); +TRecoveryStatus recovery(coord_s * new_point,robot_s result[MAX_OBSTACLE]); #endif diff --git a/digital/beacon/src/trust.c b/digital/beacon/src/trust.c index 936d0138..d81246d8 100644 --- a/digital/beacon/src/trust.c +++ b/digital/beacon/src/trust.c @@ -28,7 +28,7 @@ #include "debug_simu.h" #include "print.h" -extern opponent_s opponent[MAX_OBSTACLE]; +extern robot_s opponent[MAX_OBSTACLE]; static HAL_AppTimer_t trustTimer; diff --git a/digital/beacon/src/update.c b/digital/beacon/src/update.c index 9b987b77..570d0407 100644 --- a/digital/beacon/src/update.c +++ b/digital/beacon/src/update.c @@ -30,7 +30,7 @@ #include "print.h" /* Globals Declaration */ -extern opponent_s opponent[MAX_OBSTACLE]; +extern robot_s opponent[MAX_OBSTACLE]; /* This function checks is the given coord is a potential obstacle and updates the structure in consequence */ TUpdateStatus update(coord_s * point) -- cgit v1.2.3