Time is good

Dependencies:   RoboClaw mbed

Fork of Robot2016_2-0 by ARES

Files at this revision

API Documentation at this revision

Comitter:
sype
Date:
Thu Apr 28 08:11:25 2016 +0000
Parent:
46:5658af4e5149
Child:
49:5e2f7323f280
Commit message:
Int?gration de "l'algo" carte boutons, maintenant le bouton bleu (utilisateur) est remplac? par le jumper pr?sent sur la carte (on le retire pour d?marrer) et le changement de camp du robot se fait par le bouton pr?sent sur cette carte

Changed in this revision

Functions/func.cpp Show annotated file Show diff for this revision Revisions of this file
Functions/func.h Show annotated file Show diff for this revision Revisions of this file
Odometry/Odometry.h Show annotated file Show diff for this revision Revisions of this file
RoboClaw.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Functions/func.cpp	Mon Apr 25 12:38:58 2016 +0000
+++ b/Functions/func.cpp	Thu Apr 28 08:11:25 2016 +0000
@@ -115,7 +115,7 @@
     else rouge = 0;
 }
 
-void init_ax12(void)
+/*void init_ax12(void)
 {
     left_hand.setMode(0);
     wait_ms(10);
@@ -131,14 +131,12 @@
     right_hand.setGoal(180);
     left_hand.setGoal(180);
     wait(2);
-}
+}*/
 
 void init_interrupt(void)
 {
     CAMP.fall(&changeCamp);
-    CAMP.rise(&changeCampoff);
-    START.rise(&letsgo);
-    START.fall(&letsgooff);
+    START.rise(&go);
     mybutton.fall(&pressed);
     mybutton.rise(&unpressed);
     EndL.fall(&ELpressed);
@@ -147,24 +145,24 @@
     EndZ.rise(&EZunpressed);
     EndR.fall(&ERpressed);
     EndR.rise(&ERunpressed);
+    ticker.attach_us(&update_main, dt); // 100 Hz
 }
 
 void changeCamp(void)
 {
-    LEDV = 1;
-}
-
-void changeCampoff(void)
-{
-    LEDV = 0;
+    if(SCouleur==VERT) {
+        SCouleur = VIOLET;
+        LEDR = 1;
+        LEDV = 0;
+    }
+    else {
+        SCouleur = VERT;
+        LEDV = 1;
+        LEDR = 0;        
+    }
 }
 
-void letsgo(void)
+void go(void)
 {
-    LEDR = 0;
-}
-
-void letsgooff(void)
-{
-    LEDR = 1;
+    SStart = 1;
 }
\ No newline at end of file
--- a/Functions/func.h	Mon Apr 25 12:38:58 2016 +0000
+++ b/Functions/func.h	Thu Apr 28 08:11:25 2016 +0000
@@ -9,6 +9,13 @@
 #include "AX12.h"
 
 #define SEUIL 0.25
+#define VERT 1
+#define VIOLET 2
+#define ATTENTE 0
+#define GO 1
+#define STOP 2
+#define ADR 0x80
+#define dt 10000
 
 extern Serial logger;
 extern RoboClaw roboclaw;
@@ -25,21 +32,21 @@
 extern InterruptIn EndR;
 extern InterruptIn EndZ;
 extern InterruptIn EndL;
-extern AX12 left_hand;
-extern AX12 right_hand;
+//extern AX12 left_hand;
+//extern AX12 right_hand;
 extern Odometry odo;
+extern Ticker ticker;
 extern InterruptIn CAMP;
 extern InterruptIn START;
 extern DigitalOut LEDR;
 extern DigitalOut LEDV;
 
-extern int SIMON_i, SIMON_state;
+
+extern int SIMON_i, SIMON_state, SCouleur, SStart;
 extern bool SIMON_EL, SIMON_EZ, SIMON_ER;
 
 void changeCamp(void);
-void changeCampoff(void);
-void letsgo(void);
-void letsgooff(void);
+void go(void);
 void ELpressed(void);
 void ELunpressed(void);
 void EZpressed(void);
@@ -55,5 +62,6 @@
 void init_interrupt(void);
 void goHome(void);
 void checkAround(void);
+void update_main(void);
 
 #endif
