Search in sources :

Example 56 with Trajectory

use of me.wobblyyyy.pathfinder2.trajectory.Trajectory 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)

Example 57 with Trajectory

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

the class TrajectoryBuilder method fastTo.

public TrajectoryBuilder fastTo(PointXYZ target, double speed) {
    if (lastPoint == null) {
        throw new NullPointException("Must use the setStartPos method before creating a fast " + "trajectory to a target! This position should be " + "the robot's starting position.");
    }
    trajectories.add(new FastTrajectory(lastPoint, target, speed));
    lastPoint = target;
    return this;
}
Also used : FastTrajectory(me.wobblyyyy.pathfinder2.trajectory.FastTrajectory) NullPointException(me.wobblyyyy.pathfinder2.exceptions.NullPointException)

Example 58 with Trajectory

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

the class CircleSurrounder method surround.

/**
 * Surround the circle. This will find the closest point, create a new
 * {@link me.wobblyyyy.pathfinder2.trajectory.LinearTrajectory} to that
 * point, and then instruct Pathfinder to follow it.
 */
public void surround() {
    PointXYZ robotPosition = pathfinder.getPosition();
    double speed = pathfinder.getSpeed();
    double tolerance = pathfinder.getTolerance();
    Angle angleTolerance = pathfinder.getAngleTolerance();
    Trajectory trajectory = CircleSurround.trajectoryToClosestPoint(robotPosition, center, radius, speed, tolerance, angleTolerance);
    pathfinder.followTrajectory(trajectory);
}
Also used : Angle(me.wobblyyyy.pathfinder2.geometry.Angle) PointXYZ(me.wobblyyyy.pathfinder2.geometry.PointXYZ) Trajectory(me.wobblyyyy.pathfinder2.trajectory.Trajectory)

Example 59 with Trajectory

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

the class CircleSurrounder method fastSurround.

/**
 * Surround the circle. This will find the closest point, create a new
 * {@link me.wobblyyyy.pathfinder2.trajectory.FastTrajectory} to that
 * point, and then instruct Pathfinder to follow it.
 */
public void fastSurround() {
    PointXYZ robotPosition = pathfinder.getPosition();
    double speed = pathfinder.getSpeed();
    double tolerance = pathfinder.getTolerance();
    Angle angleTolerance = pathfinder.getAngleTolerance();
    Trajectory trajectory = CircleSurround.fastTrajectoryToClosestPoint(robotPosition, center, radius, speed);
    pathfinder.followTrajectory(trajectory);
}
Also used : Angle(me.wobblyyyy.pathfinder2.geometry.Angle) PointXYZ(me.wobblyyyy.pathfinder2.geometry.PointXYZ) Trajectory(me.wobblyyyy.pathfinder2.trajectory.Trajectory)

Example 60 with Trajectory

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

the class PathBuilder method fastPath.

public List<Trajectory> fastPath(PointXYZ start, double speed) {
    List<Trajectory> trajectories = new ArrayList<>(targets.size());
    PointXYZ previousPoint = start;
    for (PointXYZ target : targets) {
        trajectories.add(new FastTrajectory(previousPoint, target, speed));
        previousPoint = target;
    }
    return trajectories;
}
Also used : FastTrajectory(me.wobblyyyy.pathfinder2.trajectory.FastTrajectory) ArrayList(java.util.ArrayList) FastTrajectory(me.wobblyyyy.pathfinder2.trajectory.FastTrajectory) LinearTrajectory(me.wobblyyyy.pathfinder2.trajectory.LinearTrajectory) Trajectory(me.wobblyyyy.pathfinder2.trajectory.Trajectory) PointXYZ(me.wobblyyyy.pathfinder2.geometry.PointXYZ)

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