Search in sources :

Example 1 with PointXYZ

use of me.wobblyyyy.pathfinder2.geometry.PointXYZ in project Pathfinder2 by Wobblyyyy.

the class TestSimulatedChassis method testRightTurn.

@Test
public void testRightTurn() {
    pathfinder.goTo(new PointXYZ(5, 5, 90)).tickUntil(500);
    assertPositionIs(new PointXYZ(5, 5, 90));
    odometry.setTranslation(new Translation(1, 0, 0));
    odometry.updatePositionBasedOnVelocity(500);
    odometry.setTranslation(new Translation(-1, 0, 0));
    odometry.updatePositionBasedOnVelocity(500);
    odometry.setTranslation(new Translation(1, 1, 0));
    odometry.updatePositionBasedOnVelocity(500);
    odometry.setTranslation(new Translation(-1, -1, 0));
    odometry.updatePositionBasedOnVelocity(500);
    Assertions.assertTrue(pathfinder.getPosition().absDistance(new PointXYZ(5, 5, 90)) < 2);
}
Also used : Translation(me.wobblyyyy.pathfinder2.geometry.Translation) PointXYZ(me.wobblyyyy.pathfinder2.geometry.PointXYZ)

Example 2 with PointXYZ

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

use of me.wobblyyyy.pathfinder2.geometry.PointXYZ 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 4 with PointXYZ

use of me.wobblyyyy.pathfinder2.geometry.PointXYZ 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 5 with PointXYZ

use of me.wobblyyyy.pathfinder2.geometry.PointXYZ 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)

Aggregations

PointXYZ (me.wobblyyyy.pathfinder2.geometry.PointXYZ)99 LinearTrajectory (me.wobblyyyy.pathfinder2.trajectory.LinearTrajectory)33 Test (org.junit.jupiter.api.Test)32 Trajectory (me.wobblyyyy.pathfinder2.trajectory.Trajectory)27 Angle (me.wobblyyyy.pathfinder2.geometry.Angle)19 Translation (me.wobblyyyy.pathfinder2.geometry.Translation)12 MultiSegmentTrajectory (me.wobblyyyy.pathfinder2.trajectory.multi.segment.MultiSegmentTrajectory)11 ArcTrajectory (me.wobblyyyy.pathfinder2.trajectory.ArcTrajectory)10 ArrayList (java.util.ArrayList)8 Pathfinder (me.wobblyyyy.pathfinder2.Pathfinder)8 Controller (me.wobblyyyy.pathfinder2.control.Controller)5 Robot (me.wobblyyyy.pathfinder2.robot.Robot)5 SimulatedOdometry (me.wobblyyyy.pathfinder2.robot.simulated.SimulatedOdometry)5 AdvancedSplineTrajectoryBuilder (me.wobblyyyy.pathfinder2.trajectory.spline.AdvancedSplineTrajectoryBuilder)5 GenericTurnController (me.wobblyyyy.pathfinder2.control.GenericTurnController)4 Follower (me.wobblyyyy.pathfinder2.follower.Follower)4 PointXY (me.wobblyyyy.pathfinder2.geometry.PointXY)4 SimulatedDrive (me.wobblyyyy.pathfinder2.robot.simulated.SimulatedDrive)4 SimulatedRobot (me.wobblyyyy.pathfinder2.robot.simulated.SimulatedRobot)4 ElapsedTimer (me.wobblyyyy.pathfinder2.time.ElapsedTimer)4