1
Fork 0

tuned constants

notably updated wheel diameter to 7cm
This commit is contained in:
Andy Killorin 2024-10-25 16:38:56 -04:00
parent de02805873
commit 9483d84ad5
Signed by: ank
GPG key ID: 23F9463ECB67FE8C
5 changed files with 21 additions and 7 deletions

View file

@ -7,8 +7,8 @@
* tune them. * tune them.
*/ */
const float ROBOT_RADIUS = 14.7 / 2; const float ROBOT_RADIUS = 14.7 / 2;
const float LEFT_TICKS_PER_CM = 1440.0 / (3.1416 * 4.0); const float LEFT_TICKS_PER_CM = 1440.0 / (3.1416 * 7);
const float RIGHT_TICKS_PER_CM = 1440.0 / (3.1416 * 4.0); const float RIGHT_TICKS_PER_CM = 1440.0 / (3.1416 * 7);
/** /**
* You can change the control loop period, but you should use multiples of 4 ms to * You can change the control loop period, but you should use multiples of 4 ms to

View file

@ -2,7 +2,7 @@
#define DARK_THRESHOLD 500; #define DARK_THRESHOLD 500;
#define LINE_THRESHOLD 200; #define LINE_THRESHOLD 110;
#define INTERSECTION_THRESHOLD 500; #define INTERSECTION_THRESHOLD 500;
void LineSensor::Initialize(void) void LineSensor::Initialize(void)

View file

@ -34,7 +34,7 @@ protected:
// Used to keep track of the target speed, in counts / interval. // Used to keep track of the target speed, in counts / interval.
float targetSpeed = 0; float targetSpeed = 0;
float TRAPEZOIDAL_RAMP_RATE_CM_S = 30.; float TRAPEZOIDAL_RAMP_RATE_CM_S = 10.;
// maximum accelration in counts/interval // maximum accelration in counts/interval
float TRAPEZOIDAL_RAMP_RATE = TRAPEZOIDAL_RAMP_RATE_CM_S / LEFT_TICKS_PER_CM / CONTROL_LOOP_PERIOD_S; float TRAPEZOIDAL_RAMP_RATE = TRAPEZOIDAL_RAMP_RATE_CM_S / LEFT_TICKS_PER_CM / CONTROL_LOOP_PERIOD_S;
float currentSetpoint = 0; float currentSetpoint = 0;

View file

@ -123,6 +123,18 @@ void Robot::LineFollowingUpdate(void)
float turnEffort = powErr * lining_kP2 + lineError * lining_kP + errDiff * lining_kD; float turnEffort = powErr * lining_kP2 + lineError * lining_kP + errDiff * lining_kD;
#ifdef __LINING_DEBUG__
Serial.print(lineSensor.CalcError());
Serial.print(' ');
Serial.print(lineError * lining_kP);
Serial.print(' ');
Serial.print(errDiff * lining_kD);
Serial.print(' ');
Serial.print(turnEffort);
Serial.print(' ');
Serial.println(lineSensor.AverageReflectance());
#endif
rollingTurnRate = rollingTurnRate * turnRateDamp + turnEffort * (1-turnRateDamp); rollingTurnRate = rollingTurnRate * turnRateDamp + turnEffort * (1-turnRateDamp);
float speed = baseSpeed; float speed = baseSpeed;

View file

@ -3,7 +3,9 @@
#include <LineSensor.h> #include <LineSensor.h>
#include <LSM6.h> #include <LSM6.h>
static float lining_kP = 1.24; static float lining_kP2 = 0.67;
static float lining_kP = 0.72;
static float lining_kD = -1.2;
class Robot class Robot
{ {
@ -58,8 +60,8 @@ protected:
float baseSpeed = 0; float baseSpeed = 0;
float rollingTurnRate = 0; float rollingTurnRate = 0;
float turnRateDamp = 0.96; // the proportion of the turn rate retained each loop float turnRateDamp = 0.975; // the proportion of the turn rate retained each loop
float KTurnRate = 0.25; // slowdown coefficient float KTurnRate = 0.18; // slowdown coefficient
/** /**
* For tracking the motion of the Romi. We keep track of the intersection we came * For tracking the motion of the Romi. We keep track of the intersection we came