Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp@12:7ec2c5b674a2, 2019-05-28 (annotated)
- Committer:
- theolp
- Date:
- Tue May 28 06:50:44 2019 +0000
- Revision:
- 12:7ec2c5b674a2
- Parent:
- 11:e8c4a1c6553d
Test Stop asservissement + dbug position
Who changed what in which revision?
User | Revision | Line number | New 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 | 10:efa507ba2b35 | 5 | /*//Bonus fin de partie |
Wael_H | 10:efa507ba2b35 | 6 | PwmOut bonus(PA_10); |
Wael_H | 8:94ecfe411d02 | 7 | |
Wael_H | 10:efa507ba2b35 | 8 | //Disquette |
Wael_H | 10:efa507ba2b35 | 9 | PwmOut Servo_Ballon(PB_7); |
Wael_H | 10:efa507ba2b35 | 10 | PwmOut Mot_Ballon(PB_6);*/ |
Wael_H | 10:efa507ba2b35 | 11 | |
Wael_H | 10:efa507ba2b35 | 12 | |
Wael_H | 10:efa507ba2b35 | 13 | void automate_test(Robot& R); |
Wael_H | 10:efa507ba2b35 | 14 | |
Wael_H | 8:94ecfe411d02 | 15 | |
Wael_H | 2:8971078b1ccf | 16 | int main(void) |
Wael_H | 2:8971078b1ccf | 17 | { |
Wael_H | 10:efa507ba2b35 | 18 | Robot robot; |
Wael_H | 7:753e901d441b | 19 | |
theolp | 12:7ec2c5b674a2 | 20 | int pos[3]; |
theolp | 12:7ec2c5b674a2 | 21 | |
theolp | 12:7ec2c5b674a2 | 22 | //Pour cadencer la fréquence d'envoi de messages vers le module bluetooth |
theolp | 12:7ec2c5b674a2 | 23 | Timer timer_dbug; |
theolp | 12:7ec2c5b674a2 | 24 | timer_dbug.start(); |
theolp | 12:7ec2c5b674a2 | 25 | |
theolp | 12:7ec2c5b674a2 | 26 | robot.gobe(30); |
theolp | 11:e8c4a1c6553d | 27 | |
Wael_H | 9:2113adf37c66 | 28 | while(1) |
theolp | 11:e8c4a1c6553d | 29 | { |
theolp | 12:7ec2c5b674a2 | 30 | //Maj de la position du robot |
theolp | 12:7ec2c5b674a2 | 31 | robot.getPos(pos); |
theolp | 12:7ec2c5b674a2 | 32 | //Led s'allume sur la carte si le robot a une balle |
theolp | 11:e8c4a1c6553d | 33 | robot.LedBps = robot.aBalle(); |
theolp | 12:7ec2c5b674a2 | 34 | |
theolp | 12:7ec2c5b674a2 | 35 | if(timer_dbug.read() > 1.f){ |
theolp | 12:7ec2c5b674a2 | 36 | dbug.printf("posX : %d\n\r", pos[0]); |
theolp | 12:7ec2c5b674a2 | 37 | dbug.printf("posY : %d\n\r", pos[1]); |
theolp | 12:7ec2c5b674a2 | 38 | dbug.printf("Angle : %d\n\r", pos[2]); |
theolp | 12:7ec2c5b674a2 | 39 | sauter_lignes(24); |
theolp | 12:7ec2c5b674a2 | 40 | |
theolp | 12:7ec2c5b674a2 | 41 | timer_dbug.stop(); timer_dbug.reset(); timer_debug.start(); |
theolp | 12:7ec2c5b674a2 | 42 | } |
theolp | 12:7ec2c5b674a2 | 43 | |
theolp | 12:7ec2c5b674a2 | 44 | //Automate |
Wael_H | 9:2113adf37c66 | 45 | automate_test(robot); |
theolp | 11:e8c4a1c6553d | 46 | } |
Wael_H | 7:753e901d441b | 47 | } |
Wael_H | 7:753e901d441b | 48 | |
Wael_H | 10:efa507ba2b35 | 49 | |
theolp | 11:e8c4a1c6553d | 50 | void automate_test(Robot& robot) |
Wael_H | 7:753e901d441b | 51 | { |
theolp | 12:7ec2c5b674a2 | 52 | typedef enum {DEBUT, ATTENTE_BALLE, TOURNE, EJECTE} type_etat; |
theolp | 12:7ec2c5b674a2 | 53 | static type_etat etat = DEBUT; |
Wael_H | 7:753e901d441b | 54 | |
Wael_H | 7:753e901d441b | 55 | switch(etat) |
Wael_H | 9:2113adf37c66 | 56 | { |
theolp | 11:e8c4a1c6553d | 57 | case DEBUT: |
theolp | 12:7ec2c5b674a2 | 58 | robot.avance(300); |
theolp | 12:7ec2c5b674a2 | 59 | etat = ATTENTE_BALLE; |
theolp | 12:7ec2c5b674a2 | 60 | break; |
theolp | 12:7ec2c5b674a2 | 61 | |
theolp | 12:7ec2c5b674a2 | 62 | case ATTENTE_BALLE: |
theolp | 11:e8c4a1c6553d | 63 | if(robot.aBalle()){ |
theolp | 12:7ec2c5b674a2 | 64 | SendRawId(ASSERVISSEMENT_STOP); |
theolp | 12:7ec2c5b674a2 | 65 | etat = TOURNE; |
theolp | 11:e8c4a1c6553d | 66 | } |
Wael_H | 8:94ecfe411d02 | 67 | break; |
Wael_H | 8:94ecfe411d02 | 68 | |
theolp | 12:7ec2c5b674a2 | 69 | case TOURNE: |
theolp | 12:7ec2c5b674a2 | 70 | if(robot.tourne(1800)) |
theolp | 11:e8c4a1c6553d | 71 | etat = EJECTE; |
theolp | 11:e8c4a1c6553d | 72 | break; |
theolp | 11:e8c4a1c6553d | 73 | |
theolp | 11:e8c4a1c6553d | 74 | case EJECTE: |
theolp | 12:7ec2c5b674a2 | 75 | robot.ejecte(60); |
theolp | 11:e8c4a1c6553d | 76 | etat = DEBUT; |
Wael_H | 8:94ecfe411d02 | 77 | break; |
Wael_H | 7:753e901d441b | 78 | } |
Wael_H | 2:8971078b1ccf | 79 | } |