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

#include <move_command.hpp>

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

Public Member Functions

 MoveCommand (SetpointSubsystem *setpointSubsystem, float targetDisplacement, uint32_t moveTime, uint32_t pauseAfterMoveTime, bool setToTargetOnEnd, float setpointTolerance)
 
const char * getName () const override
 
bool isReady () override
 
void initialize () override
 
void execute () override
 
void end (bool interrupted) override
 
bool isFinished () 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

Displaces the connected subsystem some value in some desired time. Currently pass in a displacement and time to move and it uses tap::arch::getTimeMilliseconds() to determine the speed to move at.

Ends if subsystem is offline.

Constructor & Destructor Documentation

◆ MoveCommand()

tap::control::setpoint::MoveCommand::MoveCommand ( SetpointSubsystem setpointSubsystem,
float  targetDisplacement,
uint32_t  moveTime,
uint32_t  pauseAfterMoveTime,
bool  setToTargetOnEnd,
float  setpointTolerance 
)
Parameters
[in]setpointSubsystemThe subsystem associated with the rotate command.
[in]targetDisplacementThe desired change in subsystem value in subsystem units.
[in]moveTimeThe time it takes to move the subsystem to the desired value in milliseconds.
[in]pauseAfterMoveTimeTime in milliseconds that the command will wait after reaching the target displacement before the command is considered complete.
[in]setToTargetOnEndif true the command will set the subsystem setpoint to the ideal target value on an uninterrupted end() if subsystem is online and unjammed, otherwise the subsystem will always set the setpoint to the its current value on end().
[in]setpointToleranceThe difference between current and desired value when the command will be considered to be completed (used in the isFinished function). Uses the same units as the subsystem's setpoint.
Attention
the ramp value is calculated by finding the rotation speed ( $targetDisplacement / moveTime$), and then multiplying this by the period (how often the ramp is called)

Member Function Documentation

◆ end()

void tap::control::setpoint::MoveCommand::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::MoveCommand::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::MoveCommand::getName ( ) const
inlineoverridevirtual
Returns
the name of the command, to be implemented by derived classes.

Implements tap::control::Command.

◆ initialize()

void tap::control::setpoint::MoveCommand::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::MoveCommand::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::MoveCommand::isReady ( )
inlineoverridevirtual

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: