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

#include <unjam_command.hpp>

Inheritance diagram for tap::control::setpoint::UnjamCommand:
Collaboration diagram for tap::control::setpoint::UnjamCommand:

Public Member Functions

 UnjamCommand (SetpointSubsystem *setpointSubsystem, float unjamDisplacement, float unjamThreshold, uint32_t maxWaitTime, uint_fast16_t targetCycleCount)
 
bool isReady () override
 
void initialize () override
 
void execute () override
 
void end (bool interrupted) override
 
bool isFinished () const override
 
const char * getName () const override
 
- Public Member Functions inherited from tap::control::Command
 Command ()
 
virtual ~Command ()
 
mockable subsystem_scheduler_bitmap_t getRequirementsBitwise () const
 
int getGlobalIdentifier () const
 
mockable void addSubsystemRequirement (Subsystem *requirement)
 

Additional Inherited Members

- Protected Attributes inherited from tap::control::Command
command_scheduler_bitmap_t commandRequirementsBitwise = 0
 

Detailed Description

Command that takes control of a setpoint subsystem moves it back and forth. One back and forward motion counts as a cycle. Unjamming cycles start by trying to move in negative direction before trying to move in positive direction.

If the unjam command successfully clears its forward and backward threshold it will return the setpoint of the subsystem back to its original value and call the setpoint subsystem's clear jam method once the subsystem has reached it's original value or once interrupted. If not successful, setpoint is set to current value so as to not damage motors.

If the subsystem fails to return to the original value after clearing its forward and backward thresholds it will continue the unjamming sequence with what remaining cycles it has.

Like most setpoint commands this one will not schedule/will deschedule if setpointSubsystem goes offline.

Note
: If the command does not seem to successfully clear your subsystem's jam status try increasing the maxUnjamWaitTime. The command may not have enough time to return to the original setpoint before unjamming as this distance is potentially much greater than the unjam displacement.

Constructor & Destructor Documentation

◆ UnjamCommand()

tap::control::setpoint::UnjamCommand::UnjamCommand ( SetpointSubsystem setpointSubsystem,
float  unjamDisplacement,
float  unjamThreshold,
uint32_t  maxWaitTime,
uint_fast16_t  targetCycleCount 
)
Parameters
[in]setpointSubsystemThe associated agitator subsystem to control.
[in]unjamDisplacementHow far to attempt to displace the subsystem during an unjam. This value should be positive! Absolute value will be taken if negative.
[in]unjamThresholdThe minimum displacement to be reached both forwards and backwards before the subsystem is considered unjammed. This value must be positive. Absolute value will be taken if negative.
[in]maxWaitTimeThe maximum amount of time the controller will wait for the subsystem to reach unjamDisplacement in milliseconds before trying to move in the opposite direction.
[in]targetCycleCountthe number of cycles to attempt to wiggle the subsystem

Member Function Documentation

◆ end()

void tap::control::setpoint::UnjamCommand::end ( bool  interrupted)
overridevirtual

The action to take when the command ends. Called when either the command finishes normally, or when it interrupted/canceled.

Parameters
[in]interruptedwhether the command was interrupted/canceled.

Implements tap::control::Command.

◆ execute()

void tap::control::setpoint::UnjamCommand::execute ( )
overridevirtual

The main body of a command. Called repeatedly while the command is scheduled by a CommandScheduler.

Implements tap::control::Command.

◆ getName()

const char * tap::control::setpoint::UnjamCommand::getName ( ) const
inlineoverridevirtual
Returns
the name of the command, to be implemented by derived classes.

Implements tap::control::Command.

◆ initialize()

void tap::control::setpoint::UnjamCommand::initialize ( )
overridevirtual

The initial subroutine of a command. Called once when the command is initially scheduled by a CommandScheduler.

Note that command instances are re-used: a single command could be initialized, run, finished, then later initialized again. Ensure that initialize() resets any state stored in the command!

Implements tap::control::Command.

◆ isFinished()

bool tap::control::setpoint::UnjamCommand::isFinished ( ) const
overridevirtual

Whether the command has finished. Once a Command finishes, the scheduler will call the end() function and un-schedule it. If a Command is naturally finished (i.e. isFinished() == true), then the CommandScheduler will pass in false to end(). If, for example, another Command is added that in turn stops the Command from executing, then the CommandScheduler will pass in true to end().

Returns
whether the command has finished.

Implements tap::control::Command.

◆ isReady()

bool tap::control::setpoint::UnjamCommand::isReady ( )
overridevirtual

A check called right before a command is scheduled to determine whether or not a command should be scheduled. If return is true then the command is scheduled, if false then the command is not scheduled.

Not forced to be overridden, returns true by default.

Reimplemented from tap::control::Command.


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