Skip to content

Commit

Permalink
Added negative setpoint test
Browse files Browse the repository at this point in the history
  • Loading branch information
romi2002 committed Apr 3, 2024
1 parent 8b8ade3 commit 0f5fe6d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/controllers/control_laws/pid_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ TEST(PID, SimpleModel){

// Position should be near setpoint.
EXPECT_NEAR(position, 5, 0.1);

pid = PID(param);
position = 0;
velocity = 0;
// Run a simple simulation, check that setpoint is reached with full PID impl.
for(int i = 0; i < 1000; i++){
double u = pid.update(position, -5);

position += (velocity + u) * param.kDt;
velocity += 0.1 * param.kDt;
}


EXPECT_NEAR(position, -5, 0.1);
}

TEST(PID, ClampU) {
Expand Down

0 comments on commit 0f5fe6d

Please sign in to comment.