Search in sources :

Example 1 with LinearTrajectoryBuilder

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

the class LinearTrajectoryBuilder method goTo.

/**
 * Go to a specific point.
 *
 * @param target the target point.
 */
public LinearTrajectoryBuilder goTo(PointXYZ target) {
    trajectories.add(new LinearTrajectory(target, speed, tolerance, angleTolerance));
    last = target;
    return this;
}
Also used : LinearTrajectory(me.wobblyyyy.pathfinder2.trajectory.LinearTrajectory)

Example 2 with LinearTrajectoryBuilder

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

the class ExamplePathfinder method betterGoToSomePoints.

public void betterGoToSomePoints() {
    // generate a list of trajectories w/ LinearTrajectoryBuilder
    // the setSpeed method is used to dynamically adjust the speed of
    // the robot - for example, the speed is halved, then the speed
    // is reset, then the speed is doubled
    List<Trajectory> trajectories = new LinearTrajectoryBuilder(SPEED, TOLERANCE, ANGLE_TOLERANCE, PointXYZ.ZERO).goTo(new PointXYZ(0, 0, 0)).goTo(new PointXYZ(10, 0, 0)).setSpeed(SPEED / 2).goTo(new PointXYZ(10, 10, 0)).setSpeed(SPEED).goTo(new PointXYZ(0, 10, 0)).setSpeed(SPEED * 2).goTo(new PointXYZ(0, 0, 0)).getTrajectories();
    // follow the trajectories with a timeout of 10 seconds. if more than
    // 10 seconds pass and the trajectories haven't finished yet, stop
    // following the trajectories
    pathfinder.followTrajectories(trajectories).tickUntil(10_000);
}
Also used : LinearTrajectoryBuilder(me.wobblyyyy.pathfinder2.trajectory.builder.LinearTrajectoryBuilder) Trajectory(me.wobblyyyy.pathfinder2.trajectory.Trajectory) PointXYZ(me.wobblyyyy.pathfinder2.geometry.PointXYZ)

Example 3 with LinearTrajectoryBuilder

use of me.wobblyyyy.pathfinder2.trajectory.builder.LinearTrajectoryBuilder 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 4 with LinearTrajectoryBuilder

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

the class LinearTrajectoryBuilder method rotateLine.

/**
 * Move in a line and rotate to a specified heading.
 *
 * @param distance    the distance from the current point that the new
 *                    point should be drawn at.
 * @param targetAngle the angle the trajectory should attempt to turn to.
 * @param angle       the angle at which the line should be drawn.
 */
public LinearTrajectoryBuilder rotateLine(double distance, Angle targetAngle, Angle angle) {
    PointXYZ next = last.inDirection(distance, angle);
    trajectories.add(new LinearTrajectory(next.withHeading(targetAngle), speed, tolerance, angleTolerance));
    last = next;
    return this;
}
Also used : LinearTrajectory(me.wobblyyyy.pathfinder2.trajectory.LinearTrajectory) PointXYZ(me.wobblyyyy.pathfinder2.geometry.PointXYZ)

Aggregations

PointXYZ (me.wobblyyyy.pathfinder2.geometry.PointXYZ)3 LinearTrajectory (me.wobblyyyy.pathfinder2.trajectory.LinearTrajectory)3 Trajectory (me.wobblyyyy.pathfinder2.trajectory.Trajectory)2 LinearTrajectoryBuilder (me.wobblyyyy.pathfinder2.trajectory.builder.LinearTrajectoryBuilder)2 ArcTrajectory (me.wobblyyyy.pathfinder2.trajectory.ArcTrajectory)1 MultiSegmentTrajectory (me.wobblyyyy.pathfinder2.trajectory.multi.segment.MultiSegmentTrajectory)1