implemented lining mode
This commit is contained in:
parent
eab58ccacf
commit
e38cb63c7f
2 changed files with 5 additions and 2 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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:
|
||||||
|
|
Loading…
Reference in a new issue