Andover-Robotics / ARC-Core

This is the combined common code base for Andover Robotics Club, packaged in a library.
0 stars 9 forks source link

DSL for TeleOp control #1

Open broad-well opened 6 years ago

broad-well commented 6 years ago

This issue proposes the development and inclusion of a DSL (Domain-Specific Language) for TeleOp control from Gamepad to output columns.

Motivation

Communication between Programmers and Builders

A DSL for TeleOp allows builders to understand code that's written in it. This eliminates the need for builders (especially drivers) to always consult programmers for controller key-mappings.

Greater Understanding & Abstraction

By making the TeleOp control syntax more understandable, programmers can achieve greater efficiency in rapidly responding to key design decisions, improving overall team agility. By incorporating domain-specific abstraction above common TeleOp control patterns, repetition is reduced across teams.

Concerns

Lack of customizability

A key challenge in the implementation of this DSL is to permit greater flexibility for edge cases for teams. It is impossible to provide universal abstractions for every control pattern required, thus it is important for teams to have such capability. The inability to customize may induce inefficiencies in developing custom design patterns in accordance with the API that we provide. Code for past seasons should be examined for the most important design patterns, which should be included.

Technical Description

The DSL is expected to have a use case syntax similar to the following, replacing the current methodology.

@Override
public void loop() {
  // Binary input columns
  teleOpController.when(gamepad1.left_bumper).isPressed().then(glyphLift::raisePlatform);

  // Responding to change (toggles, etc.)
  teleOpController.when(gamepad1.right_bumper).isChanged().then(status -> if (status)
      drivetrain.togglePrecision());

  // Use analog input columns like binary ones
  teleOpController.when(gamepad1.left_trigger)
      .isAbove(0.7).then(chopsticks::raise)
      .isBelow(0.3).then(chopsticks::lower);
}