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;
}
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);
}
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());
}
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;
}
Aggregations