1
Fork 0

implemented lining mode

This commit is contained in:
Andy Killorin 2024-10-24 15:31:29 -04:00
parent eab58ccacf
commit e38cb63c7f
Signed by: ank
GPG key ID: 23F9463ECB67FE8C
2 changed files with 5 additions and 2 deletions

View file

@ -102,8 +102,9 @@ void Robot::LineFollowingUpdate(void)
if(robotState == ROBOT_LINING) if(robotState == ROBOT_LINING)
{ {
// TODO: calculate the error in CalcError(), calc the effort, and update the motion // TODO: calculate the error in CalcError(), calc the effort, and update the motion
int16_t lineError = lineSensor.CalcError(); float lineError = 3.5 - lineSensor.CalcError();
float turnEffort = 0; Serial.println(lineError);
float turnEffort = lineError * lining_kP;
chassis.SetTwist(baseSpeed, turnEffort); chassis.SetTwist(baseSpeed, turnEffort);
} }

View file

@ -3,6 +3,8 @@
#include <LineSensor.h> #include <LineSensor.h>
#include <LSM6.h> #include <LSM6.h>
static float lining_kP = 1.0;
class Robot class Robot
{ {
protected: protected: