FRC_equipe1 / Mbed 2 deprecated FRC_2019

Dependencies:   mbed

Committer:
theolp
Date:
Wed Jun 05 14:45:45 2019 +0000
Revision:
20:a1b5d032b422
Parent:
19:dad67302af25
Child:
22:f18eee9c8714
Child:
23:bb1535360a98
nouvelle version classe Robot

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Wael_H 2:8971078b1ccf 1 #include "mbed.h"
Wael_H 5:34048faec367 2 #include "CAN_asser.h"
Wael_H 10:efa507ba2b35 3 #include "Robot.h"
Wael_H 10:efa507ba2b35 4
Wael_H 16:05665faaa489 5 void automate_testDeplacement(Robot&);
Wael_H 8:94ecfe411d02 6
Wael_H 2:8971078b1ccf 7 int main(void)
Wael_H 2:8971078b1ccf 8 {
Wael_H 10:efa507ba2b35 9 Robot robot;
theolp 17:aae5361ddddf 10
theolp 17:aae5361ddddf 11 robot.setSpeed(40,400);
theolp 17:aae5361ddddf 12
theolp 17:aae5361ddddf 13 Timer timer_dbug;
theolp 17:aae5361ddddf 14 timer_dbug.start();
Wael_H 15:3d4543a6c100 15
theolp 20:a1b5d032b422 16 AnalogIn cny_g(A2);
theolp 20:a1b5d032b422 17 AnalogIn cny_d(A3);
theolp 20:a1b5d032b422 18
Wael_H 15:3d4543a6c100 19 while(1)
theolp 17:aae5361ddddf 20 {
theolp 20:a1b5d032b422 21 //automate_testDeplacement(robot);
theolp 17:aae5361ddddf 22
theolp 17:aae5361ddddf 23 if(timer_dbug.read() > 0.5f)
theolp 17:aae5361ddddf 24 {
theolp 20:a1b5d032b422 25 dbug.printf( "CNY Gauche : %f\n\r", cny_g.read() );
theolp 20:a1b5d032b422 26 dbug.printf( "CNY Droit : %f\n\r", cny_d.read() );
theolp 20:a1b5d032b422 27 sauter_lignes(20);
theolp 17:aae5361ddddf 28 timer_dbug.stop();
theolp 17:aae5361ddddf 29 timer_dbug.reset();
theolp 17:aae5361ddddf 30 timer_dbug.start();
theolp 17:aae5361ddddf 31 }
theolp 17:aae5361ddddf 32 }
Wael_H 15:3d4543a6c100 33 }
Wael_H 15:3d4543a6c100 34
Wael_H 16:05665faaa489 35 void automate_testDeplacement(Robot& robot)
Wael_H 15:3d4543a6c100 36 {
theolp 17:aae5361ddddf 37 typedef enum{AVANCE,TOURNE} type_etat;
Wael_H 16:05665faaa489 38 static type_etat etat = AVANCE;
Wael_H 7:753e901d441b 39
Wael_H 7:753e901d441b 40 switch(etat)
Wael_H 9:2113adf37c66 41 {
Wael_H 16:05665faaa489 42 case AVANCE:
theolp 17:aae5361ddddf 43 if(robot.avance(500))
Wael_H 16:05665faaa489 44 etat = TOURNE;
Wael_H 13:9c62e263f245 45 break;
Wael_H 13:9c62e263f245 46
Wael_H 16:05665faaa489 47 case TOURNE:
theolp 17:aae5361ddddf 48 if(robot.tourne(900))
theolp 17:aae5361ddddf 49 etat = AVANCE;
Wael_H 13:9c62e263f245 50 break;
Wael_H 13:9c62e263f245 51 }
Wael_H 13:9c62e263f245 52 }
Wael_H 16:05665faaa489 53