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:
- 6:477382219bcf
- Parent:
- 5:f1613df66ceb
- Child:
- 7:cb07cdb35b6c
--- a/Robot.h Mon Mar 25 22:42:31 2019 +0000
+++ b/Robot.h Tue Mar 26 16:19:47 2019 +0000
@@ -4,7 +4,7 @@
int static const numberOfSamples = 100;
int static const numberOfSensors = 6;
//attenuation factor
- float static const AF = 0.8f;
+ float static const AF = 0.3f;
Wheel* leftWheel;
Wheel* rightWheel;
lineSensor* sensorArray[numberOfSensors];
@@ -12,15 +12,21 @@
float lineVoltages[numberOfSamples];
int lvIndex;
int sensorNumber;
+
Ticker updater;
+
int endOfLineDetection;
+ float Reflec;
float RoboticAngularVelocity;
public:
- Robot(Wheel* LW, Wheel* RW, lineSensor* SA[]) : controller(10000.0f, 0.0f, 0.0f, 0.0003f)
+ Robot(Wheel* LW, Wheel* RW, lineSensor* SA[]) : controller(2.0f, 0.0f, 0.0f, 0.0006f)
{
+ updater.detach();
+
+ Reflec = 0;
lvIndex = 0;
sensorNumber = 0;
sensorArray[0] = SA[0];
@@ -36,9 +42,6 @@
//controller will output a value between +- max speed of wheels
controller.assignLimitAddress(rightWheel->returnMinAVptr(),leftWheel->returnMaxAVptr());
- controller.setInputLimits(-300.0f,300.0f);
- controller.setSetPoint(0.0f);
- updater.attach(callback(this, &Robot::robotUpdates),0.00005f);
};
float calculateTranslationalVelocity()
@@ -76,6 +79,7 @@
void robotUpdates(void) //sampling rate the ticker is attached I.E the wheel speed is updated everytime this function is called
{
float ambientLight;
+ float reading;
ambientLight = sensorArray[sensorNumber]->calcLineVoltage();
sensorArray[sensorNumber]->sample();
sensorArray[sensorNumber]->calcLineVoltage();
@@ -122,7 +126,11 @@
void rbtInit()
{
-
+ sensorArray[0]->sample();
+ Reflec = sensorArray[0]->calcLineVoltage();
+ controller.setInputLimits(-300.0f,300.0f);
+ controller.setSetPoint(0.0f);
+ updater.attach(callback(this, &Robot::robotUpdates),0.0001f);
}
};