2014 Eurobot fork

Dependencies:   mbed-rtos mbed QEI

Files at this revision

API Documentation at this revision

Comitter:
madcowswe
Date:
Sun Apr 14 14:59:57 2013 +0000
Parent:
63:c2c6269767b8
Child:
66:f1d75e51398d
Commit message:
Gains fairly tuned.

Changed in this revision

Processes/Motion/motion.cpp Show annotated file Show diff for this revision Revisions of this file
Processes/MotorControl/MotorControl.cpp Show annotated file Show diff for this revision Revisions of this file
Processes/Printing/Printing.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Processes/Motion/motion.cpp	Sun Apr 14 14:32:43 2013 +0000
+++ b/Processes/Motion/motion.cpp	Sun Apr 14 14:59:57 2013 +0000
@@ -115,7 +115,7 @@
     // angular velocity controller
     const float p_gain_av = 0.5; //TODO: tune
     
-    const float max_av = 0.5*PI; // radians per sec //TODO: tune
+    const float max_av = 0.5; // radians per sec //TODO: tune
     
     // angle error [-pi, pi]
     float angular_v = p_gain_av * angle_err;
@@ -128,9 +128,9 @@
     
     
     // forward velocity controller
-    const float p_gain_fv = 0.25; //TODO: tune
+    const float p_gain_fv = 0.5; //TODO: tune
     
-    float max_fv = 0.2; // meters per sec //TODO: tune
+    float max_fv = 0.3; // meters per sec //TODO: tune
     float max_fv_reverse = 0.05; //TODO: tune
     const float angle_envelope_exponent = 32.0;//512; //8.0; //TODO: tune
     
--- a/Processes/MotorControl/MotorControl.cpp	Sun Apr 14 14:32:43 2013 +0000
+++ b/Processes/MotorControl/MotorControl.cpp	Sun Apr 14 14:59:57 2013 +0000
@@ -74,8 +74,8 @@
     float lff = fwdcmd - omegacmd*ENCODER_WHEELBASE/2.0f;
     float rff = fwdcmd + omegacmd*ENCODER_WHEELBASE/2.0f;
 
-    mleft(max(min(actuateleft + max(power_per_dc_m_per_s*abs(lff), hysteresis_pwr)*sgn(lff), MOTOR_MAX_POWER), -MOTOR_MAX_POWER));
-    mright(max(min(actuateright + max(power_per_dc_m_per_s*abs(rff), hysteresis_pwr)*sgn(rff), MOTOR_MAX_POWER), -MOTOR_MAX_POWER));
+    mleft(max(min(actuateleft + max(power_per_dc_m_per_s*abs(lff), min(hysteresis_pwr, 3.0f*abs(lff)))*sgn(lff), MOTOR_MAX_POWER), -MOTOR_MAX_POWER));
+    mright(max(min(actuateright + max(power_per_dc_m_per_s*abs(rff), min(hysteresis_pwr, 3.0f*abs(rff)))*sgn(rff), MOTOR_MAX_POWER), -MOTOR_MAX_POWER));
     
     if (!(abs(actuateleft) > MOTOR_MAX_POWER || abs(actuateright) > MOTOR_MAX_POWER)){
         fwdIstate += errfwd;
--- a/Processes/Printing/Printing.h	Sun Apr 14 14:32:43 2013 +0000
+++ b/Processes/Printing/Printing.h	Sun Apr 14 14:59:57 2013 +0000
@@ -1,7 +1,7 @@
 
 // Eurobot13 Printing.h
 
-#define PRINTINGOFF
+//#define PRINTINGOFF
 
 #include "mbed.h"
 #include "rtos.h"
--- a/main.cpp	Sun Apr 14 14:32:43 2013 +0000
+++ b/main.cpp	Sun Apr 14 14:59:57 2013 +0000
@@ -73,20 +73,16 @@
     Ticker motorcontroltestticker;
     motorcontroltestticker.attach(MotorControl::motor_control_isr, 0.05);
     // ai layer thread
-    //Thread aithread(AI::ailayer, NULL, osPriorityNormal, 2048);
+    Thread aithread(AI::ailayer, NULL, osPriorityNormal, 2048);
     
     // motion layer periodic callback
-    //RtosTimer motion_timer(motion::motionlayer, osTimerPeriodic);
-    //motion_timer.start(50);
+    RtosTimer motion_timer(motion::motionlayer, osTimerPeriodic);
+    motion_timer.start(50);
 
-    //Thread printingThread(Printing::printingloop, NULL, osPriorityLow, 2048);
-    
-    //while(1){
-    //    printf("r:%f, l:%f, t:%f\r\n", right_encoder.getTicks()*ENCODER_M_PER_TICK, left_encoder.getTicks()*ENCODER_M_PER_TICK, SystemTime.read());
-    //}
+    Thread printingThread(Printing::printingloop, NULL, osPriorityLow, 2048);
 
-    //measureCPUidle(); //repurpose thread for idle measurement
-    
+    measureCPUidle(); //repurpose thread for idle measurement
+    /*
     MotorControl::set_omegacmd(0);
     for(float spd = 0.02; spd <= 0.5; spd *= 1.4){
     
@@ -114,7 +110,7 @@
         printf("targetspd:%f, fwd:%f, rot:%f\r\n", spd, f, r);
         Thread::wait(5000);
     }
-    
+    */
     Thread::wait(osWaitForever);
    
 }