mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[wpimath] Optimize 2nd derivative of quintic splines (#3292)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
This commit is contained in:
committed by
GitHub
parent
4fcf0b25a1
commit
51eecef2bd
@@ -172,8 +172,8 @@ class MecanumDriveOdometryTest {
|
||||
}
|
||||
|
||||
assertEquals(
|
||||
0.0, errorSum / (trajectory.getTotalTimeSeconds() / dt), 0.15, "Incorrect mean error");
|
||||
assertEquals(0.0, maxError, 0.3, "Incorrect max error");
|
||||
0.0, errorSum / (trajectory.getTotalTimeSeconds() / dt), 0.35, "Incorrect mean error");
|
||||
assertEquals(0.0, maxError, 0.35, "Incorrect max error");
|
||||
assertEquals(
|
||||
1.0,
|
||||
odometryDistanceTravelled / trajectoryDistanceTravelled,
|
||||
|
||||
@@ -7,6 +7,7 @@ package edu.wpi.first.math.trajectory;
|
||||
import static edu.wpi.first.math.util.Units.feetToMeters;
|
||||
import static org.junit.jupiter.api.Assertions.assertAll;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import edu.wpi.first.math.geometry.Pose2d;
|
||||
@@ -80,4 +81,21 @@ class TrajectoryGeneratorTest {
|
||||
assertEquals(traj.getStates().size(), 1);
|
||||
assertEquals(traj.getTotalTimeSeconds(), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testQuinticCurvatureOptimization() {
|
||||
Trajectory t =
|
||||
TrajectoryGenerator.generateTrajectory(
|
||||
Arrays.asList(
|
||||
new Pose2d(1, 0, Rotation2d.fromDegrees(90)),
|
||||
new Pose2d(0, 1, Rotation2d.fromDegrees(180)),
|
||||
new Pose2d(-1, 0, Rotation2d.fromDegrees(270)),
|
||||
new Pose2d(0, -1, Rotation2d.fromDegrees(360)),
|
||||
new Pose2d(1, 0, Rotation2d.fromDegrees(90))),
|
||||
new TrajectoryConfig(2, 2));
|
||||
|
||||
for (int i = 1; i < t.getStates().size() - 1; ++i) {
|
||||
assertNotEquals(0, t.getStates().get(i).curvatureRadPerMeter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user