Fix trapezoidal profile PID controller setpoint bug (#2210)

Co-Authored-By: Austin Shalit <austinshalit@gmail.com>
This commit is contained in:
Matt
2020-01-01 15:23:25 -08:00
committed by Peter Johnson
parent abe25b795b
commit 222669dc2c
8 changed files with 90 additions and 14 deletions

View File

@@ -0,0 +1,26 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.controller;
import org.junit.jupiter.api.Test;
import edu.wpi.first.wpilibj.trajectory.TrapezoidProfile;
import static org.junit.jupiter.api.Assertions.assertEquals;
class ProfiledPIDControllerTest {
@Test
void testStartFromNonZeroPosition() {
ProfiledPIDController controller = new ProfiledPIDController(1.0, 0.0, 0.0,
new TrapezoidProfile.Constraints(1.0, 1.0));
controller.reset(20);
assertEquals(0.0, controller.calculate(20), 0.05);
}
}