Search in sources :

Example 1 with FastTrajectory

use of me.wobblyyyy.pathfinder2.trajectory.FastTrajectory in project Pathfinder2 by Wobblyyyy.

the class TestTrajectoryCommands method testFastTrajectoryWithAutoInitial.

@Test
public void testFastTrajectoryWithAutoInitial() {
    registry.execute("fastTrajectory", "10,10,45deg", "0.5");
    registry.execute("tickUntil");
    AssertionUtils.assertIsNear(new PointXYZ(10, 10, 0), pathfinder.getPosition(), 2, Angle.fromDeg(360));
}
Also used : PointXYZ(me.wobblyyyy.pathfinder2.geometry.PointXYZ) Test(org.junit.jupiter.api.Test)

Example 2 with FastTrajectory

use of me.wobblyyyy.pathfinder2.trajectory.FastTrajectory 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 3 with FastTrajectory

use of me.wobblyyyy.pathfinder2.trajectory.FastTrajectory in project Pathfinder2 by Wobblyyyy.

the class TestFastTrajectory method testThrowsExceptions.

@Test
public void testThrowsExceptions() {
    Assertions.assertThrows(NullPointException.class, () -> {
        new FastTrajectory(null, new PointXYZ(), 0.5);
    });
    Assertions.assertThrows(NullPointException.class, () -> {
        new FastTrajectory(new PointXYZ(), null, 0.5);
    });
    Assertions.assertThrows(InvalidSpeedException.class, () -> {
        new FastTrajectory(new PointXYZ(), new PointXYZ(), -100);
    });
    Assertions.assertThrows(InvalidSpeedException.class, () -> {
        new FastTrajectory(new PointXYZ(), new PointXYZ(), 200);
    });
}
Also used : PointXYZ(me.wobblyyyy.pathfinder2.geometry.PointXYZ) Test(org.junit.jupiter.api.Test)

Example 4 with FastTrajectory

use of me.wobblyyyy.pathfinder2.trajectory.FastTrajectory in project Pathfinder2 by Wobblyyyy.

the class TestTrajectoryCommands method testFastTrajectoryWithoutAutoInitial.

@Test
public void testFastTrajectoryWithoutAutoInitial() {
    registry.execute("fastTrajectory", "0,0,0", "10,10,45deg", "0.5");
    registry.execute("tickUntil");
    AssertionUtils.assertIsNear(new PointXYZ(10, 10, 0), pathfinder.getPosition(), 2, Angle.fromDeg(360));
}
Also used : PointXYZ(me.wobblyyyy.pathfinder2.geometry.PointXYZ) Test(org.junit.jupiter.api.Test)

Example 5 with FastTrajectory

use of me.wobblyyyy.pathfinder2.trajectory.FastTrajectory in project Pathfinder2 by Wobblyyyy.

the class TrajectoryBuilder method fastTo.

public TrajectoryBuilder fastTo(PointXYZ target, double speed) {
    if (lastPoint == null) {
        throw new NullPointException("Must use the setStartPos method before creating a fast " + "trajectory to a target! This position should be " + "the robot's starting position.");
    }
    trajectories.add(new FastTrajectory(lastPoint, target, speed));
    lastPoint = target;
    return this;
}
Also used : FastTrajectory(me.wobblyyyy.pathfinder2.trajectory.FastTrajectory) NullPointException(me.wobblyyyy.pathfinder2.exceptions.NullPointException)

Aggregations

PointXYZ (me.wobblyyyy.pathfinder2.geometry.PointXYZ)5 FastTrajectory (me.wobblyyyy.pathfinder2.trajectory.FastTrajectory)3 Test (org.junit.jupiter.api.Test)3 ArrayList (java.util.ArrayList)2 LinearTrajectory (me.wobblyyyy.pathfinder2.trajectory.LinearTrajectory)2 Trajectory (me.wobblyyyy.pathfinder2.trajectory.Trajectory)2 NullPointException (me.wobblyyyy.pathfinder2.exceptions.NullPointException)1