|
Fang-Robotics-MCB
Fang Robotics Team Codebase
|
#include <subsystem.hpp>


Public Member Functions | |
| Subsystem (Drivers *drivers) | |
| virtual | ~Subsystem () |
| virtual void | initialize () |
| void | registerAndInitialize () |
| mockable void | setDefaultCommand (Command *defaultCommand) |
| mockable Command * | getDefaultCommand () const |
| virtual void | refresh () |
| virtual void | refreshSafeDisconnect () |
| mockable void | setTestCommand (Command *testCommand) |
| mockable Command * | getTestCommand () const |
| virtual const char * | getName () const |
| mockable int | getGlobalIdentifier () const |
Protected Attributes | |
| Drivers * | drivers |
A robot subsystem. Subsystems are the basic unit of robot organization in the Command-based framework; they encapsulate low-level hardware objects (motor controllers, sensors, etc) and provide methods through which they can be used by Commands. Subsystems are used by the CommandScheduler's resource management system to ensure multiple robot actions are not "fighting" over the same hardware; Commands that use a subsystem should include that subsystem by adding it as a requirement via addSubsystemRequirement, and resources used within a subsystem should generally remain encapsulated and not be shared by other parts of the robot.
Subsystems must be registered with the scheduler with the CommandScheduler.registerSubsystem() function in order for the refresh() function to be called.
| tap::control::Subsystem::Subsystem | ( | Drivers * | drivers | ) |
|
virtual |
Gets the default command for this subsystem. Returns nullptr if no default command is currently associated with the subsystem.
|
inline |
|
virtual |
Gets the test command for this subsystem. Returns nullptr if no test command is currently associated with the subsystem.
|
inlinevirtual |
Called once when you add the Subsystem to the commandScheduler stored in the Drivers class.
Reimplemented in fang::chassis::MecanumDrive, fang::chassis::BaseQuadDrive, fang::chassis::PowerQuadDrive, fang::turret::SimpleAmmoBooster, fang::turret::SimpleFeeder, fang::turret::FieldGimbal, fang::chassis::PierceMecanumDrive, fang::chassis::HolonomicSubsystem, fang::turret::SimpleAmmoBoosterSubsystem, fang::turret::SimpleFeederSubsystem, and fang::turret::FieldGimbalSubsystem.
|
inlinevirtual |
Called in the scheduler's run function assuming this command has been registered with the scheduler. This function should contain code that must be periodically updated and is generic to the subsystem (i.e. updating a control loop generic to this subsystem). This function should not contain command specific control code. When you create a subclass of Subsystem, you should overwrite this virtual function.
Must be virtual otherwise scheduler will refer to this function rather than looking in child for this function.
Reimplemented in fang::chassis::MecanumDrive, fang::chassis::BaseQuadDrive, fang::chassis::PowerQuadDrive, fang::turret::SimpleAmmoBooster, fang::turret::SimpleFeeder, and fang::turret::FieldGimbal.
|
inlinevirtual |
Called in the scheduler's run function before removing commands when safe disconnecting. This function should contain code that safely shuts down the subsystem (i.e. shutting off motors). All subsystems must implement this virtual function.
Reimplemented in fang::chassis::MecanumDrive.
| void tap::control::Subsystem::registerAndInitialize | ( | ) |
Calls initialize and registers the subsystem with the command scheduler passed in through the driver.
| void tap::control::Subsystem::setDefaultCommand | ( | Command * | defaultCommand | ) |
Sets the default Command of the Subsystem. The default Command will be automatically scheduled when no other Commands are scheduled that require the Subsystem. Default Commands should generally not end on their own, i.e. their isFinished() function should always return false. Will automatically register this Subsystem with the CommandScheduler if no other Command is scheduled for this Subsystem.
| defaultCommand | the default Command to associate with this subsystem |
| void tap::control::Subsystem::setTestCommand | ( | Command * | testCommand | ) |
Sets the test command of the Subsystem. The test command can be run by calling CommandScheduler::runHardwareTests.
Test commands must keep track of their state so that Command::isFinished continues to return true after the command has ended.
| testCommand | the test Command to associate with this subsystem |
|
protected |