Romain Ame
/
Timer71pt
Fork de Timer après le match à 61 points
Fork of Timer by
main.cpp@2:abdf8c6823a1, 2015-11-24 (annotated)
- Committer:
- sype
- Date:
- Tue Nov 24 15:02:01 2015 +0000
- Revision:
- 2:abdf8c6823a1
- Parent:
- 0:ad9600df4a70
- Child:
- 3:62e9d715de65
gotothet
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 | |
sype | 0:ad9600df4a70 | 16 | int main(void) |
sype | 2:abdf8c6823a1 | 17 | { |
sype | 2:abdf8c6823a1 | 18 | init(); |
sype | 2:abdf8c6823a1 | 19 | odo.GotoXYT(1000,300,0); |
sype | 2:abdf8c6823a1 | 20 | while(1); |
sype | 2:abdf8c6823a1 | 21 | } |
sype | 2:abdf8c6823a1 | 22 | |
sype | 2:abdf8c6823a1 | 23 | void init(void) |
sype | 0:ad9600df4a70 | 24 | { |
sype | 2:abdf8c6823a1 | 25 | pc.baud(115200); |
sype | 2:abdf8c6823a1 | 26 | pc.printf("Hello from main !\n\r"); |
sype | 2:abdf8c6823a1 | 27 | roboclaw.ForwardM1(ADR, 0); |
sype | 2:abdf8c6823a1 | 28 | roboclaw.ForwardM2(ADR, 0); |
sype | 2:abdf8c6823a1 | 29 | wait_ms(500); |
sype | 2:abdf8c6823a1 | 30 | roboclaw.ResetEnc(ADR); |
sype | 2:abdf8c6823a1 | 31 | odo.setPos(100, 1000, -PI/2); |
sype | 0:ad9600df4a70 | 32 | ticker.attach_us(&update_main,dt); // 100 Hz |
sype | 0:ad9600df4a70 | 33 | } |
sype | 0:ad9600df4a70 | 34 | |
sype | 0:ad9600df4a70 | 35 | void update_main(void) |
sype | 0:ad9600df4a70 | 36 | { |
sype | 0:ad9600df4a70 | 37 | odo.update_odo(); |
sype | 2:abdf8c6823a1 | 38 | //pc.printf("EncM1 : %6d\tEncM2 : %6d\tTheta : %3.2f\n\r", roboclaw.ReadEncM1(ADR), roboclaw.ReadEncM2(ADR), odo.getTheta()*180/PI); |
sype | 2:abdf8c6823a1 | 39 | //if(pc.readable()) if(pc.getc()=='l') led = !led; |
sype | 0:ad9600df4a70 | 40 | } |