Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: Robot.h
- Revision:
- 12:11d203351eb0
- Parent:
- 11:78c645fb76cd
--- a/Robot.h Sun Apr 28 22:20:28 2019 +0000
+++ b/Robot.h Mon Apr 29 00:57:32 2019 +0000
@@ -16,9 +16,8 @@
Ticker updater;
Timeout timeToStop;
- float endOfLineDetection;
float Reflec;
-
+ int endOfLineDetection;
float RoboticAngularVelocity;
char state;
@@ -27,6 +26,7 @@
Robot(Wheel* LW, Wheel* RW, lineSensor* SA[]) : controller(2.0f, 0.0f, 0.0f, 0.0006f) //this controller actually does nothing atm
{
+ endOfLineDetection = 0;
updater.detach();
timeToStop.detach();
AF = 0.7f; //change this value to change max speedzzzzzzzzzzzzzzzzz
@@ -143,27 +143,27 @@
{
case 0:
lineVoltages[lvIndex%numberOfSamples] = (reading * -260.0f);
- if (reading <= Reflec*8){endOfLineDetection++;}
+ if (reading <= 0.1f){endOfLineDetection++;}
break;
case 1:
lineVoltages[lvIndex%numberOfSamples] += (reading * -105.0f);
- if (reading <= Reflec*8) {endOfLineDetection++;}
+ if (reading <= 0.1f) {endOfLineDetection++;}
break;
case 2:
lineVoltages[lvIndex%numberOfSamples] += (reading * -32.5f);
- if (reading <= Reflec*8) {endOfLineDetection++;}
+ if (reading <= 0.1f) {endOfLineDetection++;}
break;
case 3:
lineVoltages[lvIndex%numberOfSamples] += (reading * 32.5f);
- if (reading <= Reflec*8) {endOfLineDetection++;}
+ if (reading <= 0.1f) {endOfLineDetection++;}
break;
case 4:
lineVoltages[lvIndex%numberOfSamples] += (reading * 75.0f);
- if (reading <= Reflec*8) {endOfLineDetection++;}
+ if (reading <= 0.1f) {endOfLineDetection++;}
break;
case 5:
lineVoltages[lvIndex%numberOfSamples] += (reading * 175.0f);
- if (reading <= Reflec*8) {endOfLineDetection++;}
+ if (reading <= 0.1f) {endOfLineDetection++;}
break;
}
@@ -171,10 +171,9 @@
if (sensorNumber >= numberOfSensors)
{
sensorNumber = 0;
- if (endOfLineDetection < 6)
+ if (endOfLineDetection < 5)
{
- //AF = scaler(-180.0f,180.0f, 0.2f, 1.0f, lineVoltages[lvIndex%numberOfSamples]);
- AF = 0.7f;
+ AF = 0.425f;
adjustRbtAngularVelocity(lineVoltages[lvIndex%numberOfSamples]);
lvIndex++;
}