![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Test code 29-10-2019
Dependencies: mbed RC_Servo VMA306 PID CNY70 CMPS03 GP2A Pixy
main.cpp@9:4053b5217339, 2019-10-24 (annotated)
- Committer:
- tuk4
- Date:
- Thu Oct 24 14:21:22 2019 +0000
- Revision:
- 9:4053b5217339
- Parent:
- 8:2d4887624f94
- Child:
- 10:6c3653c53eca
on progress 24-10-2019
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
haarkon | 0:4902b3f17137 | 1 | #include "mbed.h" |
haarkon | 0:4902b3f17137 | 2 | #include "CMPS03.h" |
haarkon | 0:4902b3f17137 | 3 | #include "CNY70.h" |
haarkon | 0:4902b3f17137 | 4 | #include "GP2A.h" |
haarkon | 0:4902b3f17137 | 5 | #include "VMA306.h" |
haarkon | 3:0221daeeaa86 | 6 | #include "Pixy.h" |
haarkon | 4:5038b4cd1088 | 7 | #include "PID.h" |
haarkon | 4:5038b4cd1088 | 8 | |
haarkon | 4:5038b4cd1088 | 9 | #define PI 3.1415926535898 |
haarkon | 0:4902b3f17137 | 10 | |
haarkon | 8:2d4887624f94 | 11 | Serial pc (PA_2, PA_3, 115200); |
haarkon | 7:6d58adc26b78 | 12 | PID motor (TIM4, TIM3, PA_9, PA_8, PC_9, PC_8, PC_6, PC_5); |
haarkon | 0:4902b3f17137 | 13 | |
haarkon | 3:0221daeeaa86 | 14 | CMPS03 boussole (PC_4); |
haarkon | 0:4902b3f17137 | 15 | |
haarkon | 3:0221daeeaa86 | 16 | CNY70 ligneD (PC_3); |
haarkon | 3:0221daeeaa86 | 17 | CNY70 ligneG (PC_2); |
haarkon | 3:0221daeeaa86 | 18 | CNY70 exterior (PA_7); |
haarkon | 0:4902b3f17137 | 19 | |
haarkon | 8:2d4887624f94 | 20 | VMA306 ultraSon (PB_15, PA_6, PB_14, PC_7, PB_13, PB_2); |
haarkon | 0:4902b3f17137 | 21 | |
haarkon | 8:2d4887624f94 | 22 | PIXY pixy (PA_0, PA_1, 115200); |
haarkon | 0:4902b3f17137 | 23 | |
haarkon | 8:2d4887624f94 | 24 | InterruptIn bp (PC_13); |
haarkon | 4:5038b4cd1088 | 25 | |
haarkon | 0:4902b3f17137 | 26 | DigitalOut led1 (PA_5); |
haarkon | 0:4902b3f17137 | 27 | DigitalOut led2 (PD_2); |
haarkon | 8:2d4887624f94 | 28 | DigitalOut unused1 (PB_10); |
haarkon | 8:2d4887624f94 | 29 | DigitalOut unused2 (PA_15); |
haarkon | 8:2d4887624f94 | 30 | DigitalOut unused3 (PA_12); |
haarkon | 8:2d4887624f94 | 31 | |
haarkon | 8:2d4887624f94 | 32 | DigitalIn unused4 (PA_4, PullUp); |
haarkon | 8:2d4887624f94 | 33 | DigitalIn unused5 (PB_0, PullUp); |
haarkon | 8:2d4887624f94 | 34 | DigitalIn unused6 (PC_1, PullUp); |
haarkon | 8:2d4887624f94 | 35 | DigitalIn unused7 (PC_0, PullUp); |
haarkon | 8:2d4887624f94 | 36 | |
haarkon | 8:2d4887624f94 | 37 | Timer temps; |
haarkon | 0:4902b3f17137 | 38 | |
tuk4 | 9:4053b5217339 | 39 | int main () |
haarkon | 3:0221daeeaa86 | 40 | { |
tuk4 | 9:4053b5217339 | 41 | motor.resetPosition(); |
tuk4 | 9:4053b5217339 | 42 | double x=0, y, theta = 0; |
haarkon | 3:0221daeeaa86 | 43 | |
haarkon | 3:0221daeeaa86 | 44 | while (1) { |
tuk4 | 9:4053b5217339 | 45 | double speed_L = 50, speed_R = 50; |
tuk4 | 9:4053b5217339 | 46 | while (x <= 200) |
tuk4 | 9:4053b5217339 | 47 | { |
tuk4 | 9:4053b5217339 | 48 | motor.setSpeed(speed_L,speed_R); |
tuk4 | 9:4053b5217339 | 49 | motor.getPosition(&x, &y, &theta); |
tuk4 | 9:4053b5217339 | 50 | pc.printf("\r x = %lf", x); |
tuk4 | 9:4053b5217339 | 51 | } |
tuk4 | 9:4053b5217339 | 52 | motor.setSpeed(0,0); |
haarkon | 3:0221daeeaa86 | 53 | } |
tuk4 | 9:4053b5217339 | 54 | |
tuk4 | 9:4053b5217339 | 55 | return 0; |
haarkon | 0:4902b3f17137 | 56 | } |