Search in sources :

Example 1 with Robot

use of me.wobblyyyy.pathfinder2.robot.Robot in project Pathfinder2 by Wobblyyyy.

the class TestSimulatedChassis method beforeEach.

@BeforeEach
public void beforeEach() {
    wrapper = new SimulatedWrapper(new SimulatedDrive(), new SimulatedOdometry());
    odometry = wrapper.getOdometry();
    robot = wrapper.getRobot();
    turnController = new ProportionalController(-0.05);
    pathfinder = new Pathfinder(robot, turnController).setSpeed(0.5).setTolerance(DEFAULT_TOLERANCE).setAngleTolerance(Angle.fromDeg(5));
    factory = new SplineBuilderFactory().setSpeed(0.5).setStep(0.1).setTolerance(DEFAULT_TOLERANCE).setAngleTolerance(Angle.fromDeg(5));
}
Also used : Pathfinder(me.wobblyyyy.pathfinder2.Pathfinder) SplineBuilderFactory(me.wobblyyyy.pathfinder2.trajectory.spline.SplineBuilderFactory) ProportionalController(me.wobblyyyy.pathfinder2.control.ProportionalController)

Example 2 with Robot

use of me.wobblyyyy.pathfinder2.robot.Robot in project Pathfinder2 by Wobblyyyy.

the class GenericTrajectoryTester method beforeEach.

@BeforeEach
public void beforeEach() {
    wrapper = new SimulatedWrapper(new SimulatedDrive(), new SimulatedOdometry());
    odometry = wrapper.getOdometry();
    robot = wrapper.getRobot();
    turnController = new ProportionalController(turnCoefficient);
    pathfinder = new Pathfinder(robot, turnController).setSpeed(speed).setTolerance(tolerance).setAngleTolerance(angleTolerance);
    factory = new SplineBuilderFactory().setSpeed(speed).setStep(step).setTolerance(tolerance).setAngleTolerance(angleTolerance);
}
Also used : SplineBuilderFactory(me.wobblyyyy.pathfinder2.trajectory.spline.SplineBuilderFactory) ProportionalController(me.wobblyyyy.pathfinder2.control.ProportionalController)

Example 3 with Robot

use of me.wobblyyyy.pathfinder2.robot.Robot in project Pathfinder2 by Wobblyyyy.

the class ExamplePathfinder method goToSomePoints.

/**
 * Go to a series of points. This method is blocking, meaning its execution
 * takes a variable amount of time to execute, and, in some cases,
 * nearly impossible. A method like this would have good use in the
 * Autonomous period of FTC/FRC games, because it's the only thing the robot
 * has to do, but wouldn't be so great for the teleop periods.
 */
@SuppressWarnings("DuplicatedCode")
public void goToSomePoints() {
    // this is a pretty bad way of going to the points...
    List<PointXYZ> points = new ArrayList<PointXYZ>() {

        {
            add(new PointXYZ(0, 0, 0));
            add(new PointXYZ(10, 0, 0));
            add(new PointXYZ(10, 10, 0));
            add(new PointXYZ(0, 10, 0));
            add(new PointXYZ(0, 0, 0));
        }
    };
    for (PointXYZ point : points) {
        goToPoint(point);
    }
}
Also used : ArrayList(java.util.ArrayList) PointXYZ(me.wobblyyyy.pathfinder2.geometry.PointXYZ)

Example 4 with Robot

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

use of me.wobblyyyy.pathfinder2.robot.Robot in project Pathfinder2 by Wobblyyyy.

the class ExampleTimedRobot method autonomousInit.

@Override
public void autonomousInit() {
    // clear it, just in case there's already a trajectory
    pathfinder.clear();
    // make the robot follow a spline: all we have to do now is tick it!
    pathfinder.splineTo(new PointXYZ(0, 0, 0), new PointXYZ(10, 0, 0), new PointXYZ(10, 10, 0), new PointXYZ(0, 10, 0), new PointXYZ(0, 0, 0));
}
Also used : PointXYZ(me.wobblyyyy.pathfinder2.geometry.PointXYZ)

Aggregations

PointXYZ (me.wobblyyyy.pathfinder2.geometry.PointXYZ)14 Trajectory (me.wobblyyyy.pathfinder2.trajectory.Trajectory)9 Robot (me.wobblyyyy.pathfinder2.robot.Robot)7 SimulatedDrive (me.wobblyyyy.pathfinder2.robot.simulated.SimulatedDrive)7 SimulatedOdometry (me.wobblyyyy.pathfinder2.robot.simulated.SimulatedOdometry)7 LinearTrajectory (me.wobblyyyy.pathfinder2.trajectory.LinearTrajectory)7 ArrayList (java.util.ArrayList)5 Pathfinder (me.wobblyyyy.pathfinder2.Pathfinder)5 Follower (me.wobblyyyy.pathfinder2.follower.Follower)5 Translation (me.wobblyyyy.pathfinder2.geometry.Translation)5 Controller (me.wobblyyyy.pathfinder2.control.Controller)4 GenericTurnController (me.wobblyyyy.pathfinder2.control.GenericTurnController)4 Angle (me.wobblyyyy.pathfinder2.geometry.Angle)4 Test (org.junit.jupiter.api.Test)4 GenericFollowerGenerator (me.wobblyyyy.pathfinder2.follower.generators.GenericFollowerGenerator)3 TaskTrajectory (me.wobblyyyy.pathfinder2.trajectory.TaskTrajectory)3 SplineBuilderFactory (me.wobblyyyy.pathfinder2.trajectory.spline.SplineBuilderFactory)3 ProportionalController (me.wobblyyyy.pathfinder2.control.ProportionalController)2 NullPointException (me.wobblyyyy.pathfinder2.exceptions.NullPointException)2 SimulatedRobot (me.wobblyyyy.pathfinder2.robot.simulated.SimulatedRobot)2