use of com.team254.lib_2014.trajectory.Trajectory in project Pathfinder2 by Wobblyyyy.
the class TrajectoryFactory method getFastTrajectories.
public static List<Trajectory> getFastTrajectories(PointXYZ start, List<PointXYZ> points, double speed) {
List<Trajectory> trajectories = new ArrayList<>(points.size() - 1);
PointXYZ lastPoint = start;
for (PointXYZ point : points) {
FastTrajectory trajectory = new FastTrajectory(lastPoint, point, speed);
trajectories.add(trajectory);
lastPoint = point;
}
return trajectories;
}
use of com.team254.lib_2014.trajectory.Trajectory in project Pathfinder2 by Wobblyyyy.
the class TestSimulatedChassis method testGlobalTrajectoryMap.
@Test
public void testGlobalTrajectoryMap() {
Class<?> clazz = TestSimulatedChassis.class;
Trajectory trajectory = factory.builder().add(new PointXYZ(0, 0, 0)).add(new PointXYZ(0, 0, 0).inDirection(10, Angle.fromDeg(45))).add(new PointXYZ(10, 10, 0)).build();
Pathfinder.addTrajectory(clazz, "test", trajectory);
pathfinder.followTrajectory(clazz, "test");
pathfinder.tickUntil(500);
Pathfinder.removeTrajectory(clazz, "test");
assertPositionIs(new PointXYZ(10, 10, 0));
}
use of com.team254.lib_2014.trajectory.Trajectory in project Pathfinder2 by Wobblyyyy.
the class TestSimulatedChassis method testArcSpline.
@Test
public void testArcSpline() {
Trajectory trajectory = factory.builder().add(new PointXYZ(0, 0, 0)).add(new PointXYZ(10, 0, 0).inDirection(10, Angle.fixedDeg(135))).add(new PointXYZ(10, 10, 0)).build();
pathfinder.followTrajectory(trajectory);
pathfinder.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 testOnFinishFollower.
@Test
public void testOnFinishFollower() {
AtomicInteger count = new AtomicInteger(0);
Consumer<PointXYZ> consumer = position -> {
count.getAndIncrement();
};
Trajectory a = new LinearTrajectory(new PointXYZ(10, 10, 0), 0.05, 0.01, Angle.fromDeg(1)).reflectX(0).onFinish(consumer);
Trajectory b = new LinearTrajectory(new PointXYZ(10, 10, 0), 0.05, 0.01, Angle.fromDeg(1)).reflectY(0).onFinish(consumer);
Trajectory c = new LinearTrajectory(new PointXYZ(10, 10, 0), 0.05, 0.01, Angle.fromDeg(1)).reflectX(0).reflectY(0).onFinish(consumer);
pathfinder.followTrajectories(a, b, c);
pathfinder.tickUntil(500);
assertPositionIs(new PointXYZ(-10, -10, 0));
Assertions.assertEquals(3, count.get());
}
use of com.team254.lib_2014.trajectory.Trajectory in project Pathfinder2 by Wobblyyyy.
the class TestAdvancedSplineTrajectory method testSplineTo.
private void testSplineTo(PointXYZ... points) {
if (points.length < 1)
throw new IllegalArgumentException();
AdvancedSplineTrajectoryBuilder builder = new AdvancedSplineTrajectoryBuilder().setStep(0.1).setTolerance(tolerance).setSpeed(speed).setAngleTolerance(angleTolerance);
builder.setInterpolationMode(mode);
for (PointXYZ point : points) builder.add(point);
builder.setInterpolationMode(InterpolationMode.DEFAULT);
Trajectory trajectory = builder.build();
PointXYZ target = points[points.length - 1];
testTrajectory(trajectory, target);
}
Aggregations