mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Fix onTarget() so that it returns false until there are any values retrieved
The onTarget() method uses the average error and there might not be a valid value until the PIDController runs once. This is causing commands to bail out early in simulation. Change-Id: I7bac9ecb847cbe4f378385b1a6998bba10147554
This commit is contained in:
committed by
Fredric Silberberg
parent
c57e749a94
commit
99b6000a65
@@ -486,8 +486,10 @@ void PIDController::SetToleranceBuffer(unsigned bufLength) {
|
||||
* setpoint.
|
||||
* Ideally it should be based on being within the tolerance for some period of
|
||||
* time.
|
||||
* This will return false until at least one input value has been computed.
|
||||
*/
|
||||
bool PIDController::OnTarget() const {
|
||||
if (m_buf.size() == 0) return false;
|
||||
double error = GetAvgError();
|
||||
|
||||
std::lock_guard<priority_recursive_mutex> sync(m_mutex);
|
||||
|
||||
Reference in New Issue
Block a user