Skip to content

driveWithController command #20

@haydenheroux

Description

@haydenheroux

Currently, binding a controller to the drive's drive command takes the form of drive.drive(() -> speedsFromController(controller)). This is because drive is a function of supplied ChassisSpeeds. This flexible interface is a good design; however it is very granular and could be up to interpretation. So, a simpler method for binding a controller to a drive command may be warranted. Some examples for improvements:

  1. Create a driveWithController alias that performs the binding within the method.
  public Command driveWithController(CommandXboxController controller) {
    return drive(() -> speedsFromController(controller));
  }
  1. Extract speedsFromController and transform it to be a Function<CommandXboxController, Supplier<ChassisSpeeds>>
drive.drive(ChassisSpeedsHelper.fromController(controller))

Note that for 2, ChassisSpeedsHelper is a new class that assist with creating, transforming, and using ChassisSpeeds. There are multiple methods in Drive that have this responsibility; some can be moved to ChassisSpeedsHelper and some can't. It may be challenging to move some of these methods over, but all can be!

Metadata

Metadata

Assignees

No one assigned

    Labels

    driveDrive subsystem and navigationgood first issueGood for newcomers

    Type

    No type

    Projects

    Status

    Ideas

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions