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: MODSERIAL PiSlingers m3pi mbed
Revision 4:369caebdf5dc, committed 2016-03-09
- Comitter:
- mpanetta
- Date:
- Wed Mar 09 17:40:26 2016 +0000
- Parent:
- 3:aa1a77b080eb
- Commit message:
- Making Public
Changed in this revision
--- a/IRBehaviorController.cpp Sat Nov 03 01:03:33 2012 +0000
+++ b/IRBehaviorController.cpp Wed Mar 09 17:40:26 2016 +0000
@@ -70,6 +70,30 @@
return tmp;
}
+float
+IRBehaviorController::getBrightness(void)
+{
+ float tmp;
+
+ NVIC_DisableIRQ(TIMER3_IRQn); // Disable Ticker IRQ for atomicity
+ tmp = brightness;
+ NVIC_EnableIRQ(TIMER3_IRQn); // Enable Ticker IRQ
+
+ return tmp;
+}
+
+float
+IRBehaviorController::getCenteroid(void)
+{
+ float tmp;
+
+ NVIC_DisableIRQ(TIMER3_IRQn); // Disable Ticker IRQ for atomicity
+ tmp = centeroid;
+ NVIC_EnableIRQ(TIMER3_IRQn); // Enable Ticker IRQ
+
+ return tmp;
+}
+
void
IRBehaviorController::dumpDebug(Serial *debug)
{
--- a/IRBehaviorController.h Sat Nov 03 01:03:33 2012 +0000
+++ b/IRBehaviorController.h Wed Mar 09 17:40:26 2016 +0000
@@ -33,6 +33,8 @@
void runSeeking(void); // Execute seeking behavior
float getPower(void); // Returns the power value needed to execute the behavior.
+ float getBrightness(void);
+ float getCenteroid(void);
void dumpDebug(Serial *debug);
--- a/MODSERIAL.lib Sat Nov 03 01:03:33 2012 +0000 +++ b/MODSERIAL.lib Wed Mar 09 17:40:26 2016 +0000 @@ -1,1 +1,1 @@ -MODSERIAL#ef4645a79fca +https://developer.mbed.org/users/mpanetta/code/MODSERIAL/#ef4645a79fca
--- a/PiSlingers.lib Sat Nov 03 01:03:33 2012 +0000 +++ b/PiSlingers.lib Wed Mar 09 17:40:26 2016 +0000 @@ -1,1 +1,1 @@ -PiSlingers#a9351d7f92b4 +https://developer.mbed.org/users/mpanetta/code/PiSlingers/#a9351d7f92b4
--- a/m3pi.lib Sat Nov 03 01:03:33 2012 +0000 +++ b/m3pi.lib Wed Mar 09 17:40:26 2016 +0000 @@ -1,1 +1,1 @@ -m3pi#1ce8bf1f4452 +https://developer.mbed.org/users/mpanetta/code/m3pi/#1ce8bf1f4452
--- a/main.cpp Sat Nov 03 01:03:33 2012 +0000
+++ b/main.cpp Wed Mar 09 17:40:26 2016 +0000
@@ -19,8 +19,8 @@
// PID terms
#define P_TERM 0.10f
#define I_TERM 0.00f
-#define D_TERM 0.05f
-#define THRESHOLD 0.40f
+#define D_TERM 0.08f
+#define THRESHOLD 0.20f
//PID pid(P_TERM, I_TERM, D_TERM, &blueTooth);
PID pid(P_TERM, I_TERM, D_TERM);
@@ -90,7 +90,7 @@
#define BEACON_P_TERM 1.0f
#define BEACON_I_TERM 0.0f
#define BEACON_D_TERM 0.0f
-#define GO_SPEED 0.8f
+#define GO_SPEED 0.5f
PID beaconPID(BEACON_P_TERM, BEACON_I_TERM, BEACON_D_TERM);
@@ -113,11 +113,11 @@
//FunctionPointer ird_scan(&ird, &IRObjDetector::scan);
-
+ wait(1);
base.reset();
base.locate(0, 0);
base.printf("IR Track");
- wait(5);
+ wait(4);
//semihost_powerdown(); // Disable the secondary controller, this reduces both power and noise.
@@ -140,6 +140,8 @@
{
uint16_t rssiL;
uint16_t rssiR;
+ float irBrightness;
+ float irCenteroid;
blueTooth.printf("\e[1J"); // Clear terminal screen
blueTooth.printf("\e[H"); // Home terminal screen
@@ -149,10 +151,16 @@
//pid.dumpDebug(&blueTooth);
//irController.dumpDebug(&blueTooth);
- blueTooth.printf("Getting power from IR.\r\n");
- ipower = irController.getPower();
+ blueTooth.printf("Getting power brightness and centeroid from IR.\r\n");
+ ipower = irController.getPower();
+ irBrightness = irController.getBrightness();
+ irCenteroid = irController.getCenteroid();
blueTooth.printf("IR: power = %3.2f\r\n", ipower);
- ipower = 0; // Temp disable.
+ blueTooth.printf("IR: brightness= %3.2f\r\n", irBrightness);
+ blueTooth.printf("IR: centeroid = %3.2f\r\n", irCenteroid);
+ //ipower = 0; // Temp disable.
+ ipower = ipower * irBrightness; // We want more avoidance for closer objects
+ //ipower = -ipower;
beacon.scan();
@@ -180,7 +188,7 @@
else
power = bpower;
- if (rssi > 140)
+ if (rssi > 180)
{
speed = 0;
}