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 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
-
ClassDescriptionEnhanced version of WPILib's Command that allows for extension of existing functionality.BaseMaintainerCommand<TargetT,
PowerT> A command that maintains a subsystem at a goal value (and allows human override).A command composition that runs a set of commands in parallel, ending when the last command ends.A command composition that runs a set of commands in parallel, ending only when a specific command (the "deadline") ends, interrupting all other commands that are still running at that point.Core Robot class which configures logging, tunables, scheduling, and the injector.A command composition that runs a list of commands in sequence.BaseSetpointSubsystem<TargetT,PowerT> Base class for subsystems that have a setpoint managed by a maintainer.A base class for maintainer commands that use simple Double values for both current and target values.A base class for setpoint subsystems that use simple Double values for both current and target values.Command that waits for a setpoint subsystem to reach its goalA registry for components that implementDataFrameRefreshable, which allows them to be refreshed on a regular basis by theBaseRobot.Convenience wrapper of InstantCommand that allows setting a human readable name for dashboard and logging readability.SetTargetCommand<TargetT>A command that sets a target value on a BaseSetpointSubsystem.Command that waits for a maintainer to be at its goal or until a timeout.Wrapper for base Scheduler which intelligently manages exceptions.