Search in sources :

Example 36 with Trajectory

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());
}
Also used : LinearTrajectoryBuilder(me.wobblyyyy.pathfinder2.trajectory.builder.LinearTrajectoryBuilder) MultiSegmentTrajectory(me.wobblyyyy.pathfinder2.trajectory.multi.segment.MultiSegmentTrajectory) 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 37 with Trajectory

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));
}
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 38 with Trajectory

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());
}
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 39 with Trajectory

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

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);
}
Also used : ElapsedTimer(me.wobblyyyy.pathfinder2.time.ElapsedTimer) Test(org.junit.jupiter.api.Test)

Aggregations

PointXYZ (me.wobblyyyy.pathfinder2.geometry.PointXYZ)41 Trajectory (me.wobblyyyy.pathfinder2.trajectory.Trajectory)30 LinearTrajectory (me.wobblyyyy.pathfinder2.trajectory.LinearTrajectory)24 Trajectory (com.team254.lib_2014.trajectory.Trajectory)16 MultiSegmentTrajectory (me.wobblyyyy.pathfinder2.trajectory.multi.segment.MultiSegmentTrajectory)11 Test (org.junit.jupiter.api.Test)11 TrajectoryGenerator (com.team254.lib_2014.trajectory.TrajectoryGenerator)9 ArcTrajectory (me.wobblyyyy.pathfinder2.trajectory.ArcTrajectory)9 Path (com.team254.lib_2014.trajectory.Path)7 ArrayList (java.util.ArrayList)6 Pathfinder (me.wobblyyyy.pathfinder2.Pathfinder)6 Controller (me.wobblyyyy.pathfinder2.control.Controller)5 Follower (me.wobblyyyy.pathfinder2.follower.Follower)5 Angle (me.wobblyyyy.pathfinder2.geometry.Angle)5 Robot (me.wobblyyyy.pathfinder2.robot.Robot)5 ElapsedTimer (me.wobblyyyy.pathfinder2.time.ElapsedTimer)5 AdvancedSplineTrajectoryBuilder (me.wobblyyyy.pathfinder2.trajectory.spline.AdvancedSplineTrajectoryBuilder)5 GenericTurnController (me.wobblyyyy.pathfinder2.control.GenericTurnController)4 Translation (me.wobblyyyy.pathfinder2.geometry.Translation)4 SimulatedDrive (me.wobblyyyy.pathfinder2.robot.simulated.SimulatedDrive)4