Programme course fonctionnel Jour J Croisement non pris en charge (tourne en rond)
Fork of Programme_course_30Tr by
shield.cpp@5:7714a216c91d, 2017-03-24 (annotated)
- Committer:
- leandre
- Date:
- Fri Mar 24 09:29:12 2017 +0000
- Revision:
- 5:7714a216c91d
- Parent:
- 4:8b0215ec788f
Prog fonctionnel Jour J; Croisement ? r?gler
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Freescale_cup | 0:3ec7fc598e48 | 1 | #include "Mlib.h" |
Freescale_cup | 0:3ec7fc598e48 | 2 | |
Freescale_cup | 0:3ec7fc598e48 | 3 | /***************SHIELD*****************/ |
Freescale_cup | 0:3ec7fc598e48 | 4 | |
Freescale_cup | 0:3ec7fc598e48 | 5 | |
Freescale_cup | 0:3ec7fc598e48 | 6 | void moteurs_arriere() |
Freescale_cup | 0:3ec7fc598e48 | 7 | { |
Freescale_cup | 0:3ec7fc598e48 | 8 | vitesse_virage = new_bari/2; |
Freescale_cup | 0:3ec7fc598e48 | 9 | |
leandre | 5:7714a216c91d | 10 | ajust_vitesse = ajust_vit_bosse +((ligne_droite*5)/2)-ajust_vit_vir; |
leandre | 4:8b0215ec788f | 11 | |
leandre | 4:8b0215ec788f | 12 | pc.printf("%hi\n", ajust_vit_bosse); |
leandre | 4:8b0215ec788f | 13 | |
leandre | 4:8b0215ec788f | 14 | if(bosse==1) {PWM_motor(90,90);} // acceleration à diminuer pour la competition |
leandre | 4:8b0215ec788f | 15 | else if(bosse==3) {PWM_motor(30,30);} |
leandre | 4:8b0215ec788f | 16 | else if(VIT == 0) |
Freescale_cup | 0:3ec7fc598e48 | 17 | { |
Freescale_cup | 0:3ec7fc598e48 | 18 | PWM_motor(0,0); |
Freescale_cup | 0:3ec7fc598e48 | 19 | } |
Freescale_cup | 0:3ec7fc598e48 | 20 | else if(ralentire == 1) |
Freescale_cup | 0:3ec7fc598e48 | 21 | { |
Freescale_cup | 0:3ec7fc598e48 | 22 | if(vitesse_virage > 0) |
Freescale_cup | 0:3ec7fc598e48 | 23 | { |
Freescale_cup | 0:3ec7fc598e48 | 24 | PWM_motor((VIT+ajust_vitesse) - vitesse_virage,(VIT)+ 4*vitesse_virage); |
Freescale_cup | 0:3ec7fc598e48 | 25 | } |
Freescale_cup | 0:3ec7fc598e48 | 26 | else |
Freescale_cup | 0:3ec7fc598e48 | 27 | { |
Freescale_cup | 0:3ec7fc598e48 | 28 | PWM_motor((VIT)- 4*vitesse_virage, (VIT+ajust_vitesse) + vitesse_virage); |
Freescale_cup | 0:3ec7fc598e48 | 29 | } |
Freescale_cup | 0:3ec7fc598e48 | 30 | } |
Freescale_cup | 0:3ec7fc598e48 | 31 | else |
Freescale_cup | 0:3ec7fc598e48 | 32 | { |
Freescale_cup | 0:3ec7fc598e48 | 33 | if(vitesse_virage > 0) |
Freescale_cup | 0:3ec7fc598e48 | 34 | { |
Freescale_cup | 0:3ec7fc598e48 | 35 | PWM_motor((VIT) - vitesse_virage, (VIT) + vitesse_virage); |
Freescale_cup | 0:3ec7fc598e48 | 36 | } |
Freescale_cup | 0:3ec7fc598e48 | 37 | else |
Freescale_cup | 0:3ec7fc598e48 | 38 | { |
Freescale_cup | 0:3ec7fc598e48 | 39 | PWM_motor((VIT)- vitesse_virage, (VIT) + vitesse_virage); |
Freescale_cup | 0:3ec7fc598e48 | 40 | } |
Freescale_cup | 0:3ec7fc598e48 | 41 | } |
Freescale_cup | 0:3ec7fc598e48 | 42 | |
Freescale_cup | 0:3ec7fc598e48 | 43 | } |
Freescale_cup | 0:3ec7fc598e48 | 44 | |
Freescale_cup | 0:3ec7fc598e48 | 45 | void test_servo(int time) |
Freescale_cup | 0:3ec7fc598e48 | 46 | { |
Freescale_cup | 0:3ec7fc598e48 | 47 | Timer debut_fct; |
Freescale_cup | 0:3ec7fc598e48 | 48 | debut_fct.start(); |
Freescale_cup | 0:3ec7fc598e48 | 49 | while(debut_fct.read() < time) |
Freescale_cup | 0:3ec7fc598e48 | 50 | { |
Freescale_cup | 0:3ec7fc598e48 | 51 | for(int i = -30; i < 30; i++) |
Freescale_cup | 0:3ec7fc598e48 | 52 | { |
Freescale_cup | 0:3ec7fc598e48 | 53 | angle_servo_moteur(i); |
Freescale_cup | 0:3ec7fc598e48 | 54 | wait(0.01); |
Freescale_cup | 0:3ec7fc598e48 | 55 | } |
Freescale_cup | 0:3ec7fc598e48 | 56 | for(int i = 30; i > -30; i--) |
Freescale_cup | 0:3ec7fc598e48 | 57 | { |
Freescale_cup | 0:3ec7fc598e48 | 58 | angle_servo_moteur(i); |
Freescale_cup | 0:3ec7fc598e48 | 59 | wait(0.01); |
Freescale_cup | 0:3ec7fc598e48 | 60 | } |
Freescale_cup | 0:3ec7fc598e48 | 61 | } |
Freescale_cup | 0:3ec7fc598e48 | 62 | angle_servo_moteur(0); |
Freescale_cup | 0:3ec7fc598e48 | 63 | } |
Freescale_cup | 0:3ec7fc598e48 | 64 | |
Freescale_cup | 0:3ec7fc598e48 | 65 | void Get_pot_value() |
Freescale_cup | 0:3ec7fc598e48 | 66 | { |
Freescale_cup | 0:3ec7fc598e48 | 67 | VIT = 0, KP = 0; |
Freescale_cup | 0:3ec7fc598e48 | 68 | for(int i = 0; i < 10; i++) |
Freescale_cup | 0:3ec7fc598e48 | 69 | { |
Freescale_cup | 0:3ec7fc598e48 | 70 | VIT += ((pot1.read()+1)*(25.0)); |
leandre | 5:7714a216c91d | 71 | KP += ((pot2.read()+1)*75); |
Freescale_cup | 0:3ec7fc598e48 | 72 | } |
Freescale_cup | 0:3ec7fc598e48 | 73 | VIT /= 10; |
leandre | 1:000a03402c6e | 74 | pc.printf("VIT=%d\nKP=%d\n",VIT,KP); //ici |
Freescale_cup | 0:3ec7fc598e48 | 75 | } |