use of com.team254.lib_2014.trajectory.Trajectory in project Pathfinder2 by Wobblyyyy.
the class TestSimulatedChassis method testAkimaSplineInterpolation.
@Test
public void testAkimaSplineInterpolation() {
Trajectory trajectory = new AdvancedSplineTrajectoryBuilder().setStep(0.5).setTolerance(DEFAULT_TOLERANCE).setAngleTolerance(Angle.fromDeg(1)).setInterpolationMode(InterpolationMode.AKIMA).setSpeed(0.5).add(new PointXYZ(0, 0, 0)).add(new PointXYZ(4, 10, 0)).add(new PointXYZ(8, 12, 0)).add(new PointXYZ(10, 13, 0)).add(new PointXYZ(12, 14, 0)).add(new PointXYZ(14, 15, 0)).build();
pathfinder.followTrajectory(trajectory);
pathfinder.tickUntil(500);
assertPositionIs(new PointXYZ(14, 15, 0));
}
use of com.team254.lib_2014.trajectory.Trajectory in project Pathfinder2 by Wobblyyyy.
the class TestSimulatedChassis method testMultiSegmentTrajectory.
@Test
public void testMultiSegmentTrajectory() {
List<Trajectory> trajectories = new LinearTrajectoryBuilder().setSpeed(0.5).setTolerance(DEFAULT_TOLERANCE).setAngleTolerance(Angle.fromDeg(1)).goTo(new PointXYZ(0, 0, 0)).goTo(new PointXYZ(0, 10, 0)).goTo(new PointXYZ(10, 10, 0)).goTo(new PointXYZ(10, 0, 0)).goTo(new PointXYZ(0, 0, 0)).getTrajectories();
Trajectory trajectory = new MultiSegmentTrajectory(trajectories);
pathfinder.followTrajectory(trajectory);
pathfinder.tickUntil(500);
assertPositionIs(new PointXYZ());
}
use of com.team254.lib_2014.trajectory.Trajectory in project Pathfinder2 by Wobblyyyy.
the class TestSimulatedChassis method testReflectedTrajectory.
@Test
public void testReflectedTrajectory() {
Trajectory a = new LinearTrajectory(new PointXYZ(10, 10, 0), 0.05, 0.01, Angle.fromDeg(1)).reflectX(0);
Trajectory b = new LinearTrajectory(new PointXYZ(10, 10, 0), 0.05, 0.01, Angle.fromDeg(1)).reflectY(0);
Trajectory c = new LinearTrajectory(new PointXYZ(10, 10, 0), 0.05, 0.01, Angle.fromDeg(1)).reflectX(0).reflectY(0);
pathfinder.followTrajectory(a).tickUntil(500);
assertPositionIs(new PointXYZ(-10, 10, 0));
pathfinder.followTrajectory(b).tickUntil(500);
assertPositionIs(new PointXYZ(10, -10, 0));
pathfinder.followTrajectory(c).tickUntil(500);
assertPositionIs(new PointXYZ(-10, -10, 0));
}
use of com.team254.lib_2014.trajectory.Trajectory in project Pathfinder2 by Wobblyyyy.
the class TestSimulatedChassis method testCubicSplineInterpolation.
@Test
public void testCubicSplineInterpolation() {
Trajectory trajectory = new AdvancedSplineTrajectoryBuilder().setStep(0.1).setTolerance(DEFAULT_TOLERANCE).setAngleTolerance(Angle.fromDeg(1)).setInterpolationMode(InterpolationMode.CUBIC).setSpeed(0.5).add(new PointXYZ(0, 0, 0)).add(new PointXYZ(4, 10, 0)).add(new PointXYZ(8, 12, 0)).add(new PointXYZ(10, 13, 0)).add(new PointXYZ(12, 14, 0)).add(new PointXYZ(14, 15, 0)).build();
pathfinder.followTrajectory(trajectory);
pathfinder.tickUntil(500);
assertPositionIs(new PointXYZ(14, 15, 0));
}
use of com.team254.lib_2014.trajectory.Trajectory in project Pathfinder2 by Wobblyyyy.
the class TestSimulatedChassis method testBackwardsArcSpline.
@Test
public void testBackwardsArcSpline() {
Trajectory trajectory = factory.builder().setInterpolationMode(InterpolationMode.CUBIC).setStep(0.1).add(new PointXYZ(10, 10, 0)).add(new PointXYZ(10, 0, 0).inDirection(10, Angle.fixedDeg(135))).add(new PointXYZ(0, 0, 0)).build();
odometry.setRawPosition(new PointXYZ(10, 10, 0));
pathfinder.followTrajectory(trajectory);
pathfinder.tickUntil(500);
assertPositionIs(new PointXYZ());
}
Aggregations