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
main.cpp
- Committer:
- Bobymicjohn
- Date:
- 2017-02-09
- Revision:
- 14:88302da8bff0
- Parent:
- 13:7dcb1642ef99
- Child:
- 15:eb6a274b3dfb
File content as of revision 14:88302da8bff0:
#include "mbed.h" #include "Motor.h" #include "Servo.h" #include "Core.h" #include "SWUSBServer.h" #include "Camera.h" #include "PinAssignment.h" //DigitalOut led(LED1, 1); int main(void) { SW::Core core; Motor motor(core); Servo servo(core); Camera cam(core); unsigned int testCount = 0; unsigned int testCount2 = 0; char buf[5]; bool isRegRead = false; while (1) { //led = 0; core.Update(0.0f); motor.Update(0.0f); testCount++; if(testCount >= 200) { testCount2++; sprintf(buf, "%d", testCount2); servo.setAngle(SERVO_RT * SERVO_MAX_ANGLE); //core.GetUSBServer().PushUnreliableMsg('D', buf); testCount = 0; } if(!isRegRead && core.GetUSBServer().GetStatus() == SER_STAT_RUNNING) { cam.ReadRegisters(); isRegRead = true; } wait(0.01); } } /* PwmOut servo(PTE20); int main() { servo.period(0.020); // servo requires a 20ms period while (1) { for(float offset=0.0; offset<0.001; offset+=0.0001) { servo.pulsewidth(0.001 + offset); // servo position determined by a pulsewidth between 1-2ms wait(0.25); } } } */ /* //code for accelerometer sensor. const char regAddr = 0x0D; char readValue = 0; int result1 = m_sccbCtrl.write(0x1D<<1, ®Addr, 1, true); int result2 = m_sccbCtrl.read(0x1D<<1, &readValue, 1, false); char buf[20]; sprintf(buf, "%#x-%#x-%d-%d", regAddr, readValue, result1, result2); m_core.GetUSBServer().PushUnreliableMsg('D', buf); */