SmartWheels self-driving race car. Designed for NXP Cup. Uses FRDM-KL25Z, area-scan camera, and simple image processing to detect and navigate any NXP spec track.

Dependencies:   TSI USBDevice mbed-dev

Fork of SmartWheels by haofan Zheng

Committer:
Bobymicjohn
Date:
Tue Feb 07 21:58:20 2017 +0000
Revision:
11:676ea42afd56
Parent:
10:fedb5786a109
Child:
13:7dcb1642ef99
Finished Core, and Servo classes.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hazheng 3:c8867972ffc7 1 #include "mbed.h"
hazheng 5:577b582e4fe9 2
Bobymicjohn 8:92f6baeea027 3 #include "Motor.h"
Bobymicjohn 11:676ea42afd56 4 #include "Servo.h"
Bobymicjohn 11:676ea42afd56 5 #include "Core.h"
Bobymicjohn 11:676ea42afd56 6 #include "SWUSBServer.h"
Bobymicjohn 10:fedb5786a109 7
Bobymicjohn 10:fedb5786a109 8 #include "PinAssignment.h"
Bobymicjohn 8:92f6baeea027 9
Bobymicjohn 11:676ea42afd56 10 //DigitalOut led(LED1, 1);
hazheng 5:577b582e4fe9 11
hazheng 3:c8867972ffc7 12 int main(void) {
Bobymicjohn 11:676ea42afd56 13
hazheng 5:577b582e4fe9 14 //Camera cam;
Bobymicjohn 11:676ea42afd56 15 SW::Core core;
Bobymicjohn 10:fedb5786a109 16
Bobymicjohn 11:676ea42afd56 17 Motor motor(core);
Bobymicjohn 11:676ea42afd56 18 Servo servo(core);
hazheng 6:0682e1c90119 19
hazheng 5:577b582e4fe9 20 unsigned int testCount = 0;
hazheng 5:577b582e4fe9 21 unsigned int testCount2 = 0;
hazheng 5:577b582e4fe9 22 char buf[5];
hazheng 3:c8867972ffc7 23
hazheng 5:577b582e4fe9 24 while (1)
hazheng 5:577b582e4fe9 25 {
Bobymicjohn 11:676ea42afd56 26 //led = 0;
Bobymicjohn 11:676ea42afd56 27 core.Update(0.0f);
Bobymicjohn 8:92f6baeea027 28 motor.Update(0.0f);
hazheng 5:577b582e4fe9 29 testCount++;
Bobymicjohn 11:676ea42afd56 30 if(testCount >= 200)
hazheng 5:577b582e4fe9 31 {
hazheng 5:577b582e4fe9 32 testCount2++;
hazheng 5:577b582e4fe9 33 sprintf(buf, "%d", testCount2);
Bobymicjohn 11:676ea42afd56 34 servo.setAngle(SERVO_RT * SERVO_MAX_ANGLE);
Bobymicjohn 11:676ea42afd56 35 //core.GetUSBServer().PushUnreliableMsg('D', buf);
hazheng 5:577b582e4fe9 36 testCount = 0;
hazheng 3:c8867972ffc7 37 }
hazheng 3:c8867972ffc7 38
Bobymicjohn 8:92f6baeea027 39 wait(0.01);
hazheng 3:c8867972ffc7 40 }
hazheng 3:c8867972ffc7 41 }
hazheng 3:c8867972ffc7 42
hazheng 3:c8867972ffc7 43 /*
hazheng 3:c8867972ffc7 44 PwmOut servo(PTE20);
hazheng 3:c8867972ffc7 45
hazheng 3:c8867972ffc7 46 int main() {
hazheng 3:c8867972ffc7 47 servo.period(0.020); // servo requires a 20ms period
hazheng 3:c8867972ffc7 48
hazheng 3:c8867972ffc7 49 while (1) {
hazheng 3:c8867972ffc7 50 for(float offset=0.0; offset<0.001; offset+=0.0001) {
hazheng 3:c8867972ffc7 51 servo.pulsewidth(0.001 + offset); // servo position determined by a pulsewidth between 1-2ms
hazheng 3:c8867972ffc7 52 wait(0.25);
hazheng 3:c8867972ffc7 53 }
hazheng 3:c8867972ffc7 54 }
hazheng 3:c8867972ffc7 55
hazheng 3:c8867972ffc7 56 }
hazheng 3:c8867972ffc7 57 */