mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
Reflowed comments and removed commented out code (#735)
This commit is contained in:
committed by
Peter Johnson
parent
1e8d18b328
commit
c663d7cd16
@@ -25,6 +25,7 @@ int Command::m_commandCounter = 0;
|
||||
|
||||
/**
|
||||
* Creates a new command.
|
||||
*
|
||||
* The name of this command will be default.
|
||||
*/
|
||||
Command::Command() : Command("", -1.0) {}
|
||||
@@ -40,7 +41,7 @@ Command::Command(const std::string& name) : Command(name, -1.0) {}
|
||||
* Creates a new command with the given timeout and a default name.
|
||||
*
|
||||
* @param timeout the time (in seconds) before this command "times out"
|
||||
* @see Command#isTimedOut() isTimedOut()
|
||||
* @see IsTimedOut()
|
||||
*/
|
||||
Command::Command(double timeout) : Command("", timeout) {}
|
||||
|
||||
@@ -49,7 +50,7 @@ Command::Command(double timeout) : Command("", timeout) {}
|
||||
*
|
||||
* @param name the name of the command
|
||||
* @param timeout the time (in seconds) before this command "times out"
|
||||
* @see Command#isTimedOut() isTimedOut()
|
||||
* @see IsTimedOut()
|
||||
*/
|
||||
Command::Command(const std::string& name, double timeout) {
|
||||
// We use -1.0 to indicate no timeout.
|
||||
@@ -75,7 +76,7 @@ Command::~Command() {
|
||||
*
|
||||
* The ID is a unique sequence number that is incremented for each command.
|
||||
*
|
||||
* @return the ID of this command
|
||||
* @return The ID of this command
|
||||
*/
|
||||
int Command::GetID() const { return m_commandID; }
|
||||
|
||||
@@ -83,7 +84,7 @@ int Command::GetID() const { return m_commandID; }
|
||||
* Sets the timeout of this command.
|
||||
*
|
||||
* @param timeout the timeout (in seconds)
|
||||
* @see Command#isTimedOut() isTimedOut()
|
||||
* @see IsTimedOut()
|
||||
*/
|
||||
void Command::SetTimeout(double timeout) {
|
||||
if (timeout < 0.0)
|
||||
@@ -107,15 +108,13 @@ double Command::TimeSinceInitialized() const {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method specifies that the given {@link Subsystem} is used by this
|
||||
* command.
|
||||
* This method specifies that the given Subsystem is used by this command.
|
||||
*
|
||||
* This method is crucial to the functioning of the Command System in general.
|
||||
*
|
||||
* <p>Note that the recommended way to call this method is in the
|
||||
* constructor.</p>
|
||||
* Note that the recommended way to call this method is in the constructor.
|
||||
*
|
||||
* @param subsystem the {@link Subsystem} required
|
||||
* @param subsystem The Subsystem required
|
||||
* @see Subsystem
|
||||
*/
|
||||
void Command::Requires(Subsystem* subsystem) {
|
||||
@@ -130,8 +129,7 @@ void Command::Requires(Subsystem* subsystem) {
|
||||
/**
|
||||
* Called when the command has been removed.
|
||||
*
|
||||
* This will call {@link Command#interrupted() interrupted()} or
|
||||
* {@link Command#end() end()}.
|
||||
* This will call Interrupted() or End().
|
||||
*/
|
||||
void Command::Removed() {
|
||||
if (m_initialized) {
|
||||
@@ -150,11 +148,11 @@ void Command::Removed() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts up the command. Gets the command ready to start.
|
||||
* Starts up the command. Gets the command ready to start.
|
||||
*
|
||||
* <p>Note that the command will eventually start, however it will not
|
||||
* necessarily do so immediately, and may in fact be canceled before initialize
|
||||
* is even called.</p>
|
||||
* Note that the command will eventually start, however it will not necessarily
|
||||
* do so immediately, and may in fact be canceled before initialize is even
|
||||
* called.
|
||||
*/
|
||||
void Command::Start() {
|
||||
LockChanges();
|
||||
@@ -169,7 +167,7 @@ void Command::Start() {
|
||||
/**
|
||||
* The run method is used internally to actually run the commands.
|
||||
*
|
||||
* @return whether or not the command should stay within the {@link Scheduler}.
|
||||
* @return Whether or not the command should stay within the Scheduler.
|
||||
*/
|
||||
bool Command::Run() {
|
||||
if (!m_runWhenDisabled && m_parent == nullptr && RobotState::IsDisabled())
|
||||
@@ -201,22 +199,20 @@ void Command::Initialize() {}
|
||||
void Command::Execute() {}
|
||||
|
||||
/**
|
||||
* Called when the command ended peacefully. This is where you may want
|
||||
* to wrap up loose ends, like shutting off a motor that was being used
|
||||
* in the command.
|
||||
* Called when the command ended peacefully. This is where you may want to wrap
|
||||
* up loose ends, like shutting off a motor that was being used in the command.
|
||||
*/
|
||||
void Command::End() {}
|
||||
|
||||
/**
|
||||
* Called when the command ends because somebody called
|
||||
* {@link Command#cancel() cancel()} or another command shared the same
|
||||
* requirements as this one, and booted it out.
|
||||
* Called when the command ends because somebody called Cancel() or another
|
||||
* command shared the same requirements as this one, and booted it out.
|
||||
*
|
||||
* <p>This is where you may want to wrap up loose ends, like shutting off a
|
||||
* motor that was being used in the command.</p>
|
||||
* This is where you may want to wrap up loose ends, like shutting off a motor
|
||||
* that was being used in the command.
|
||||
*
|
||||
* <p>Generally, it is useful to simply call the {@link Command#end() end()}
|
||||
* method within this method, as done here.</p>
|
||||
* Generally, it is useful to simply call the End() method within this method,
|
||||
* as done here.
|
||||
*/
|
||||
void Command::Interrupted() { End(); }
|
||||
|
||||
@@ -231,15 +227,13 @@ void Command::_End() {}
|
||||
/**
|
||||
* Called to indicate that the timer should start.
|
||||
*
|
||||
* This is called right before {@link Command#initialize() initialize()} is,
|
||||
* inside the {@link Command#run() run()} method.
|
||||
* This is called right before Initialize() is, inside the Run() method.
|
||||
*/
|
||||
void Command::StartTiming() { m_startTime = Timer::GetFPGATimestamp(); }
|
||||
|
||||
/**
|
||||
* Returns whether or not the
|
||||
* {@link Command#timeSinceInitialized() timeSinceInitialized()} method returns
|
||||
* a number which is greater than or equal to the timeout for the command.
|
||||
* Returns whether or not the TimeSinceInitialized() method returns a number
|
||||
* which is greater than or equal to the timeout for the command.
|
||||
*
|
||||
* If there is no timeout, this will always return false.
|
||||
*
|
||||
@@ -250,11 +244,11 @@ bool Command::IsTimedOut() const {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the requirements (as an std::set of {@link Subsystem Subsystems}
|
||||
* pointers) of this command.
|
||||
* Returns the requirements (as an std::set of Subsystem pointers) of this
|
||||
* command.
|
||||
*
|
||||
* @return the requirements (as an std::set of {@link Subsystem Subsystems}
|
||||
* pointers) of this command
|
||||
* @return The requirements (as an std::set of Subsystem pointers) of this
|
||||
* command
|
||||
*/
|
||||
Command::SubsystemSet Command::GetRequirements() const {
|
||||
return m_requirements;
|
||||
@@ -268,9 +262,9 @@ void Command::LockChanges() { m_locked = true; }
|
||||
/**
|
||||
* If changes are locked, then this will generate a CommandIllegalUse error.
|
||||
*
|
||||
* @param message the message to report on error (it is appended by a default
|
||||
* @param message The message to report on error (it is appended by a default
|
||||
* message)
|
||||
* @return true if assert passed, false if assert failed
|
||||
* @return True if assert passed, false if assert failed.
|
||||
*/
|
||||
bool Command::AssertUnlocked(const std::string& message) {
|
||||
if (m_locked) {
|
||||
@@ -283,7 +277,7 @@ bool Command::AssertUnlocked(const std::string& message) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the parent of this command. No actual change is made to the group.
|
||||
* Sets the parent of this command. No actual change is made to the group.
|
||||
*
|
||||
* @param parent the parent
|
||||
*/
|
||||
@@ -302,9 +296,10 @@ void Command::SetParent(CommandGroup* parent) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears list of subsystem requirements. This is only used by
|
||||
* {@link ConditionalCommand} so cancelling the chosen command works properly in
|
||||
* {@link CommandGroup}.
|
||||
* Clears list of subsystem requirements.
|
||||
*
|
||||
* This is only used by ConditionalCommand so cancelling the chosen command
|
||||
* works properly in CommandGroup.
|
||||
*/
|
||||
void Command::ClearRequirements() { m_requirements.clear(); }
|
||||
|
||||
@@ -313,12 +308,11 @@ void Command::ClearRequirements() { m_requirements.clear(); }
|
||||
*
|
||||
* The lifecycle of a command is:
|
||||
*
|
||||
* startRunning() is called.
|
||||
* run() is called (multiple times potentially)
|
||||
* removed() is called
|
||||
* StartRunning() is called. Run() is called (multiple times potentially).
|
||||
* Removed() is called.
|
||||
*
|
||||
* It is very important that startRunning and removed be called in order or some
|
||||
* assumptions of the code will be broken.
|
||||
* It is very important that StartRunning() and Removed() be called in order or
|
||||
* some assumptions of the code will be broken.
|
||||
*/
|
||||
void Command::StartRunning() {
|
||||
m_running = true;
|
||||
@@ -330,7 +324,7 @@ void Command::StartRunning() {
|
||||
* Returns whether or not the command is running.
|
||||
*
|
||||
* This may return true even if the command has just been canceled, as it may
|
||||
* not have yet called {@link Command#interrupted()}.
|
||||
* not have yet called Interrupted().
|
||||
*
|
||||
* @return whether or not the command is running
|
||||
*/
|
||||
@@ -339,13 +333,13 @@ bool Command::IsRunning() const { return m_running; }
|
||||
/**
|
||||
* This will cancel the current command.
|
||||
*
|
||||
* <p>This will cancel the current command eventually. It can be called
|
||||
* multiple times. And it can be called when the command is not running. If
|
||||
* the command is running though, then the command will be marked as canceled
|
||||
* and eventually removed.</p>
|
||||
* This will cancel the current command eventually. It can be called multiple
|
||||
* times. And it can be called when the command is not running. If the command
|
||||
* is running though, then the command will be marked as canceled and eventually
|
||||
* removed.
|
||||
*
|
||||
* <p>A command can not be canceled if it is a part of a command group, you
|
||||
* must cancel the command group instead.</p>
|
||||
* A command can not be canceled if it is a part of a command group, you must
|
||||
* cancel the command group instead.
|
||||
*/
|
||||
void Command::Cancel() {
|
||||
if (m_parent != nullptr)
|
||||
@@ -357,7 +351,7 @@ void Command::Cancel() {
|
||||
}
|
||||
|
||||
/**
|
||||
* This works like cancel(), except that it doesn't throw an exception if it is
|
||||
* This works like Cancel(), except that it doesn't throw an exception if it is
|
||||
* a part of a command group.
|
||||
*
|
||||
* Should only be called by the parent command group.
|
||||
@@ -390,7 +384,7 @@ void Command::SetInterruptible(bool interruptible) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the command requires the given {@link Subsystem}.
|
||||
* Checks if the command requires the given Subsystem.
|
||||
*
|
||||
* @param system the system
|
||||
* @return whether or not the subsystem is required (false if given nullptr)
|
||||
@@ -400,32 +394,31 @@ bool Command::DoesRequire(Subsystem* system) const {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link CommandGroup} that this command is a part of.
|
||||
* Returns the CommandGroup that this command is a part of.
|
||||
*
|
||||
* Will return null if this {@link Command} is not in a group.
|
||||
* Will return null if this Command is not in a group.
|
||||
*
|
||||
* @return the {@link CommandGroup} that this command is a part of (or null if
|
||||
* not in group)
|
||||
* @return The CommandGroup that this command is a part of (or null if not in
|
||||
* group)
|
||||
*/
|
||||
CommandGroup* Command::GetGroup() const { return m_parent; }
|
||||
|
||||
/**
|
||||
* Sets whether or not this {@link Command} should run when the robot is
|
||||
* disabled.
|
||||
* Sets whether or not this Command should run when the robot is disabled.
|
||||
*
|
||||
* <p>By default a command will not run when the robot is disabled, and will in
|
||||
* fact be canceled.</p>
|
||||
* By default a command will not run when the robot is disabled, and will in
|
||||
* fact be canceled.
|
||||
*
|
||||
* @param run whether or not this command should run when the robot is disabled
|
||||
* @param run Whether this command should run when the robot is disabled.
|
||||
*/
|
||||
void Command::SetRunWhenDisabled(bool run) { m_runWhenDisabled = run; }
|
||||
|
||||
/**
|
||||
* Returns whether or not this {@link Command} will run when the robot is
|
||||
* disabled, or if it will cancel itself.
|
||||
* Returns whether or not this Command will run when the robot is disabled, or
|
||||
* if it will cancel itself.
|
||||
*
|
||||
* @return whether or not this {@link Command} will run when the robot is
|
||||
* disabled, or if it will cancel itself
|
||||
* @return Whether this Command will run when the robot is disabled, or if it
|
||||
* will cancel itself.
|
||||
*/
|
||||
bool Command::WillRunWhenDisabled() const { return m_runWhenDisabled; }
|
||||
|
||||
|
||||
@@ -12,22 +12,23 @@
|
||||
using namespace frc;
|
||||
|
||||
/**
|
||||
* Creates a new {@link CommandGroup CommandGroup} with the given name.
|
||||
* @param name the name for this command group
|
||||
* Creates a new CommandGroup with the given name.
|
||||
*
|
||||
* @param name The name for this command group
|
||||
*/
|
||||
CommandGroup::CommandGroup(const std::string& name) : Command(name) {}
|
||||
|
||||
/**
|
||||
* Adds a new {@link Command Command} to the group. The {@link Command Command}
|
||||
* will be started after all the previously added {@link Command Commands}.
|
||||
* Adds a new Command to the group. The Command will be started after all the
|
||||
* previously added Commands.
|
||||
*
|
||||
* <p>Note that any requirements the given {@link Command Command} has will be
|
||||
* added to the group. For this reason, a {@link Command Command's}
|
||||
* requirements can not be changed after being added to a group.</p>
|
||||
* Note that any requirements the given Command has will be added to the group.
|
||||
* For this reason, a Command's requirements can not be changed after being
|
||||
* added to a group.
|
||||
*
|
||||
* <p>It is recommended that this method be called in the constructor.</p>
|
||||
* It is recommended that this method be called in the constructor.
|
||||
*
|
||||
* @param command The {@link Command Command} to be added
|
||||
* @param command The Command to be added
|
||||
*/
|
||||
void CommandGroup::AddSequential(Command* command) {
|
||||
if (command == nullptr) {
|
||||
@@ -48,21 +49,20 @@ void CommandGroup::AddSequential(Command* command) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new {@link Command Command} to the group with a given timeout.
|
||||
* The {@link Command Command} will be started after all the previously added
|
||||
* commands.
|
||||
* Adds a new Command to the group with a given timeout. The Command will be
|
||||
* started after all the previously added commands.
|
||||
*
|
||||
* <p>Once the {@link Command Command} is started, it will be run until it
|
||||
* finishes or the time expires, whichever is sooner. Note that the given
|
||||
* {@link Command Command} will have no knowledge that it is on a timer.</p>
|
||||
* Once the Command is started, it will be run until it finishes or the time
|
||||
* expires, whichever is sooner. Note that the given Command will have no
|
||||
* knowledge that it is on a timer.
|
||||
*
|
||||
* <p>Note that any requirements the given {@link Command Command} has will be
|
||||
* added to the group. For this reason, a {@link Command Command's}
|
||||
* requirements can not be changed after being added to a group.</p>
|
||||
* Note that any requirements the given Command has will be added to the group.
|
||||
* For this reason, a Command's requirements can not be changed after being
|
||||
* added to a group.
|
||||
*
|
||||
* <p>It is recommended that this method be called in the constructor.</p>
|
||||
* It is recommended that this method be called in the constructor.
|
||||
*
|
||||
* @param command The {@link Command Command} to be added
|
||||
* @param command The Command to be added
|
||||
* @param timeout The timeout (in seconds)
|
||||
*/
|
||||
void CommandGroup::AddSequential(Command* command, double timeout) {
|
||||
@@ -88,21 +88,20 @@ void CommandGroup::AddSequential(Command* command, double timeout) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new child {@link Command} to the group. The {@link Command} will be
|
||||
* started after all the previously added {@link Command Commands}.
|
||||
* Adds a new child Command to the group. The Command will be started after all
|
||||
* the previously added Commands.
|
||||
*
|
||||
* <p>Instead of waiting for the child to finish, a {@link CommandGroup} will
|
||||
* have it run at the same time as the subsequent {@link Command Commands}.
|
||||
* The child will run until either it finishes, a new child with conflicting
|
||||
* requirements is started, or the main sequence runs a {@link Command} with
|
||||
* conflicting requirements. In the latter two cases, the child will be
|
||||
* canceled even if it says it can't be interrupted.</p>
|
||||
* Instead of waiting for the child to finish, a CommandGroup will have it run
|
||||
* at the same time as the subsequent Commands. The child will run until either
|
||||
* it finishes, a new child with conflicting requirements is started, or the
|
||||
* main sequence runs a Command with conflicting requirements. In the latter two
|
||||
* cases, the child will be canceled even if it says it can't be interrupted.
|
||||
*
|
||||
* <p>Note that any requirements the given {@link Command Command} has will be
|
||||
* added to the group. For this reason, a {@link Command Command's}
|
||||
* requirements can not be changed after being added to a group.</p>
|
||||
* Note that any requirements the given Command has will be added to the group.
|
||||
* For this reason, a Command's requirements can not be changed after being
|
||||
* added to a group.
|
||||
*
|
||||
* <p>It is recommended that this method be called in the constructor.</p>
|
||||
* It is recommended that this method be called in the constructor.
|
||||
*
|
||||
* @param command The command to be added
|
||||
*/
|
||||
@@ -125,27 +124,25 @@ void CommandGroup::AddParallel(Command* command) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new child {@link Command} to the group with the given timeout. The
|
||||
* {@link Command} will be started after all the previously added
|
||||
* {@link Command Commands}.
|
||||
* Adds a new child Command to the group with the given timeout. The Command
|
||||
* will be started after all the previously added Commands.
|
||||
*
|
||||
* <p>Once the {@link Command Command} is started, it will run until it
|
||||
* finishes, is interrupted, or the time expires, whichever is sooner. Note
|
||||
* that the given {@link Command Command} will have no knowledge that it is on
|
||||
* a timer.</p>
|
||||
* Once the Command is started, it will run until it finishes, is interrupted,
|
||||
* or the time expires, whichever is sooner. Note that the given Command will
|
||||
* have no knowledge that it is on a timer.
|
||||
*
|
||||
* <p>Instead of waiting for the child to finish, a {@link CommandGroup} will
|
||||
* have it run at the same time as the subsequent {@link Command Commands}.
|
||||
* The child will run until either it finishes, the timeout expires, a new
|
||||
* child with conflicting requirements is started, or the main sequence runs a
|
||||
* {@link Command} with conflicting requirements. In the latter two cases, the
|
||||
* child will be canceled even if it says it can't be interrupted.</p>
|
||||
* Instead of waiting for the child to finish, a CommandGroup will have it run
|
||||
* at the same time as the subsequent Commands. The child will run until either
|
||||
* it finishes, the timeout expires, a new child with conflicting requirements
|
||||
* is started, or the main sequence runs a Command with conflicting
|
||||
* requirements. In the latter two cases, the child will be canceled even if it
|
||||
* says it can't be interrupted.
|
||||
*
|
||||
* <p>Note that any requirements the given {@link Command Command} has will be
|
||||
* added to the group. For this reason, a {@link Command Command's}
|
||||
* requirements can not be changed after being added to a group.</p>
|
||||
* Note that any requirements the given Command has will be added to the group.
|
||||
* For this reason, a Command's requirements can not be changed after being
|
||||
* added to a group.
|
||||
*
|
||||
* <p>It is recommended that this method be called in the constructor.</p>
|
||||
* It is recommended that this method be called in the constructor.
|
||||
*
|
||||
* @param command The command to be added
|
||||
* @param timeout The timeout (in seconds)
|
||||
|
||||
@@ -25,10 +25,8 @@ static void RequireAll(Command& command, Command* onTrue, Command* onFalse) {
|
||||
/**
|
||||
* Creates a new ConditionalCommand with given onTrue and onFalse Commands.
|
||||
*
|
||||
* @param onTrue The Command to execute if {@link
|
||||
* ConditionalCommand#Condition()} returns true
|
||||
* @param onFalse The Command to execute if {@link
|
||||
* ConditionalCommand#Condition()} returns false
|
||||
* @param onTrue The Command to execute if Condition() returns true
|
||||
* @param onFalse The Command to execute if Condition() returns false
|
||||
*/
|
||||
ConditionalCommand::ConditionalCommand(Command* onTrue, Command* onFalse) {
|
||||
m_onTrue = onTrue;
|
||||
@@ -40,11 +38,9 @@ ConditionalCommand::ConditionalCommand(Command* onTrue, Command* onFalse) {
|
||||
/**
|
||||
* Creates a new ConditionalCommand with given onTrue and onFalse Commands.
|
||||
*
|
||||
* @param name the name for this command group
|
||||
* @param onTrue The Command to execute if {@link
|
||||
* ConditionalCommand#Condition()} returns true
|
||||
* @param onFalse The Command to execute if {@link
|
||||
* ConditionalCommand#Condition()} returns false
|
||||
* @param name The name for this command group
|
||||
* @param onTrue The Command to execute if Condition() returns true
|
||||
* @param onFalse The Command to execute if Condition() returns false
|
||||
*/
|
||||
ConditionalCommand::ConditionalCommand(const std::string& name, Command* onTrue,
|
||||
Command* onFalse)
|
||||
@@ -63,10 +59,8 @@ void ConditionalCommand::_Initialize() {
|
||||
}
|
||||
|
||||
if (m_chosenCommand != nullptr) {
|
||||
/*
|
||||
* This is a hack to make cancelling the chosen command inside a
|
||||
* CommandGroup work properly
|
||||
*/
|
||||
// This is a hack to make cancelling the chosen command inside a
|
||||
// CommandGroup work properly
|
||||
m_chosenCommand->ClearRequirements();
|
||||
|
||||
m_chosenCommand->Start();
|
||||
|
||||
@@ -10,8 +10,9 @@
|
||||
using namespace frc;
|
||||
|
||||
/**
|
||||
* Creates a new {@link InstantCommand} with the given name.
|
||||
* @param name the name for this command
|
||||
* Creates a new InstantCommand with the given name.
|
||||
*
|
||||
* @param name The name for this command
|
||||
*/
|
||||
InstantCommand::InstantCommand(const std::string& name) : Command(name) {}
|
||||
|
||||
|
||||
@@ -12,8 +12,7 @@
|
||||
using namespace frc;
|
||||
|
||||
/**
|
||||
* Instantiates a {@link PIDSubsystem} that will use the given p, i and d
|
||||
* values.
|
||||
* Instantiates a PIDSubsystem that will use the given P, I, and D values.
|
||||
*
|
||||
* @param name the name
|
||||
* @param p the proportional value
|
||||
@@ -27,8 +26,7 @@ PIDSubsystem::PIDSubsystem(const std::string& name, double p, double i,
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a {@link PIDSubsystem} that will use the given p, i and d
|
||||
* values.
|
||||
* Instantiates a PIDSubsystem that will use the given P, I, and D values.
|
||||
*
|
||||
* @param name the name
|
||||
* @param p the proportional value
|
||||
@@ -43,8 +41,7 @@ PIDSubsystem::PIDSubsystem(const std::string& name, double p, double i,
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a {@link PIDSubsystem} that will use the given p, i and d
|
||||
* values.
|
||||
* Instantiates a PIDSubsystem that will use the given P, I, and D values.
|
||||
*
|
||||
* It will also space the time between PID loop calculations to be equal to the
|
||||
* given period.
|
||||
@@ -64,8 +61,7 @@ PIDSubsystem::PIDSubsystem(const std::string& name, double p, double i,
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a {@link PIDSubsystem} that will use the given p, i and d
|
||||
* values.
|
||||
* Instantiates a PIDSubsystem that will use the given P, I, and D values.
|
||||
*
|
||||
* It will use the class name as its name.
|
||||
*
|
||||
@@ -79,8 +75,7 @@ PIDSubsystem::PIDSubsystem(double p, double i, double d)
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a {@link PIDSubsystem} that will use the given p, i and d
|
||||
* values.
|
||||
* Instantiates a PIDSubsystem that will use the given P, I, and D values.
|
||||
*
|
||||
* It will use the class name as its name.
|
||||
*
|
||||
@@ -95,8 +90,7 @@ PIDSubsystem::PIDSubsystem(double p, double i, double d, double f)
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a {@link PIDSubsystem} that will use the given p, i and d
|
||||
* values.
|
||||
* Instantiates a PIDSubsystem that will use the given P, I, and D values.
|
||||
*
|
||||
* It will use the class name as its name. It will also space the time
|
||||
* between PID loop calculations to be equal to the given period.
|
||||
@@ -115,21 +109,21 @@ PIDSubsystem::PIDSubsystem(double p, double i, double d, double f,
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the internal {@link PIDController}.
|
||||
* Enables the internal PIDController.
|
||||
*/
|
||||
void PIDSubsystem::Enable() { m_controller->Enable(); }
|
||||
|
||||
/**
|
||||
* Disables the internal {@link PIDController}.
|
||||
* Disables the internal PIDController.
|
||||
*/
|
||||
void PIDSubsystem::Disable() { m_controller->Disable(); }
|
||||
|
||||
/**
|
||||
* Returns the {@link PIDController} used by this {@link PIDSubsystem}.
|
||||
* Returns the PIDController used by this PIDSubsystem.
|
||||
*
|
||||
* Use this if you would like to fine tune the pid loop.
|
||||
* Use this if you would like to fine tune the PID loop.
|
||||
*
|
||||
* @return the {@link PIDController} used by this {@link PIDSubsystem}
|
||||
* @return The PIDController used by this PIDSubsystem
|
||||
*/
|
||||
std::shared_ptr<PIDController> PIDSubsystem::GetPIDController() {
|
||||
return m_controller;
|
||||
@@ -138,8 +132,8 @@ std::shared_ptr<PIDController> PIDSubsystem::GetPIDController() {
|
||||
/**
|
||||
* Sets the setpoint to the given value.
|
||||
*
|
||||
* If {@link PIDCommand#SetRange(double, double) SetRange(...)} was called,
|
||||
* then the given setpoint will be trimmed to fit within the range.
|
||||
* If SetRange() was called, then the given setpoint will be trimmed to fit
|
||||
* within the range.
|
||||
*
|
||||
* @param setpoint the new setpoint
|
||||
*/
|
||||
@@ -150,8 +144,7 @@ void PIDSubsystem::SetSetpoint(double setpoint) {
|
||||
/**
|
||||
* Adds the given value to the setpoint.
|
||||
*
|
||||
* If {@link PIDCommand#SetRange(double, double) SetRange(...)} was used,
|
||||
* then the bounds will still be honored by this method.
|
||||
* If SetRange() was used, then the bounds will still be honored by this method.
|
||||
*
|
||||
* @param deltaSetpoint the change in the setpoint
|
||||
*/
|
||||
@@ -197,7 +190,8 @@ void PIDSubsystem::SetAbsoluteTolerance(double absValue) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the percentage error which is considered tolerable for use with OnTarget.
|
||||
* Set the percentage error which is considered tolerable for use with
|
||||
* OnTarget().
|
||||
*
|
||||
* @param percent percentage error which is tolerable
|
||||
*/
|
||||
@@ -207,9 +201,9 @@ void PIDSubsystem::SetPercentTolerance(double percent) {
|
||||
|
||||
/**
|
||||
* Return true if the error is within the percentage of the total input range,
|
||||
* determined by SetTolerance.
|
||||
* determined by SetTolerance().
|
||||
*
|
||||
* This asssumes that the maximum and minimum input were set using SetInput.
|
||||
* This asssumes that the maximum and minimum input were set using SetInput().
|
||||
* Use OnTarget() in the IsFinished() method of commands that use this
|
||||
* subsystem.
|
||||
*
|
||||
@@ -217,7 +211,7 @@ void PIDSubsystem::SetPercentTolerance(double percent) {
|
||||
* setpoint. Ideally it should be based on being within the tolerance for some
|
||||
* period of time.
|
||||
*
|
||||
* @return true if the error is within the percentage tolerance of the input
|
||||
* @return True if the error is within the percentage tolerance of the input
|
||||
* range
|
||||
*/
|
||||
bool PIDSubsystem::OnTarget() const { return m_controller->OnTarget(); }
|
||||
|
||||
@@ -20,9 +20,9 @@ using namespace frc;
|
||||
Scheduler::Scheduler() { HLUsageReporting::ReportScheduler(); }
|
||||
|
||||
/**
|
||||
* Returns the {@link Scheduler}, creating it if one does not exist.
|
||||
* Returns the Scheduler, creating it if one does not exist.
|
||||
*
|
||||
* @return the {@link Scheduler}
|
||||
* @return the Scheduler
|
||||
*/
|
||||
Scheduler* Scheduler::GetInstance() {
|
||||
static Scheduler instance;
|
||||
@@ -99,14 +99,14 @@ void Scheduler::ProcessCommandAddition(Command* command) {
|
||||
* Runs a single iteration of the loop.
|
||||
*
|
||||
* This method should be called often in order to have a functioning
|
||||
* {@link Command} system. The loop has five stages:
|
||||
* Command system. The loop has five stages:
|
||||
*
|
||||
* <ol>
|
||||
* <li> Poll the Buttons </li>
|
||||
* <li> Execute/Remove the Commands </li>
|
||||
* <li> Send values to SmartDashboard </li>
|
||||
* <li> Add Commands </li>
|
||||
* <li> Add Defaults </li>
|
||||
* <li>Poll the Buttons</li>
|
||||
* <li>Execute/Remove the Commands</li>
|
||||
* <li>Send values to SmartDashboard</li>
|
||||
* <li>Add Commands</li>
|
||||
* <li>Add Defaults</li>
|
||||
* </ol>
|
||||
*/
|
||||
void Scheduler::Run() {
|
||||
@@ -166,10 +166,10 @@ void Scheduler::Run() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a {@link Subsystem} to this {@link Scheduler}, so that the {@link
|
||||
* Scheduler} might know if a default {@link Command} needs to be run.
|
||||
* Registers a Subsystem to this Scheduler, so that the Scheduler might know if
|
||||
* a default Command needs to be run.
|
||||
*
|
||||
* All {@link Subsystem Subsystems} should call this.
|
||||
* All Subsystems should call this.
|
||||
*
|
||||
* @param system the system
|
||||
*/
|
||||
@@ -182,7 +182,7 @@ void Scheduler::RegisterSubsystem(Subsystem* subsystem) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the {@link Command} from the {@link Scheduler}.
|
||||
* Removes the Command from the Scheduler.
|
||||
*
|
||||
* @param command the command to remove
|
||||
*/
|
||||
@@ -235,10 +235,8 @@ void Scheduler::UpdateTable() {
|
||||
toCancel = new_toCancel->GetDoubleArray();
|
||||
else
|
||||
toCancel.resize(0);
|
||||
// m_table->RetrieveValue("Ids", *ids);
|
||||
|
||||
// cancel commands that have had the cancel buttons pressed
|
||||
// on the SmartDashboad
|
||||
// Cancel commands whose cancel buttons were pressed on the SmartDashboard
|
||||
if (!toCancel.empty()) {
|
||||
for (auto commandIter = m_commands.begin();
|
||||
commandIter != m_commands.end(); ++commandIter) {
|
||||
|
||||
@@ -38,8 +38,8 @@ void Subsystem::InitDefaultCommand() {}
|
||||
* Sets the default command. If this is not called or is called with null,
|
||||
* then there will be no default command for the subsystem.
|
||||
*
|
||||
* <p><b>WARNING:</b> This should <b>NOT</b> be called in a constructor if the
|
||||
* subsystem is a singleton.</p>
|
||||
* <b>WARNING:</b> This should <b>NOT</b> be called in a constructor if the
|
||||
* subsystem is a singleton.
|
||||
*
|
||||
* @param command the default command (or null if there should be none)
|
||||
*/
|
||||
@@ -113,9 +113,9 @@ void Subsystem::Periodic() {}
|
||||
* Call this to alert Subsystem that the current command is actually the
|
||||
* command.
|
||||
*
|
||||
* Sometimes, the {@link Subsystem} is told that it has no command while the
|
||||
* {@link Scheduler} is going through the loop, only to be soon after given a
|
||||
* new one. This will avoid that situation.
|
||||
* Sometimes, the Subsystem is told that it has no command while the Scheduler
|
||||
* is going through the loop, only to be soon after given a new one. This will
|
||||
* avoid that situation.
|
||||
*/
|
||||
void Subsystem::ConfirmCommand() {
|
||||
if (m_currentCommandChanged) {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
using namespace frc;
|
||||
|
||||
/**
|
||||
* A {@link WaitCommand} will wait until a certain match time before finishing.
|
||||
* A WaitCommand will wait until a certain match time before finishing.
|
||||
*
|
||||
* This will wait until the game clock reaches some value, then continue to the
|
||||
* next command.
|
||||
|
||||
Reference in New Issue
Block a user