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
Revision 13:521d6c6e7042, committed 2019-04-29
- Comitter:
- UditSrivastav
- Date:
- Mon Apr 29 09:40:30 2019 +0000
- Parent:
- 12:11d203351eb0
- Commit message:
- Anythign um
Changed in this revision
--- a/PID.h Mon Apr 29 00:57:32 2019 +0000
+++ b/PID.h Mon Apr 29 09:40:30 2019 +0000
@@ -82,6 +82,13 @@
return prevControlAction;
}
+ void reset()
+ {
+ prevControlAction = 0;
+ PrevPrevErr = 0;
+ PrevErr = 0;
+ }
+
};
//(((temp-inMin)/(inMax - inMin))*(outMax-outMin))+outMin
\ No newline at end of file
--- a/Robot.h Mon Apr 29 00:57:32 2019 +0000
+++ b/Robot.h Mon Apr 29 09:40:30 2019 +0000
@@ -173,13 +173,15 @@
sensorNumber = 0;
if (endOfLineDetection < 5)
{
- AF = 0.425f;
+ AF = 0.5f;
adjustRbtAngularVelocity(lineVoltages[lvIndex%numberOfSamples]);
lvIndex++;
}
else
{
- stopMovement();
+ stopMovement();
+ rightWheel->resetPID();
+ leftWheel->resetPID();
}
endOfLineDetection = 0;
}
@@ -187,10 +189,13 @@
void turn180()
{
+ stopMovement();
+ rightWheel->resetPID();
+ leftWheel->resetPID();
updater.detach();
rightWheel->adjustAngularVelocity(rightWheel->returnMaxAngularVel()*0.3f);
leftWheel->adjustAngularVelocity(rightWheel->returnMaxAngularVel()*-0.3f);
- timeToStop.attach(callback(this, &Robot::reAttach),1.1f);
+ timeToStop.attach(callback(this, &Robot::reAttach),1.0f);
state = 'S';
}
--- a/SensorControl/lineSensor.h Mon Apr 29 00:57:32 2019 +0000
+++ b/SensorControl/lineSensor.h Mon Apr 29 09:40:30 2019 +0000
@@ -9,7 +9,7 @@
Timeout sampler;
public:
- float static const sampleTime = 0.00004f;
+ float static const sampleTime = 0.00009f;
lineSensor(PinName E, PinName R):emitter(E), receiver(R)
{
--- a/WheelControl/Wheel.h Mon Apr 29 00:57:32 2019 +0000
+++ b/WheelControl/Wheel.h Mon Apr 29 09:40:30 2019 +0000
@@ -60,6 +60,11 @@
return angularVelocity;
}
+ void resetPID()
+ {
+ controller.reset();
+ }
+
//only called once during initialization to calculate max angular velocity
//dir = direction, do opposite for each wheel just so your buggy doesn't move FORWARD but rather rotates
void init(int dir)