Search in sources :

Example 16 with Trajectory

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;
}
Also used : FastTrajectory(me.wobblyyyy.pathfinder2.trajectory.FastTrajectory) ArrayList(java.util.ArrayList) FastTrajectory(me.wobblyyyy.pathfinder2.trajectory.FastTrajectory) LinearTrajectory(me.wobblyyyy.pathfinder2.trajectory.LinearTrajectory) Trajectory(me.wobblyyyy.pathfinder2.trajectory.Trajectory) PointXYZ(me.wobblyyyy.pathfinder2.geometry.PointXYZ)

Example 17 with Trajectory

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));
}
Also used : ArcTrajectory(me.wobblyyyy.pathfinder2.trajectory.ArcTrajectory) Trajectory(me.wobblyyyy.pathfinder2.trajectory.Trajectory) MultiSegmentTrajectory(me.wobblyyyy.pathfinder2.trajectory.multi.segment.MultiSegmentTrajectory) LinearTrajectory(me.wobblyyyy.pathfinder2.trajectory.LinearTrajectory) PointXYZ(me.wobblyyyy.pathfinder2.geometry.PointXYZ)

Example 18 with Trajectory

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));
}
Also used : ArcTrajectory(me.wobblyyyy.pathfinder2.trajectory.ArcTrajectory) Trajectory(me.wobblyyyy.pathfinder2.trajectory.Trajectory) MultiSegmentTrajectory(me.wobblyyyy.pathfinder2.trajectory.multi.segment.MultiSegmentTrajectory) LinearTrajectory(me.wobblyyyy.pathfinder2.trajectory.LinearTrajectory) PointXYZ(me.wobblyyyy.pathfinder2.geometry.PointXYZ)

Example 19 with Trajectory

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());
}
Also used : Angle(me.wobblyyyy.pathfinder2.geometry.Angle) InterpolationMode(me.wobblyyyy.pathfinder2.trajectory.spline.InterpolationMode) ProportionalController(me.wobblyyyy.pathfinder2.control.ProportionalController) Geometry(me.wobblyyyy.pathfinder2.geometry.Geometry) Pathfinder(me.wobblyyyy.pathfinder2.Pathfinder) ArcTrajectory(me.wobblyyyy.pathfinder2.trajectory.ArcTrajectory) Trajectory(me.wobblyyyy.pathfinder2.trajectory.Trajectory) Lifecycle(org.junit.jupiter.api.TestInstance.Lifecycle) Translation(me.wobblyyyy.pathfinder2.geometry.Translation) Consumer(java.util.function.Consumer) StatTracker(me.wobblyyyy.pathfinder2.plugin.bundled.StatTracker) List(java.util.List) AdvancedSplineTrajectoryBuilder(me.wobblyyyy.pathfinder2.trajectory.spline.AdvancedSplineTrajectoryBuilder) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) SplineBuilderFactory(me.wobblyyyy.pathfinder2.trajectory.spline.SplineBuilderFactory) org.junit.jupiter.api(org.junit.jupiter.api) LinearTrajectoryBuilder(me.wobblyyyy.pathfinder2.trajectory.builder.LinearTrajectoryBuilder) MultiSegmentTrajectory(me.wobblyyyy.pathfinder2.trajectory.multi.segment.MultiSegmentTrajectory) Robot(me.wobblyyyy.pathfinder2.robot.Robot) LinearTrajectory(me.wobblyyyy.pathfinder2.trajectory.LinearTrajectory) Controller(me.wobblyyyy.pathfinder2.control.Controller) StringUtils(me.wobblyyyy.pathfinder2.utils.StringUtils) MultiSplineBuilder(me.wobblyyyy.pathfinder2.trajectory.spline.MultiSplineBuilder) PointXYZ(me.wobblyyyy.pathfinder2.geometry.PointXYZ) LinearTrajectory(me.wobblyyyy.pathfinder2.trajectory.LinearTrajectory) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) PointXYZ(me.wobblyyyy.pathfinder2.geometry.PointXYZ) ArcTrajectory(me.wobblyyyy.pathfinder2.trajectory.ArcTrajectory) Trajectory(me.wobblyyyy.pathfinder2.trajectory.Trajectory) MultiSegmentTrajectory(me.wobblyyyy.pathfinder2.trajectory.multi.segment.MultiSegmentTrajectory) LinearTrajectory(me.wobblyyyy.pathfinder2.trajectory.LinearTrajectory)

Example 20 with Trajectory

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);
}
Also used : PointXYZ(me.wobblyyyy.pathfinder2.geometry.PointXYZ) Trajectory(me.wobblyyyy.pathfinder2.trajectory.Trajectory)

Aggregations

Trajectory (me.wobblyyyy.pathfinder2.trajectory.Trajectory)30 PointXYZ (me.wobblyyyy.pathfinder2.geometry.PointXYZ)26 LinearTrajectory (me.wobblyyyy.pathfinder2.trajectory.LinearTrajectory)21 Trajectory (com.team254.lib_2014.trajectory.Trajectory)16 TrajectoryGenerator (com.team254.lib_2014.trajectory.TrajectoryGenerator)9 ArcTrajectory (me.wobblyyyy.pathfinder2.trajectory.ArcTrajectory)9 MultiSegmentTrajectory (me.wobblyyyy.pathfinder2.trajectory.multi.segment.MultiSegmentTrajectory)9 Path (com.team254.lib_2014.trajectory.Path)8 ArrayList (java.util.ArrayList)7 Controller (me.wobblyyyy.pathfinder2.control.Controller)5 Follower (me.wobblyyyy.pathfinder2.follower.Follower)5 Robot (me.wobblyyyy.pathfinder2.robot.Robot)5 AdvancedSplineTrajectoryBuilder (me.wobblyyyy.pathfinder2.trajectory.spline.AdvancedSplineTrajectoryBuilder)5 Test (org.junit.jupiter.api.Test)5 ElapsedTime (com.qualcomm.robotcore.util.ElapsedTime)4 GenericTurnController (me.wobblyyyy.pathfinder2.control.GenericTurnController)4 SimulatedDrive (me.wobblyyyy.pathfinder2.robot.simulated.SimulatedDrive)4 SimulatedOdometry (me.wobblyyyy.pathfinder2.robot.simulated.SimulatedOdometry)4 TaskTrajectory (me.wobblyyyy.pathfinder2.trajectory.TaskTrajectory)4 TrajectoryFollower (com.team254.lib_2014.trajectory.TrajectoryFollower)3