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

Revision:
11:676ea42afd56
Parent:
10:fedb5786a109
Child:
13:7dcb1642ef99
--- a/main.cpp	Tue Feb 07 18:20:38 2017 +0000
+++ b/main.cpp	Tue Feb 07 21:58:20 2017 +0000
@@ -1,36 +1,21 @@
 #include "mbed.h"
 
 #include "Motor.h"
-
-#include "USBHIDServer.h"
+#include "Servo.h"
+#include "Core.h"
+#include "SWUSBServer.h"
 
 #include "PinAssignment.h"
- 
-PwmOut servo(ST_SERVO);
 
-DigitalOut led(LED1, 1);
+//DigitalOut led(LED1, 1);
 
 int main(void) {
-    servo.period(0.020);
-    servo.pulsewidth(0.00185);
+   
     //Camera cam;
-    
-    Motor motor;
-    motor.setLeftSpeed(0.5f);
-    motor.setRightSpeed(0.5f);
-    
-    wait(5);
+    SW::Core core;
     
-    servo.pulsewidth(0.0012);
-    motor.setLeftSpeed(0.5f);
-    motor.setRightSpeed(0.5f);
-    
-    wait(2);
-    
-    motor.setLeftSpeed(-0.0f);
-    motor.setRightSpeed(-0.0f);
-    
-    USBHIDServer server;
+    Motor motor(core);
+    Servo servo(core);
     
     unsigned int testCount = 0;
     unsigned int testCount2 = 0;
@@ -38,16 +23,16 @@
         
     while (1) 
     {
-        led = 0;
-        server.Update(0.0f);
+        //led = 0;
+        core.Update(0.0f);
         motor.Update(0.0f);
         testCount++;
-        if(testCount >= 10000)
+        if(testCount >= 200)
         {
             testCount2++;
             sprintf(buf, "%d", testCount2);
-            //server.PushUnreliableMsg('D', "Test Message!");
-            server.PushUnreliableMsg('D', buf);
+            servo.setAngle(SERVO_RT * SERVO_MAX_ANGLE);
+            //core.GetUSBServer().PushUnreliableMsg('D', buf);
             testCount = 0;
         }