Package xbot.common.command
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 BaseSetpointSubsystem
s.
They have a command that extends BaseMaintainerCommand
that runs on
the subsystem. Commands extending from BaseSetpointCommand
s 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 BaseSetpointCommand
s 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
-
ClassDescriptionEnhanced version of WPILib's Command that allows for extension of existing functionality.A command that maintains a subsystem at a goal value (and allows human override).Core Robot class which configures logging, properties, scheduling, and the injector.Base class for subsystems that have a setpoint managed by a maintainer.Command that waits for a setpoint subsystem to reach its goalConvenience wrapper of InstantCommand that allows setting a human readable name for smartdashboard/logging readability.Command that waits for a maintainer to be at its goal or until a timeout.Wrapper for base Scheduler which intelligently manages exceptions.