Search in sources :

Example 1 with ProportionalController

use of me.wobblyyyy.pathfinder2.control.ProportionalController 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 ProportionalController

use of me.wobblyyyy.pathfinder2.control.ProportionalController 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 ProportionalController

use of me.wobblyyyy.pathfinder2.control.ProportionalController 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)

Aggregations

ProportionalController (me.wobblyyyy.pathfinder2.control.ProportionalController)3 Pathfinder (me.wobblyyyy.pathfinder2.Pathfinder)2 SplineBuilderFactory (me.wobblyyyy.pathfinder2.trajectory.spline.SplineBuilderFactory)2 HashMap (java.util.HashMap)1 Controller (me.wobblyyyy.pathfinder2.control.Controller)1 Shifter (me.wobblyyyy.pathfinder2.utils.Shifter)1