Fang-Robotics-MCB
Fang Robotics Team Codebase
Loading...
Searching...
No Matches
tap::control::Subsystem Class Reference

#include <subsystem.hpp>

Inheritance diagram for tap::control::Subsystem:
Collaboration diagram for tap::control::Subsystem:

Public Member Functions

 Subsystem (Drivers *drivers)
 
virtual ~Subsystem ()
 
virtual void initialize ()
 
void registerAndInitialize ()
 
mockable void setDefaultCommand (Command *defaultCommand)
 
mockable CommandgetDefaultCommand () const
 
virtual void refresh ()
 
virtual void refreshSafeDisconnect ()
 
mockable void setTestCommand (Command *testCommand)
 
mockable CommandgetTestCommand () const
 
virtual const char * getName () const
 
mockable int getGlobalIdentifier () const
 

Protected Attributes

Driversdrivers
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Subsystem()

tap::control::Subsystem::Subsystem ( Drivers drivers)

◆ ~Subsystem()

tap::control::Subsystem::~Subsystem ( )
virtual

Member Function Documentation

◆ getDefaultCommand()

mockable Command * tap::control::Subsystem::getDefaultCommand ( ) const
inline

Gets the default command for this subsystem. Returns nullptr if no default command is currently associated with the subsystem.

Returns
the default command associated with this subsystem

◆ getGlobalIdentifier()

mockable int tap::control::Subsystem::getGlobalIdentifier ( ) const
inline

◆ getName()

const char * tap::control::Subsystem::getName ( ) const
virtual

◆ getTestCommand()

mockable Command * tap::control::Subsystem::getTestCommand ( ) const
inline

Gets the test command for this subsystem. Returns nullptr if no test command is currently associated with the subsystem.

Returns
the test command associated with this subsystem

◆ initialize()

◆ refresh()

virtual void tap::control::Subsystem::refresh ( )
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.

◆ refreshSafeDisconnect()

virtual void tap::control::Subsystem::refreshSafeDisconnect ( )
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.

◆ registerAndInitialize()

void tap::control::Subsystem::registerAndInitialize ( )

Calls initialize and registers the subsystem with the command scheduler passed in through the driver.

◆ setDefaultCommand()

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.

Parameters
defaultCommandthe default Command to associate with this subsystem

◆ setTestCommand()

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.

Parameters
testCommandthe test Command to associate with this subsystem

Member Data Documentation

◆ drivers

Drivers* tap::control::Subsystem::drivers
protected

The documentation for this class was generated from the following files: