summaryrefslogtreecommitdiffhomepage
path: root/digital
diff options
context:
space:
mode:
authorFlorent Duchon2013-03-28 22:14:27 +0100
committerFlorent Duchon2013-03-28 23:07:25 +0100
commit894e8307503e67088b114cbbe644f58c7c2aa089 (patch)
tree2f31bb35215a6462fc5289c60578bee9ae998a54 /digital
parentba29df64d09042c2b0d6c2c8b896c6fb9bdf3262 (diff)
digital/beacon: rework of opponents and apb robot structures
Diffstat (limited to 'digital')
-rw-r--r--digital/beacon/src/position.c42
-rw-r--r--digital/beacon/src/position.h18
-rw-r--r--digital/beacon/src/recovery.c2
-rw-r--r--digital/beacon/src/recovery.h2
-rw-r--r--digital/beacon/src/trust.c2
-rw-r--r--digital/beacon/src/update.c2
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
@@ -46,6 +46,13 @@ typedef enum{
} TOpponent_ID;
typedef enum{
+ POV_BEACON_1 = 1,
+ POV_BEACON_2,
+ POV_BEACON_3
+} TBeacon_ID;
+
+
+typedef enum{
X,
Y
} TCoord_type;
@@ -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)