possible DriveToPoint impl
This commit is contained in:
parent
324a51cf4c
commit
e4b4072fd9
2 changed files with 8 additions and 12 deletions
|
|
@ -62,10 +62,6 @@ float Robot::RadError(float current, float destination) {
|
|||
|
||||
bool Robot::CheckReachedDestination(void)
|
||||
{
|
||||
/**
|
||||
* TODO: Add code to check if you've reached destination here.
|
||||
*/
|
||||
|
||||
return SquareDistance() < TARGET_SQ_DIST
|
||||
&& RadError(currPose.theta, destPose.theta) < TARGET_RAD_ERR;
|
||||
}
|
||||
|
|
@ -83,20 +79,16 @@ void Robot::DriveToPoint(void)
|
|||
}
|
||||
|
||||
float heading_err = RadError(currPose.theta, target_heading);
|
||||
float forward_effort = cos(heading_err) * sqrt(SquareDistance());
|
||||
float forward_err = cos(heading_err) * sqrt(SquareDistance());
|
||||
|
||||
|
||||
/**
|
||||
* TODO: Add your IK algorithm here.
|
||||
*/
|
||||
float turn_effort = heading_err * LATERAL_kP;
|
||||
float forward_effort = forward_err * LONGITUDINAL_kP;
|
||||
|
||||
#ifdef __NAV_DEBUG__
|
||||
// Print useful stuff here.
|
||||
#endif
|
||||
|
||||
/**
|
||||
* TODO: Call chassis.SetMotorEfforts() to command the motion, based on your calculations above.
|
||||
*/
|
||||
chassis.SetMotorEfforts(forward_effort - turn_effort, forward_effort + turn_effort);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -105,4 +97,5 @@ void Robot::HandleDestination(void)
|
|||
/**
|
||||
* TODO: Stop and change state. Turn off LED.
|
||||
*/
|
||||
EnterIdleState(); // TODO: sequence
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@
|
|||
const float TARGET_SQ_DIST = pow(3.0, 2); // distance from setpoint that is ok (cm)
|
||||
const float TARGET_RAD_ERR = 0.25; // angle from setpoint that is ok (rad)
|
||||
|
||||
const float LONGITUDINAL_kP = 3.0;
|
||||
const float LATERAL_kP = 3.0 * DEG_TO_RAD;
|
||||
|
||||
class Robot
|
||||
{
|
||||
protected:
|
||||
|
|
|
|||
Loading…
Reference in a new issue