Skip to content

Commit

Permalink
MPC: PositonSmoothing, change test to reflect that we have to come in…
Browse files Browse the repository at this point in the history
…withing the acceptance radius, and not exact position.
  • Loading branch information
Claudio-Chies committed Nov 19, 2024
1 parent b53f849 commit 2bfb198
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/lib/motion_planning/PositionSmoothingTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,17 @@ TEST_F(PositionSmoothingTest, reachesTargetVelocityIntegration)

TEST_F(PositionSmoothingTest, reachesTargetInitialVelocity)
{
const int N_ITER = 2000;
const int N_ITER = 20000;
const float DELTA_T = 0.02f;
const Vector3f INITIAL_POSITION{0.f, 0.f, 0.f};
const Vector3f TARGET{12.f, 17.f, 8.f};
const Vector3f NEXT_TARGET{8.f, 12.f, 80.f};

const float XY_ACC_RAD = 10.f;
const float Z_ACC_RAD = 0.8f;


Vector3f waypoints[3] = {INITIAL_POSITION, TARGET, NEXT_TARGET};
Vector3f waypoints[3] = {INITIAL_POSITION, TARGET, TARGET};
Vector3f ff_velocity{1.f, 0.1f, 0.3f};

Vector3f position{0.f, 0.f, 0.f};
Expand All @@ -180,12 +183,13 @@ TEST_F(PositionSmoothingTest, reachesTargetInitialVelocity)
ff_velocity = {0.f, 0.f, 0.f};
expectDynamicsLimitsRespected(out);

if (position == TARGET) {
if (Vector2f(position.xy() - TARGET.xy()).norm() < XY_ACC_RAD && fabsf(position(2) - TARGET(2)) < Z_ACC_RAD) {
printf("Converged in %d iterations\n", iteration);
break;
}
}

EXPECT_EQ(TARGET, position);
EXPECT_LT(Vector2f(position.xy() - TARGET.xy()).norm(), XY_ACC_RAD);
EXPECT_LT(fabsf(position(2) - TARGET(2)), Z_ACC_RAD);
EXPECT_LT(iteration, N_ITER) << "Took too long to converge\n";
}

0 comments on commit 2bfb198

Please sign in to comment.