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


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 |
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.
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. | tap::control::setpoint::UnjamCommand::UnjamCommand | ( | SetpointSubsystem * | setpointSubsystem, |
| float | unjamDisplacement, | ||
| float | unjamThreshold, | ||
| uint32_t | maxWaitTime, | ||
| uint_fast16_t | targetCycleCount | ||
| ) |
| [in] | setpointSubsystem | The associated agitator subsystem to control. |
| [in] | unjamDisplacement | How far to attempt to displace the subsystem during an unjam. This value should be positive! Absolute value will be taken if negative. |
| [in] | unjamThreshold | The 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] | maxWaitTime | The 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] | targetCycleCount | the number of cycles to attempt to wiggle the subsystem |
|
overridevirtual |
The action to take when the command ends. Called when either the command finishes normally, or when it interrupted/canceled.
| [in] | interrupted | whether the command was interrupted/canceled. |
Implements tap::control::Command.
|
overridevirtual |
The main body of a command. Called repeatedly while the command is scheduled by a CommandScheduler.
Implements tap::control::Command.
|
inlineoverridevirtual |
Implements tap::control::Command.
|
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.
|
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().
Implements tap::control::Command.
|
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.