Package xbot.common.command


package xbot.common.command
The command framework, scheduler and subsystems.

Setpoint Subsystems and Maintainers

There are many components of the robot that need to maintain a particular state. For example, an arm might need to maintain a particular angle, or a drive train might need to maintain a particular velocity. We can implement these components as setpoint subsystems that have a maintainer command that runs in the background and keeps the subsystem and its outputs at the desired state.

Setpoint subsystems are implemented as BaseSetpointSubsystems. They have a command that extends BaseMaintainerCommand that runs on the subsystem. Commands extending from BaseSetpointCommands are used to change the setpoint of the subsystem.

A BaseSetpointSubsystem often has a default command that runs on it. This command is a BaseSetpointCommand-derived command that returns the related mechanism to its default state. For example, an arm might have a default command that returns the arm to its lowest position. Additional commands can be created to move the arm to other positions. These commands will interrupt each other because they are all BaseSetpointCommands that require the same subsystem and acquire its setpoint lock.

The BaseMaintainerCommand is responsible for maintaining the subsystem at the desired state. It can take input from the human operator and/or from a control system loop using the inputs to the setpoint subsystem. The maintainer sends a power value to the setpoint subsystem, and the setpoint subsystem is responsible for converting that power into an output.

     classDiagram
         class ShooterWheelSetpointSubsystem {
             -Device output
             -Sensor input
             +getCurrentValue() T
             +getTargetValue() T
             +setTargetValue(T value) void
             +setPower(T power) void
             +isCalibrated() boolean
         }
         class BaseSetpointSubsystem~T~ {
             +getCurrentValue()*T
             +getTargetValue()* T
             +setTargetValue(T value)* void
             +setPower(T power)* void
             +isCalibrated()* boolean
         }
         BaseSetpointSubsystem~T~ --|> ShooterWheelSetpointSubsystem
         class ShooterWheelMaintainerCommand {
             ~BaseSetpointSubsystem~T~ subsystemToMaintain
             +execute() void
             #coastAction() void
             #humanControlAction() void
             #initializeMachineControlAction() void
             #calibratedMachineControlAction() void
             #uncalibratedMachineControlAction() void
             #getErrorMagnitude() double
             #getHumanInput() T
             #getHumanInputMagnitude() double
         }
         class BaseMaintainerCommand~T~ {
             ~BaseSetpointSubsystem~T~ subsystemToMaintain
             +execute() void
             #coastAction()* void
             #humanControlAction()* void
             #initializeMachineControlAction()* void
             #calibratedMachineControlAction()* void
             #uncalibratedMachineControlAction()* void
             #getErrorMagnitude()* double
             #getHumanInput()* T
             #getHumanInputMagnitude()* double
         }
         BaseMaintainerCommand~T~ --|> ShooterWheelMaintainerCommand
         class StopShooterWheelSetpointCommand {
             -BaseSetpointSubsystem~T~ subsystem
             +initialize() void
             +execute() void
             +isFinished() boolean
         }
         class BaseSetpointCommand~T~ {
             -BaseSetpointSubsystem~T~ subsystem
             +initialize()* void
             +execute()* void
             +isFinished()* boolean
         }
         BaseSetpointCommand~T~ --|> StopShooterWheelSetpointCommand
         ShooterWheelMaintainerCommand ..> ShooterWheelSetpointSubsystem : Maintains outputs
         StopShooterWheelSetpointCommand ..> ShooterWheelSetpointSubsystem : Sets targets