impl roatation-aware raddiff
This commit is contained in:
parent
936b160f2c
commit
ff16e9026d
2 changed files with 19 additions and 1 deletions
|
|
@ -46,6 +46,20 @@ float Robot::SquareDistance(void) {
|
||||||
return pow((destPose.x - currPose.x),2) + pow((destPose.y-currPose.y),2);
|
return pow((destPose.x - currPose.x),2) + pow((destPose.y-currPose.y),2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float Robot::RadError(float current, float destination) {
|
||||||
|
|
||||||
|
float diff = destination-current;
|
||||||
|
diff += PI_2;
|
||||||
|
diff %= TAU;
|
||||||
|
diff -= PI_2;
|
||||||
|
|
||||||
|
if (diff > 180) {
|
||||||
|
diff -= TAU;
|
||||||
|
}
|
||||||
|
|
||||||
|
return diff;
|
||||||
|
}
|
||||||
|
|
||||||
bool Robot::CheckReachedDestination(void)
|
bool Robot::CheckReachedDestination(void)
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|
@ -54,7 +68,8 @@ bool Robot::CheckReachedDestination(void)
|
||||||
|
|
||||||
float rad_error = abs(destPose.theta - currPose.theta);
|
float rad_error = abs(destPose.theta - currPose.theta);
|
||||||
|
|
||||||
return SquareDistance() < TARGET_SQ_DIST && rad_error < TARGET_RAD_ERR;
|
return SquareDistance() < TARGET_SQ_DIST
|
||||||
|
&& RadError(currPose.theta, destPose.theta) < TARGET_RAD_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Robot::DriveToPoint(void)
|
void Robot::DriveToPoint(void)
|
||||||
|
|
|
||||||
|
|
@ -55,4 +55,7 @@ protected:
|
||||||
|
|
||||||
// Square distance between current and target pose
|
// Square distance between current and target pose
|
||||||
float SquareDistance(void);
|
float SquareDistance(void);
|
||||||
|
|
||||||
|
// minimum radians to transform current to setpoint
|
||||||
|
float RadError(float current, float setpoint);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue