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.
Fork of TFC-RACING-DEMO by
Revision 2:999ca57934bf, committed 2014-06-25
- Comitter:
- simonchow
- Date:
- Wed Jun 25 18:25:18 2014 +0000
- Parent:
- 1:87b28e8b9941
- Commit message:
- Track mode: Speed controlled with pot0; Kp controlled with pot1;
Changed in this revision
| Spices/Spices.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/Spices/Spices.cpp Tue Jun 24 06:38:55 2014 +0000
+++ b/Spices/Spices.cpp Wed Jun 25 18:25:18 2014 +0000
@@ -29,7 +29,7 @@
#define MIN_POWER 60 // percent min power (estimating for a 2-ft turn => 24" / (24" + 6" car) = 4/5; speed of inner wheel is 20% lower worst case
#define SPEED_ADJUST 4 // do not change
#define ABS_ERROR_THRESH 10 // number of pixels line position offset before changing KP value
-#define CONTROL_METHOD 2 // which control method to use
+#define CONTROL_METHOD 1 // which control method to use
// Drive/motor params
@@ -686,7 +686,7 @@
void SteeringControl()
{
-
+ float ReadPot1 = 1;
float targetPosition = (float)( (NUM_LINE_SCAN / 2) - 0.5); // target to achieve for line position
float KP; // proportional control factor
@@ -717,8 +717,9 @@
break;
case 1:
// Proportional control with 50% bit more oomph --- a bit more aggressive around the bends
+ ReadPot1 = TFC_ReadPot(1)+1; // pot range 0-2
KP = (float) ( MAX_STEER_RIGHT - MAX_STEER_LEFT ) / ( NUM_LINE_SCAN - (2*FILTER_ENDS) - MIN_LINE_WIDTH );
- KP = KP * 1.5;
+ KP = KP * ReadPot1;
KD = 0;
KI = 0;
break;
@@ -844,9 +845,9 @@
// set maximum speed
if (doRisky)
- MaxSpeed = LUDICROUS_SPEED; // faster
+ MaxSpeed = LUDICROUS_SPEED * ((TFC_ReadPot(0)+1)/2.0); // faster
else
- MaxSpeed = LIGHT_SPEED; // slower
+ MaxSpeed = LIGHT_SPEED * ((TFC_ReadPot(0)+1)/2.0); // slower
switch (SPEED_ADJUST)
{
