Search in sources :

Example 1 with LinearTrajectory

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

the class TestSimulatedChassis method testZeroPointTurn.

@Test
public void testZeroPointTurn() {
    pathfinder.followTrajectory(new LinearTrajectory(new PointXYZ(0, 0, 10), 0.5, 2, Angle.fromDeg(5)));
    pathfinder.tickUntil(500);
    assertPositionIs(new PointXYZ(0, 0, 10));
}
Also used : LinearTrajectory(me.wobblyyyy.pathfinder2.trajectory.LinearTrajectory) PointXYZ(me.wobblyyyy.pathfinder2.geometry.PointXYZ)

Example 2 with LinearTrajectory

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

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

the class TestSimulatedChassis method testRectangle.

@Test
public void testRectangle() {
    pathfinder.followTrajectories(new LinearTrajectory(new PointXYZ(0, 0, 0), 0.5, 2, Angle.fromDeg(5)), new LinearTrajectory(new PointXYZ(10, 0, 0), 0.5, 2, Angle.fromDeg(5)), new LinearTrajectory(new PointXYZ(10, 10, 0), 0.5, 2, Angle.fromDeg(5)), new LinearTrajectory(new PointXYZ(0, 10, 0), 0.5, 2, Angle.fromDeg(5)), new LinearTrajectory(new PointXYZ(0, 0, 0), 0.5, 2, Angle.fromDeg(5)));
    pathfinder.tickUntil(500);
    assertPositionIs(new PointXYZ());
}
Also used : LinearTrajectory(me.wobblyyyy.pathfinder2.trajectory.LinearTrajectory) PointXYZ(me.wobblyyyy.pathfinder2.geometry.PointXYZ)

Example 4 with LinearTrajectory

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

the class TestSimulatedChassis method testMultipleTrajectories.

@Test
public void testMultipleTrajectories() {
    pathfinder.followTrajectories(new LinearTrajectory(new PointXYZ(10, 10, 270), 0.5, 2, Angle.fromDeg(5)), new LinearTrajectory(new PointXYZ(20, 20, 360), 0.5, 2, Angle.fromDeg(5)));
    pathfinder.tickUntil(500);
    assertPositionIs(new PointXYZ(20, 20, 360));
}
Also used : LinearTrajectory(me.wobblyyyy.pathfinder2.trajectory.LinearTrajectory) PointXYZ(me.wobblyyyy.pathfinder2.geometry.PointXYZ)

Example 5 with LinearTrajectory

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

the class TestSimulatedChassis method testMovingTurn.

@Test
public void testMovingTurn() {
    pathfinder.followTrajectory(new LinearTrajectory(new PointXYZ(10, 10, 10), 0.5, 2, Angle.fromDeg(5)));
    pathfinder.tickUntil(500);
    assertPositionIs(new PointXYZ(10, 10, 10));
}
Also used : LinearTrajectory(me.wobblyyyy.pathfinder2.trajectory.LinearTrajectory) PointXYZ(me.wobblyyyy.pathfinder2.geometry.PointXYZ)

Aggregations

LinearTrajectory (me.wobblyyyy.pathfinder2.trajectory.LinearTrajectory)22 PointXYZ (me.wobblyyyy.pathfinder2.geometry.PointXYZ)21 Test (org.junit.jupiter.api.Test)9 Trajectory (me.wobblyyyy.pathfinder2.trajectory.Trajectory)7 Pathfinder (me.wobblyyyy.pathfinder2.Pathfinder)5 Controller (me.wobblyyyy.pathfinder2.control.Controller)5 Robot (me.wobblyyyy.pathfinder2.robot.Robot)5 ArrayList (java.util.ArrayList)4 GenericTurnController (me.wobblyyyy.pathfinder2.control.GenericTurnController)4 Follower (me.wobblyyyy.pathfinder2.follower.Follower)4 SimulatedDrive (me.wobblyyyy.pathfinder2.robot.simulated.SimulatedDrive)4 SimulatedOdometry (me.wobblyyyy.pathfinder2.robot.simulated.SimulatedOdometry)4 SimulatedRobot (me.wobblyyyy.pathfinder2.robot.simulated.SimulatedRobot)4 GenericFollowerGenerator (me.wobblyyyy.pathfinder2.follower.generators.GenericFollowerGenerator)3 Translation (me.wobblyyyy.pathfinder2.geometry.Translation)3 Angle (me.wobblyyyy.pathfinder2.geometry.Angle)2 ArcTrajectory (me.wobblyyyy.pathfinder2.trajectory.ArcTrajectory)2 MultiSegmentTrajectory (me.wobblyyyy.pathfinder2.trajectory.multi.segment.MultiSegmentTrajectory)2 List (java.util.List)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1