[commands] Update Command documentation (NFC) (#3881)

Add reference to which VendorDep the class is included in.
Add missing OldCommands C++ Documentation (copied from Java).
This commit is contained in:
sciencewhiz
2022-01-08 11:11:34 -08:00
committed by GitHub
parent b3707cca0b
commit 8ac45f20bb
146 changed files with 413 additions and 25 deletions

View File

@@ -14,6 +14,8 @@ import java.util.function.BooleanSupplier;
*
* <p>Commands are run synchronously from the main robot loop; no multithreading is used, unless
* specified explicitly from the command implementation.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public interface Command {
/** The initial subroutine of a command. Called once when the command is initially scheduled. */

View File

@@ -10,7 +10,11 @@ import edu.wpi.first.util.sendable.SendableRegistry;
import java.util.HashSet;
import java.util.Set;
/** A {@link Sendable} base class for {@link Command}s. */
/**
* A {@link Sendable} base class for {@link Command}s.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public abstract class CommandBase implements Sendable, Command {
protected Set<Subsystem> m_requirements = new HashSet<>();

View File

@@ -13,6 +13,8 @@ import java.util.WeakHashMap;
* A base for CommandGroups. Statically tracks commands that have been allocated to groups to ensure
* those commands are not also used independently, which can result in inconsistent command state
* and unpredictable execution.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public abstract class CommandGroupBase extends CommandBase {
private static final Set<Command> m_groupedCommands =

View File

@@ -33,6 +33,8 @@ import java.util.function.Consumer;
* synchronously from the main loop. Subsystems should be registered with the scheduler using {@link
* CommandScheduler#registerSubsystem(Subsystem...)} in order for their {@link Subsystem#periodic()}
* methods to be called and for their default commands to be scheduled.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public final class CommandScheduler implements NTSendable, AutoCloseable {
/** The Singleton Instance. */

View File

@@ -8,6 +8,8 @@ import edu.wpi.first.wpilibj.Timer;
/**
* Class that holds scheduling state for a command. Used internally by the {@link CommandScheduler}.
*
* <p>This class is provided by the NewCommands VendorDep
*/
class CommandState {
// The time since this command was initialized.

View File

@@ -21,6 +21,8 @@ import java.util.function.BooleanSupplier;
* scheduled individually.
*
* <p>As a rule, CommandGroups require the union of the requirements of their component commands.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public class ConditionalCommand extends CommandBase {
private final Command m_onTrue;

View File

@@ -14,6 +14,8 @@ import java.util.function.Consumer;
* the constructor. Useful for inline definitions of complex commands - note, however, that if a
* command is beyond a certain complexity it is usually better practice to write a proper class for
* it than to inline it.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public class FunctionalCommand extends CommandBase {
protected final Runnable m_onInit;

View File

@@ -10,6 +10,8 @@ import static edu.wpi.first.wpilibj.util.ErrorMessages.requireNonNullParam;
* A Command that runs instantly; it will initialize, execute once, and end on the same iteration of
* the scheduler. Users can either pass in a Runnable and a set of requirements, or else subclass
* this command if desired.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public class InstantCommand extends CommandBase {
private final Runnable m_toRun;

View File

@@ -35,6 +35,8 @@ import java.util.function.Supplier;
*
* <p>The robot angle controller does not follow the angle given by the trajectory but rather goes
* to the angle given in the final state of the trajectory.
*
* <p>This class is provided by the NewCommands VendorDep
*/
@SuppressWarnings("MemberName")
public class MecanumControllerCommand extends CommandBase {

View File

@@ -14,6 +14,8 @@ import edu.wpi.first.wpilibj.Notifier;
* <p>WARNING: Do not use this class unless you are confident in your ability to make the executed
* code thread-safe. If you do not know what "thread-safe" means, that is a good sign that you
* should not use this class.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public class NotifierCommand extends CommandBase {
protected final Notifier m_notifier;

View File

@@ -15,6 +15,8 @@ import java.util.function.DoubleSupplier;
* A command that controls an output with a {@link PIDController}. Runs forever by default - to add
* exit conditions and/or other behavior, subclass this class. The controller calculation and output
* are performed synchronously in the command's execute() method.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public class PIDCommand extends CommandBase {
protected final PIDController m_controller;

View File

@@ -11,6 +11,8 @@ import edu.wpi.first.math.controller.PIDController;
/**
* A subsystem that uses a {@link PIDController} to control an output. The controller is run
* synchronously from the subsystem's periodic() method.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public abstract class PIDSubsystem extends SubsystemBase {
protected final PIDController m_controller;

View File

@@ -12,6 +12,8 @@ import java.util.Map;
* A CommandGroup that runs a set of commands in parallel, ending when the last command ends.
*
* <p>As a rule, CommandGroups require the union of the requirements of their component commands.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public class ParallelCommandGroup extends CommandGroupBase {
// maps commands in this group to whether they are still running

View File

@@ -13,6 +13,8 @@ import java.util.Map;
* "deadline") ends, interrupting all other commands that are still running at that point.
*
* <p>As a rule, CommandGroups require the union of the requirements of their component commands.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public class ParallelDeadlineGroup extends CommandGroupBase {
// maps commands in this group to whether they are still running

View File

@@ -13,6 +13,8 @@ import java.util.Set;
* and interrupting all the others.
*
* <p>As a rule, CommandGroups require the union of the requirements of their component commands.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public class ParallelRaceGroup extends CommandGroupBase {
private final Set<Command> m_commands = new HashSet<>();

View File

@@ -14,6 +14,8 @@ import static edu.wpi.first.wpilibj2.command.CommandGroupBase.requireUngrouped;
* cannot be added to any other groups, or scheduled individually.
*
* <p>As a rule, CommandGroups require the union of the requirements of their component commands.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public class PerpetualCommand extends CommandBase {
protected final Command m_command;

View File

@@ -4,7 +4,11 @@
package edu.wpi.first.wpilibj2.command;
/** A command that prints a string when initialized. */
/**
* A command that prints a string when initialized.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public class PrintCommand extends InstantCommand {
/**
* Creates a new a PrintCommand.

View File

@@ -17,6 +17,8 @@ import java.util.function.Supplier;
* A command that controls an output with a {@link ProfiledPIDController}. Runs forever by default -
* to add exit conditions and/or other behavior, subclass this class. The controller calculation and
* output are performed synchronously in the command's execute() method.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public class ProfiledPIDCommand extends CommandBase {
protected final ProfiledPIDController m_controller;

View File

@@ -13,6 +13,8 @@ import edu.wpi.first.math.trajectory.TrapezoidProfile;
/**
* A subsystem that uses a {@link ProfiledPIDController} to control an output. The controller is run
* synchronously from the subsystem's periodic() method.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public abstract class ProfiledPIDSubsystem extends SubsystemBase {
protected final ProfiledPIDController m_controller;

View File

@@ -10,6 +10,8 @@ import java.util.Set;
* Schedules the given commands when this command is initialized, and ends when all the commands are
* no longer scheduled. Useful for forking off from CommandGroups. If this command is interrupted,
* it will cancel all of the commands.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public class ProxyScheduleCommand extends CommandBase {
private final Set<Command> m_toSchedule;

View File

@@ -29,6 +29,8 @@ import java.util.function.Supplier;
* <p>Advanced teams seeking more flexibility (for example, those who wish to use the onboard PID
* functionality of a "smart" motor controller) may use the secondary constructor that omits the PID
* and feedforward functionality, returning only the raw wheel speeds from the RAMSETE controller.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public class RamseteCommand extends CommandBase {
private final Timer m_timer = new Timer();

View File

@@ -12,6 +12,8 @@ import java.util.function.BooleanSupplier;
* A command that runs a Runnable continuously. Has no end condition as-is; either subclass it or
* use {@link Command#withTimeout(double)} or {@link Command#withInterrupt(BooleanSupplier)} to give
* it one. If you only wish to execute a Runnable once, use {@link InstantCommand}.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public class RunCommand extends CommandBase {
protected final Runnable m_toRun;

View File

@@ -10,6 +10,8 @@ import java.util.Set;
* Schedules the given commands when this command is initialized. Useful for forking off from
* CommandGroups. Note that if run from a CommandGroup, the group will not know about the status of
* the scheduled commands, and will treat this command as finishing instantly.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public class ScheduleCommand extends CommandBase {
private final Set<Command> m_toSchedule;

View File

@@ -23,6 +23,8 @@ import java.util.function.Supplier;
* scheduled individually.
*
* <p>As a rule, CommandGroups require the union of the requirements of their component commands.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public class SelectCommand extends CommandBase {
private final Map<Object, Command> m_commands;

View File

@@ -11,6 +11,8 @@ import java.util.List;
* A CommandGroups that runs a list of commands in sequence.
*
* <p>As a rule, CommandGroups require the union of the requirements of their component commands.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public class SequentialCommandGroup extends CommandGroupBase {
private final List<Command> m_commands = new ArrayList<>();

View File

@@ -11,6 +11,8 @@ import static edu.wpi.first.wpilibj.util.ErrorMessages.requireNonNullParam;
* Useful for running and then stopping a motor, or extending and then retracting a solenoid. Has no
* end condition as-is; either subclass it or use {@link Command#withTimeout(double)} or {@link
* Command#withInterrupt(java.util.function.BooleanSupplier)} to give it one.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public class StartEndCommand extends CommandBase {
protected final Runnable m_onInit;

View File

@@ -18,6 +18,8 @@ package edu.wpi.first.wpilibj2.command;
* Subsystem#periodic()} method to be called. It is recommended that this method be called from the
* constructor of users' Subsystem implementations. The {@link SubsystemBase} class offers a simple
* base for user implementations that handles this.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public interface Subsystem {
/**

View File

@@ -11,6 +11,8 @@ import edu.wpi.first.util.sendable.SendableRegistry;
/**
* A base for subsystems that handles registration in the constructor, and provides a more intuitive
* method for setting the default command.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public abstract class SubsystemBase implements Subsystem, Sendable {
/** Constructor. */

View File

@@ -28,6 +28,8 @@ import java.util.function.Supplier;
*
* <p>The robot angle controller does not follow the angle given by the trajectory but rather goes
* to the angle given in the final state of the trajectory.
*
* <p>This class is provided by the NewCommands VendorDep
*/
@SuppressWarnings("MemberName")
public class SwerveControllerCommand extends CommandBase {

View File

@@ -13,6 +13,8 @@ import java.util.function.Consumer;
/**
* A command that runs a {@link TrapezoidProfile}. Useful for smoothly controlling mechanism motion.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public class TrapezoidProfileCommand extends CommandBase {
private final TrapezoidProfile m_profile;

View File

@@ -11,6 +11,8 @@ import edu.wpi.first.math.trajectory.TrapezoidProfile;
/**
* A subsystem that generates and runs trapezoidal motion profiles automatically. The user specifies
* how to use the current state of the motion profile by overriding the `useState` method.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public abstract class TrapezoidProfileSubsystem extends SubsystemBase {
private final double m_period;

View File

@@ -10,6 +10,8 @@ import edu.wpi.first.wpilibj.Timer;
/**
* A command that does nothing but takes a specified amount of time to finish. Useful for
* CommandGroups. Can also be subclassed to make a command with an internal timer.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public class WaitCommand extends CommandBase {
protected Timer m_timer = new Timer();

View File

@@ -12,6 +12,8 @@ import java.util.function.BooleanSupplier;
/**
* A command that does nothing but ends after a specified match time or condition. Useful for
* CommandGroups.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public class WaitUntilCommand extends CommandBase {
private final BooleanSupplier m_condition;

View File

@@ -17,6 +17,8 @@ import java.util.function.BooleanSupplier;
* <p>This class represents a subclass of Trigger that is specifically aimed at buttons on an
* operator interface as a common use case of the more generalized Trigger objects. This is a simple
* wrapper around Trigger with the method names renamed to fit the Button object use.
*
* <p>This class is provided by the OldCommands VendorDep
*/
public class Button extends Trigger {
/**

View File

@@ -7,6 +7,8 @@ package edu.wpi.first.wpilibj2.command.button;
/**
* This class is intended to be used within a program. The programmer can manually set its value.
* Also includes a setting for whether or not it should invert its value.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public class InternalButton extends Button {
private boolean m_pressed;

View File

@@ -8,7 +8,11 @@ import static edu.wpi.first.wpilibj.util.ErrorMessages.requireNonNullParam;
import edu.wpi.first.wpilibj.GenericHID;
/** A {@link Button} that gets its state from a {@link GenericHID}. */
/**
* A {@link Button} that gets its state from a {@link GenericHID}.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public class JoystickButton extends Button {
private final GenericHID m_joystick;
private final int m_buttonNumber;

View File

@@ -8,7 +8,11 @@ import edu.wpi.first.networktables.NetworkTable;
import edu.wpi.first.networktables.NetworkTableEntry;
import edu.wpi.first.networktables.NetworkTableInstance;
/** A {@link Button} that uses a {@link NetworkTable} boolean field. */
/**
* A {@link Button} that uses a {@link NetworkTable} boolean field.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public class NetworkButton extends Button {
private final NetworkTableEntry m_entry;

View File

@@ -8,7 +8,11 @@ import static edu.wpi.first.wpilibj.util.ErrorMessages.requireNonNullParam;
import edu.wpi.first.wpilibj.GenericHID;
/** A {@link Button} that gets its state from a POV on a {@link GenericHID}. */
/**
* A {@link Button} that gets its state from a POV on a {@link GenericHID}.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public class POVButton extends Button {
private final GenericHID m_joystick;
private final int m_angle;

View File

@@ -23,6 +23,8 @@ import java.util.function.BooleanSupplier;
* (for instance, if they want to react to the user holding a button while the robot is reading a
* certain sensor input). For this, they only have to write the {@link Trigger#get()} method to get
* the full functionality of the Trigger class.
*
* <p>This class is provided by the NewCommands VendorDep
*/
public class Trigger implements BooleanSupplier {
private final BooleanSupplier m_isActive;