\ No newline at end of file
--- a/Odometry/Odometry.h	Mon Apr 25 12:38:58 2016 +0000
+++ b/Odometry/Odometry.h	Thu Apr 28 08:11:25 2016 +0000
@@ -8,13 +8,13 @@
 #define C 1.0
 
 /* Vitesse d'acceleration d'angle reduite de 8000->4000 */
-#define accel_angle 8000
-#define vitesse_angle 12000
-#define deccel_angle 8000
+#define accel_angle 0x1000
+#define vitesse_angle 0x1000
+#define deccel_angle 0x1000
 
-#define accel_dista 12000
-#define vitesse_dista 20000
-#define deccel_dista 12000
+#define accel_dista 0x1000
+#define vitesse_dista 0x1000
+#define deccel_dista 0x1000
 
 /* Si le robot parcourt un trop grand angle, il diminuer l'entraxe, sinon l'augmenter */
 #define ENTRAXE 243.8
--- a/RoboClaw.lib	Mon Apr 25 12:38:58 2016 +0000
+++ b/RoboClaw.lib	Thu Apr 28 08:11:25 2016 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/teams/ARES/code/RoboClaw/#af0e3da221a9
+https://developer.mbed.org/teams/ARES/code/RoboClaw/#68669cccd769
--- a/main.cpp	Mon Apr 25 12:38:58 2016 +0000
+++ b/main.cpp	Thu Apr 28 08:11:25 2016 +0000
@@ -1,16 +1,9 @@
 #include "func.h"
 
-#define ATTENTE 0
-#define GO 1
-#define STOP 2
-#define ADR 0x80
-#define dt 10000
-
 /* Déclaration des différents éléments de l'IHM */
 
-/* Carte boutons, la NUCLEO n'arrive pas à récupérer les signaux CAMP et START */
-InterruptIn CAMP(PH_0);
-InterruptIn START(PH_1);
+InterruptIn CAMP(PA_15);
+InterruptIn START(PB_7);
 DigitalOut LEDR(PC_2);
 DigitalOut LEDV(PC_3);
 
@@ -27,8 +20,8 @@
 DigitalOut rouge(PC_8);
 
 /* AX12 - non fonctionnels, je pense que le souci vient de la bibliothèque car la trame n'est pas correcte (analyseur logique) */
-AX12 left_hand(PA_9, PA_10, 4, 250000);
-AX12 right_hand(PA_9, PA_10, 1, 250000);
+//AX12 left_hand(PA_9, PA_10, 4, 250000);
+//AX12 right_hand(PA_9, PA_10, 1, 250000);
 
 /* Sharp */
 AnalogIn capt1(PA_4);
@@ -48,11 +41,11 @@
 Ticker ticker;
 
 Serial logger(USBTX, USBRX);
-//Serial logger(PA_2, PA_3);
+//Serial logger(PA_9, PA_10);
 RoboClaw roboclaw(ADR, 460800, PA_11, PA_12);
 Odometry odo(61.7, 61.8, ENTRAXE, 4096, roboclaw);
 
-int SIMON_i = 0, SIMON_state = 0;
+int SIMON_i = 0, SIMON_state = 0, SCouleur = 1, SStart = 0;
 bool SIMON_EL = false, SIMON_EZ = false, SIMON_ER = false;
 
 void init(void);
@@ -62,27 +55,26 @@
 int main(void)
 {
     init();
-    while(1) JPO();
+    while(1);
 }
 
 void init(void)
 {
     logger.baud(9600);
-    logger.printf("Hello from main !\n\r");
+    logger.printf("Coucou!\n\r");
     roboclaw.ForwardM1(0);
     roboclaw.ForwardM2(0);
-    LEDV = 1;
-    while(button);
-    LEDV = 0;
+    while(SStart==0);
+    wait(1);
+    odo.setPos(110, 1000, 0);
     roboclaw.ResetEnc();
     init_interrupt();
-    ticker.attach_us(&update_main, dt); // 100 Hz    
     wait_ms(100);
     logger.printf("End init\n\r");
 }
 
 void update_main(void)
 {
-    odo.update_odo();
+    //odo.update_odo();
     //checkAround();
 }
\ No newline at end of file