Search in sources :

Example 6 with PointXYZ

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

the class TestTrajectoryCommands method testLinearTrajectory.

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

Example 7 with PointXYZ

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

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

the class GenericTrajectoryBenchmarker method followTrajectories.

public void followTrajectories(Blackhole blackhole, Trajectory... trajectories) {
    SimulatedRobot robot = new SimulatedRobot();
    Pathfinder pathfinder = new Pathfinder(robot, -0.05);
    PointXYZ lastPosition = PointXYZ.ZERO;
    double distance = 0;
    for (Trajectory trajectory : trajectories) {
        robot.setPosition(PointXYZ.ZERO);
        pathfinder.followTrajectory(trajectory);
        while (distance < 10) {
            pathfinder.tick();
            distance += pathfinder.getPosition().absDistance(lastPosition);
        }
    }
}
Also used : Pathfinder(me.wobblyyyy.pathfinder2.Pathfinder) SimulatedRobot(me.wobblyyyy.pathfinder2.robot.simulated.SimulatedRobot) PointXYZ(me.wobblyyyy.pathfinder2.geometry.PointXYZ)

Example 9 with PointXYZ

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

the class TestCommandRegistry method testParseManyLines.

@Test
public void testParseManyLines() {
    Assertions.assertFalse(pathfinder.isActive());
    String[] lines = new String[] { "def a 0,0,0", "def b 5,10,0", "def c 10,20,0", "def d 15,25,0", "def e 20,30,0", "splineTo $a\\", "$b\\", "$c\\", "$d\\", "$e", "tickUntil" };
    registry.parse(lines);
    AssertionUtils.assertIsNear(new PointXYZ(20, 30, 0), pathfinder.getPosition(), 2, Angle.fromDeg(5));
}
Also used : PointXYZ(me.wobblyyyy.pathfinder2.geometry.PointXYZ) Test(org.junit.jupiter.api.Test)

Example 10 with PointXYZ

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

the class DifferentialDriveOdometry method update.

/**
 * Update the robot's position. After updating the position, return the
 * newly-updated position.
 *
 * @param gyroAngle     the angle of the gyroscope.
 * @param rightDistance the distance of the right encoder. This should
 *                      NOT be the "elapsed distance," or distance since
 *                      the last update: rather, this should be the
 *                      encoder's distance, in total.
 * @param leftDistance  the distance of the left encoder.
 *                      NOT be the "elapsed distance," or distance since
 *                      the last update: rather, this should be the
 *                      encoder's distance, in total.
 * @return the robot's updated posititon.
 */
public PointXYZ update(Angle gyroAngle, double rightDistance, double leftDistance) {
    double deltaRight = rightDistance - previousRightDistance;
    double deltaLeft = leftDistance - previousLeftDistance;
    previousRightDistance = rightDistance;
    previousLeftDistance = leftDistance;
    double averageDelta = Average.of(deltaRight, deltaLeft);
    Angle angle = gyroAngle.add(gyroOffset);
    PointXYZ newPosition = position.applyTranslation(new Translation(0.0, averageDelta, angle.subtract(previousAngle).deg()));
    previousAngle = angle;
    position = newPosition.withZ(angle);
    return position;
}
Also used : Translation(me.wobblyyyy.pathfinder2.geometry.Translation) Angle(me.wobblyyyy.pathfinder2.geometry.Angle) PointXYZ(me.wobblyyyy.pathfinder2.geometry.PointXYZ)

Aggregations

PointXYZ (me.wobblyyyy.pathfinder2.geometry.PointXYZ)103 Test (org.junit.jupiter.api.Test)34 LinearTrajectory (me.wobblyyyy.pathfinder2.trajectory.LinearTrajectory)33 Trajectory (me.wobblyyyy.pathfinder2.trajectory.Trajectory)27 Angle (me.wobblyyyy.pathfinder2.geometry.Angle)22 Translation (me.wobblyyyy.pathfinder2.geometry.Translation)13 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