Search in sources :

Example 1 with Controller

use of me.wobblyyyy.pathfinder2.control.Controller in project Grupo5Cine by Diroro14.

the class Main method cargar.

private static void cargar() throws IOException {
    InputStream is = new FileInputStream(new File(_inFile));
    Controller controller = new Controller();
    controller.load(is);
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Controller(control.Controller) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 2 with Controller

use of me.wobblyyyy.pathfinder2.control.Controller in project Pathfinder2 by Wobblyyyy.

the class TestControlledTrajectory method testSingleController.

private void testSingleController(Controller controller, PointXYZ target, double tolerance, Angle angleTolerance) {
    PointXYZ origin = pathfinder.getPosition();
    Trajectory toTarget = new ControlledTrajectory(target, controller, tolerance, angleTolerance);
    Trajectory toOrigin = new ControlledTrajectory(origin, controller, tolerance, angleTolerance);
    follow(toTarget, target);
    follow(toOrigin, origin);
}
Also used : PointXYZ(me.wobblyyyy.pathfinder2.geometry.PointXYZ)

Example 3 with Controller

use of me.wobblyyyy.pathfinder2.control.Controller in project Pathfinder2 by Wobblyyyy.

the class ExampleTimedRobot method robotInit.

@Override
public void robotInit() {
    // initialize everything. if this was a real implementation, you would
    // not want to use SimulatedDrive or SimulatedOdometry
    drive = new SimulatedDrive();
    odometry = new SimulatedOdometry();
    robot = new Robot(drive, odometry);
    pathfinder = new Pathfinder(robot, controller).setSpeed(0.5).setTolerance(2).setAngleTolerance(Angle.fromDeg(5));
}
Also used : Pathfinder(me.wobblyyyy.pathfinder2.Pathfinder) SimulatedDrive(me.wobblyyyy.pathfinder2.robot.simulated.SimulatedDrive) SimulatedOdometry(me.wobblyyyy.pathfinder2.robot.simulated.SimulatedOdometry) TimedRobot(edu.wpi.first.wpilibj.TimedRobot) Robot(me.wobblyyyy.pathfinder2.robot.Robot)

Example 4 with Controller

use of me.wobblyyyy.pathfinder2.control.Controller in project Pathfinder2 by Wobblyyyy.

the class ExampleElevator method exampleShifterElevator.

public void exampleShifterElevator() {
    Pathfinder pathfinder = Pathfinder.newSimulatedPathfinder(0.01);
    Map<Integer, Integer> levels = new HashMap<Integer, Integer>() {

        {
            put(1, 100);
            put(2, 200);
            put(3, 300);
            put(4, 400);
            put(5, 500);
        }
    };
    Controller controller = new ProportionalController(0.001);
    Shifter shifter = new Shifter(1, 1, 5, false, gear -> {
        int target = levels.get(gear);
        controller.setTarget(target);
    });
    pathfinder.getListenerManager().bind(ListenerMode.CONDITION_NEWLY_MET, this::aButton, b -> b, b -> shifter.shift(ShifterDirection.UP));
    pathfinder.getListenerManager().bind(ListenerMode.CONDITION_NEWLY_MET, this::bButton, b -> b, b -> shifter.shift(ShifterDirection.DOWN));
    pathfinder.onTick(pf -> {
        int elevatorPosition = getPosition();
        double elevatorPower = controller.calculate(elevatorPosition);
        setElevatorPower(elevatorPower);
    });
}
Also used : Pathfinder(me.wobblyyyy.pathfinder2.Pathfinder) HashMap(java.util.HashMap) Shifter(me.wobblyyyy.pathfinder2.utils.Shifter) ProportionalController(me.wobblyyyy.pathfinder2.control.ProportionalController) Controller(me.wobblyyyy.pathfinder2.control.Controller) ProportionalController(me.wobblyyyy.pathfinder2.control.ProportionalController)

Example 5 with Controller

use of me.wobblyyyy.pathfinder2.control.Controller in project Pathfinder2 by Wobblyyyy.

the class Pathfinder method newEmptyPathfinder.

/**
 * Create a new, "empty" instance of Pathfinder.
 *
 * <p>
 * This is pretty much only useful for debugging or testing purposes.
 * </p>
 *
 * @param coefficient the coefficient to use for the turn controller.
 * @return a new instance of Pathfinder that makes use of both the
 * {@link EmptyDrive} and {@link EmptyOdometry} classes.
 */
public static Pathfinder newEmptyPathfinder(double coefficient) {
    Drive drive = new EmptyDrive();
    Odometry odometry = new EmptyOdometry();
    Robot robot = new Robot(drive, odometry);
    return new Pathfinder(robot, coefficient);
}
Also used : EmptyOdometry(me.wobblyyyy.pathfinder2.robot.simulated.EmptyOdometry) Drive(me.wobblyyyy.pathfinder2.robot.Drive) EmptyDrive(me.wobblyyyy.pathfinder2.robot.simulated.EmptyDrive) SimulatedDrive(me.wobblyyyy.pathfinder2.robot.simulated.SimulatedDrive) EmptyOdometry(me.wobblyyyy.pathfinder2.robot.simulated.EmptyOdometry) Odometry(me.wobblyyyy.pathfinder2.robot.Odometry) SimulatedOdometry(me.wobblyyyy.pathfinder2.robot.simulated.SimulatedOdometry) Robot(me.wobblyyyy.pathfinder2.robot.Robot) SimulatedRobot(me.wobblyyyy.pathfinder2.robot.simulated.SimulatedRobot) EmptyDrive(me.wobblyyyy.pathfinder2.robot.simulated.EmptyDrive)

Aggregations

PointXYZ (me.wobblyyyy.pathfinder2.geometry.PointXYZ)6 Robot (me.wobblyyyy.pathfinder2.robot.Robot)6 SimulatedDrive (me.wobblyyyy.pathfinder2.robot.simulated.SimulatedDrive)6 SimulatedOdometry (me.wobblyyyy.pathfinder2.robot.simulated.SimulatedOdometry)6 Controller (me.wobblyyyy.pathfinder2.control.Controller)5 GenericTurnController (me.wobblyyyy.pathfinder2.control.GenericTurnController)4 Follower (me.wobblyyyy.pathfinder2.follower.Follower)4 LinearTrajectory (me.wobblyyyy.pathfinder2.trajectory.LinearTrajectory)4 Trajectory (me.wobblyyyy.pathfinder2.trajectory.Trajectory)4 Test (org.junit.jupiter.api.Test)4 ArrayList (java.util.ArrayList)3 GenericFollowerGenerator (me.wobblyyyy.pathfinder2.follower.generators.GenericFollowerGenerator)3 Pathfinder (me.wobblyyyy.pathfinder2.Pathfinder)2 Controller (control.Controller)1 TimedRobot (edu.wpi.first.wpilibj.TimedRobot)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 HashMap (java.util.HashMap)1 ProportionalController (me.wobblyyyy.pathfinder2.control.ProportionalController)1