ARES
/
Timer
Time is good
Fork of Robot2016_2-0 by
main.cpp@9:e39b218ab20d, 2015-11-24 (annotated)
- Committer:
- IceTeam
- Date:
- Tue Nov 24 23:05:12 2015 +0000
- Revision:
- 9:e39b218ab20d
- Parent:
- 3:62e9d715de65
- Child:
- 10:ae3178aa94e9
Test de r?solution de bug pour la g?n?ration de doc
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sype | 0:ad9600df4a70 | 1 | #include "Odometry.h" |
sype | 0:ad9600df4a70 | 2 | |
sype | 0:ad9600df4a70 | 3 | #define dt 10000 |
sype | 0:ad9600df4a70 | 4 | |
sype | 2:abdf8c6823a1 | 5 | InterruptIn button(USER_BUTTON); |
sype | 2:abdf8c6823a1 | 6 | DigitalOut led(LED1); |
sype | 0:ad9600df4a70 | 7 | Ticker ticker; |
sype | 2:abdf8c6823a1 | 8 | Serial pc(USBTX, USBRX); |
sype | 0:ad9600df4a70 | 9 | //Serial pc(PA_9, PA_10); |
sype | 2:abdf8c6823a1 | 10 | RoboClaw roboclaw(115200, PA_11, PA_12); |
sype | 2:abdf8c6823a1 | 11 | Odometry odo(47.4, 47.1, 242.0, roboclaw); |
sype | 0:ad9600df4a70 | 12 | |
sype | 0:ad9600df4a70 | 13 | void update_main(void); |
sype | 2:abdf8c6823a1 | 14 | void init(void); |
sype | 0:ad9600df4a70 | 15 | |
IceTeam | 9:e39b218ab20d | 16 | /** Debut du programme */ |
sype | 0:ad9600df4a70 | 17 | int main(void) |
sype | 2:abdf8c6823a1 | 18 | { |
sype | 2:abdf8c6823a1 | 19 | init(); |
sype | 3:62e9d715de65 | 20 | odo.GotoXYT(2250,500,0); |
sype | 2:abdf8c6823a1 | 21 | while(1); |
sype | 2:abdf8c6823a1 | 22 | } |
sype | 2:abdf8c6823a1 | 23 | |
sype | 2:abdf8c6823a1 | 24 | void init(void) |
sype | 0:ad9600df4a70 | 25 | { |
sype | 2:abdf8c6823a1 | 26 | pc.baud(115200); |
sype | 2:abdf8c6823a1 | 27 | pc.printf("Hello from main !\n\r"); |
sype | 2:abdf8c6823a1 | 28 | roboclaw.ForwardM1(ADR, 0); |
sype | 2:abdf8c6823a1 | 29 | roboclaw.ForwardM2(ADR, 0); |
sype | 2:abdf8c6823a1 | 30 | wait_ms(500); |
sype | 2:abdf8c6823a1 | 31 | roboclaw.ResetEnc(ADR); |
sype | 3:62e9d715de65 | 32 | odo.setPos(1500, 1000, 2*PI/3); |
sype | 0:ad9600df4a70 | 33 | ticker.attach_us(&update_main,dt); // 100 Hz |
sype | 0:ad9600df4a70 | 34 | } |
sype | 0:ad9600df4a70 | 35 | |
sype | 0:ad9600df4a70 | 36 | void update_main(void) |
sype | 0:ad9600df4a70 | 37 | { |
sype | 0:ad9600df4a70 | 38 | odo.update_odo(); |
sype | 2:abdf8c6823a1 | 39 | //pc.printf("EncM1 : %6d\tEncM2 : %6d\tTheta : %3.2f\n\r", roboclaw.ReadEncM1(ADR), roboclaw.ReadEncM2(ADR), odo.getTheta()*180/PI); |
sype | 2:abdf8c6823a1 | 40 | //if(pc.readable()) if(pc.getc()=='l') led = !led; |
sype | 0:ad9600df4a70 | 41 | } |