Pathfinder2

Paths, trajectories, splines, the number 2, and a whole lot of swag.

GPL-3.0 License

Stars
13
Committers
2

This project is no longer actively being developed. If anyone is interested in continuing the development of this project, please let me know!

I'd be happy to help you with using this project. You can reach me through Discord (wobblyyyy#6733) or e-mail ([email protected]).

Pathfinder2 is a continuation of the original Pathfinder library: a streamlined motion planning and control system designed for FIRST events, such as the FIRST Robotics Competition and the FIRST Tech Challenge.

  • Track the position of a wheeled mobile robot using a variety of odometry
    implementations.
  • Dynamically correct for movement error and drift.
  • Plan complex routes using the
    Trajectory
    system. Follow splines, arcs, lines, equations, the little green light at
    the end of the tunnel - whatever you want, it's really up to you.
  • Full-featured geometry package with polygon collision detection, several
    shapes, lines, points, and angles.
  • Map gamepad events (button press, trigger press, joystick move, etc) to
    Runnables, making it easy to create listeners.
  • Incredibly customizable: much of Pathfinder is based on interfaces and
    there's a plugin system for advance usages.
  • Potentially the coolest piece of code ever written. I don't have any
    evidence to support that, but we're all about swag here.

NEW DOCUMENTATION:

Pathfinder has improved documentation available in the docs directory.

OLD DOCUMENTATION:

Want to get started? Check out the releases guide to get everything installed, and then head over to the documentation portal.

Pathfinder handles everything related to your robot's movement. It abstracts away much of the tedious movement-related code many robot codebases are bogged down with and allows you to focus on what else your robot can do. In addition to providing a robust interface for precisely controlling your robot's movement, Pathfinder provides a wide array of robotics-related utilities and tools.

Want your robot to move to a certain point on the field? Simple:

pathfinder.goTo(new PointXY(10, 15));

PointXY is a simple Cartesian coordinate with X and Y values. Now let's say you want to make your robot move to the same point, but turn to 45 degrees.

// method 1
pathfinder.goTo(new PointXYZ(10, 15, Angle.fromDeg(45)));

// method 2
pathfinder.goToZ(Angle.fromDeg(45));

Pathfinder is capable of significantly more than simple movement - splines, motion profiling, recording and playback - the list goes on.

Check out an example FRC project here!

Here's a demonstration of Pathfinder's utilization of lambda expressions to write simple and readable code.

pathfinder
    .setSpeed(0.5)
    .setTolerance(2)
    .setAngleTolerance(Angle.fixedDeg(5))
    .splineTo(
        new PointXYZ(10, 10, Angle.fixedDeg(90)),
        new PointXYZ(20, 30, Angle.fixedDeg(45)),
        new PointXYZ(30, 50, Angle.fixedDeg(180))
    )
    .tickUntil();

pathfinder.getListenerManager()
    .bindButton(gampad::a, (isPressed) -> {
        // code to be executed whenever the A button is pressed
    })
    .bindButton(gamepad::b, (isPressed) -> {
        // code to be executed whenever the B button is pressed
    })
    .bind(new ListenerBuilder()
        .setMode(ListenerMode.CONDITION_IS_MET)
        .addInput(() -> SupplierFilter.anyTrue(
            () -> gamepad.rightTrigger() > 0,
            () -> gamepad.leftTrigger() > 0
        ))
        .setWhenTriggered(() -> {
            // code to be executed whenever either trigger is pressed
        })
        .setPriority(10)
        .setExpiration(Double.MAX_VALUE),
        .setMaximumExecutions(Double.MAX_VALUE)
    );

// whenever pathfinder is "ticked" (updated, basically), set the robot's
// translation to whatever the driver's controller outputs
pathfinder.onTick(() -> {
    pathfinder.setTranslation(new Translation(
        gamepad.leftStickX(),
        gamepad.leftStickY(),
        gamepad.rightStickX()
    ));
});

while (true) {
    // tick pathfinder forever
    pathfinder.tick();
}

Installation instructions have been moved here.

Here's all of the sources of documentation I can think of right now.

  • Documentation portal -
    the hub for documentation for this library.
  • Project tutorial - this is a basic tutorial
    that walks through the fundamentals of the library. This is probably the best
    place to start getting acquainted with the library.
  • Examples - several example usages of the project. Each
    of the classes contained in this module will contain more specific
    documentation explaining what the example is demonstrating.
  • JavaDoc - JavaDoc
    for the Pathfinder2 library. This is the most fine-grained documentation, and I'd
    encourage you to check this out once you're comfortable with the library.
  • Video guides - (not yet available) video guides on using
    the library. Who doesn't love videos? Right? Right.
  • Project releases - a guide on all of the available
    releases of Pathfinder.

This project uses the GNU GPL V3. You're allowed to freely distribute and modify the code contained in this project, so long as a copy of the original license is provided, and all of your code is made open-source.