use of me.wobblyyyy.pathfinder2.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 me.wobblyyyy.pathfinder2.trajectory.Trajectory in project Pathfinder2 by Wobblyyyy.
the class TestSimulatedChassis method testMultipleSplines.
@Test
public void testMultipleSplines() {
Trajectory[] splines = new Trajectory[] { factory.builder().add(new PointXYZ(0, 0, 0)).add(new PointXYZ(4, 10, 0)).add(new PointXYZ(8, 12, 0)).build(), factory.builder().add(new PointXYZ(8, 12, 0)).add(new PointXYZ(16, 10, 0)).add(new PointXYZ(18, 5, 0)).build(), factory.builder().add(new PointXYZ(18, 5, 0)).add(new PointXYZ(20, 10, 0)).add(new PointXYZ(22, 12, 0)).build() };
for (Trajectory spline : splines) pathfinder.followTrajectory(spline);
pathfinder.tickUntil(500);
assertPositionIs(new PointXYZ(22, 12, 0));
}
use of me.wobblyyyy.pathfinder2.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());
}
use of me.wobblyyyy.pathfinder2.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 me.wobblyyyy.pathfinder2.trajectory.Trajectory in project Pathfinder2 by Wobblyyyy.
the class TestTaskTrajectory method testMinTimeTaskTrajectory.
@Test
public void testMinTimeTaskTrajectory() {
ElapsedTimer timer = new ElapsedTimer(true);
Trajectory trajectory = new TaskTrajectoryBuilder().setMinTimeMs(10).setIsFinished(() -> timer.elapsedMs() > 10).build();
testTrajectory(trajectory, pathfinder.getPosition(), 100);
Assertions.assertTrue(timer.elapsedMs() > 10);
}
Aggregations