car using PID from centre line
Dependencies: FRDM-TFC mbed CBuffer XBEE mbed_angular_speed motor2 MMA8451Q
Fork of KL25Z_Camera_Test by
Diff: main.cpp
- Revision:
- 32:6829684f8c4d
- Parent:
- 31:1a06c9e1985e
- Child:
- 33:0fc789c09694
- Child:
- 34:3de7a19ccea3
diff -r 1a06c9e1985e -r 6829684f8c4d main.cpp --- a/main.cpp Wed Jan 11 11:36:56 2017 +0000 +++ b/main.cpp Wed Jan 11 19:59:03 2017 +0000 @@ -31,7 +31,7 @@ Timer t1; Timer t2; -//testing timer +//testing timer for laptimes Timer lapTimer; @@ -220,10 +220,11 @@ //dutyCycleCorner(speed,servo_pid.output); - //may want to have just to set cornering speed at different if going to be slowing down for cornering. + //dutyCycleCorner(float cornerspeed, servo_pid.output); //dutyCycleCorner(speed, servo_pid.output); - + // This activates the electronic differential so that it runs whilst cornering. + // this changes the desired desired speed of each of the wheels according to the angle of the servo. sensorCorner(left_motor_pid.desired_value, right_motor_pid.desired_value , servo_pid.output, speed); } @@ -592,14 +593,16 @@ int lapTime() { // function which sends the lap time back to the telemetry. + //reads the timer float newTime= lapTimer.read(); lapNo += 1; float lapTime= newTime-oldTime; float avgTime= newTime/lapNo; - + // this calulates the average lap time and the lap time. + //then sends the information back to the UI. sendString("For lap number: %d Lap Time: %f Avergae time: %f \n\r", lapNo,lapTime,avgTime); - // OH WHAT UP IT'S DAT BOI!!!! + return 0; }