diff --git a/wpilibc/src/main/native/cpp/CameraServer.cpp b/wpilibc/src/main/native/cpp/CameraServer.cpp index 8299453179..448ee42353 100644 --- a/wpilibc/src/main/native/cpp/CameraServer.cpp +++ b/wpilibc/src/main/native/cpp/CameraServer.cpp @@ -177,64 +177,7 @@ static std::string PixelFormatToString(int pixelFormat) { return "Unknown"; } } -#if 0 -static cs::VideoMode::PixelFormat PixelFormatFromString(llvm::StringRef str) { - if (str == "MJPEG" || str == "mjpeg" || str == "JPEG" || str == "jpeg") - return cs::VideoMode::PixelFormat::kMJPEG; - if (str == "YUYV" || str == "yuyv") return cs::VideoMode::PixelFormat::kYUYV; - if (str == "RGB565" || str == "rgb565") - return cs::VideoMode::PixelFormat::kRGB565; - if (str == "BGR" || str == "bgr") return cs::VideoMode::PixelFormat::kBGR; - if (str == "GRAY" || str == "Gray" || str == "gray") - return cs::VideoMode::PixelFormat::kGray; - return cs::VideoMode::PixelFormat::kUnknown; -} -static cs::VideoMode VideoModeFromString(llvm::StringRef modeStr) { - cs::VideoMode mode; - size_t pos; - - // width: [0-9]+ - pos = modeStr.find_first_not_of("0123456789"); - llvm::StringRef widthStr = modeStr.slice(0, pos); - modeStr = modeStr.drop_front(pos).ltrim(); // drop whitespace too - - // 'x' - if (modeStr.empty() || modeStr[0] != 'x') return mode; - modeStr = modeStr.drop_front(1).ltrim(); // drop whitespace too - - // height: [0-9]+ - pos = modeStr.find_first_not_of("0123456789"); - llvm::StringRef heightStr = modeStr.slice(0, pos); - modeStr = modeStr.drop_front(pos).ltrim(); // drop whitespace too - - // format: all characters until whitespace - pos = modeStr.find_first_of(" \t\n\v\f\r"); - llvm::StringRef formatStr = modeStr.slice(0, pos); - modeStr = modeStr.drop_front(pos).ltrim(); // drop whitespace too - - // fps: [0-9.]+ - pos = modeStr.find_first_not_of("0123456789."); - llvm::StringRef fpsStr = modeStr.slice(0, pos); - modeStr = modeStr.drop_front(pos).ltrim(); // drop whitespace too - - // "fps" - if (!modeStr.startswith("fps")) return mode; - - // make fps an integer string by dropping after the decimal - fpsStr = fpsStr.slice(0, fpsStr.find('.')); - - // convert width, height, and fps to integers - if (widthStr.getAsInteger(10, mode.width)) return mode; - if (heightStr.getAsInteger(10, mode.height)) return mode; - if (fpsStr.getAsInteger(10, mode.fps)) return mode; - - // convert format to enum value - mode.pixelFormat = PixelFormatFromString(formatStr); - - return mode; -} -#endif static std::string VideoModeToString(const cs::VideoMode& mode) { std::string rv; llvm::raw_string_ostream oss{rv}; diff --git a/wpilibc/src/main/native/cpp/Commands/Command.cpp b/wpilibc/src/main/native/cpp/Commands/Command.cpp index d9a10f16f1..621f5a2faa 100644 --- a/wpilibc/src/main/native/cpp/Commands/Command.cpp +++ b/wpilibc/src/main/native/cpp/Commands/Command.cpp @@ -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. * - *
Note that the recommended way to call this method is in the - * constructor.
+ * 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. * - *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.
+ * 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. * - *This is where you may want to wrap up loose ends, like shutting off a - * motor that was being used in the command.
+ * This is where you may want to wrap up loose ends, like shutting off a motor + * that was being used in the command. * - *Generally, it is useful to simply call the {@link Command#end() end()} - * method within this method, as done here.
+ * 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. * - *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.
+ * 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. * - *A command can not be canceled if it is a part of a command group, you - * must cancel the command group instead.
+ * 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. * - *By default a command will not run when the robot is disabled, and will in - * fact be canceled.
+ * 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; } diff --git a/wpilibc/src/main/native/cpp/Commands/CommandGroup.cpp b/wpilibc/src/main/native/cpp/Commands/CommandGroup.cpp index 37b65d577b..d5e796f46d 100644 --- a/wpilibc/src/main/native/cpp/Commands/CommandGroup.cpp +++ b/wpilibc/src/main/native/cpp/Commands/CommandGroup.cpp @@ -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. * - *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.
+ * 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. * - *It is recommended that this method be called in the constructor.
+ * 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. * - *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.
+ * 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. * - *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.
+ * 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. * - *It is recommended that this method be called in the constructor.
+ * 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. * - *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.
+ * 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. * - *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.
+ * 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. * - *It is recommended that this method be called in the constructor.
+ * 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. * - *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.
+ * 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. * - *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.
+ * 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. * - *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.
+ * 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. * - *It is recommended that this method be called in the constructor.
+ * It is recommended that this method be called in the constructor. * * @param command The command to be added * @param timeout The timeout (in seconds) diff --git a/wpilibc/src/main/native/cpp/Commands/ConditionalCommand.cpp b/wpilibc/src/main/native/cpp/Commands/ConditionalCommand.cpp index 164b64ef34..576994342e 100644 --- a/wpilibc/src/main/native/cpp/Commands/ConditionalCommand.cpp +++ b/wpilibc/src/main/native/cpp/Commands/ConditionalCommand.cpp @@ -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(); diff --git a/wpilibc/src/main/native/cpp/Commands/InstantCommand.cpp b/wpilibc/src/main/native/cpp/Commands/InstantCommand.cpp index d4a1a3a957..a9a6a67bdb 100644 --- a/wpilibc/src/main/native/cpp/Commands/InstantCommand.cpp +++ b/wpilibc/src/main/native/cpp/Commands/InstantCommand.cpp @@ -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) {} diff --git a/wpilibc/src/main/native/cpp/Commands/PIDSubsystem.cpp b/wpilibc/src/main/native/cpp/Commands/PIDSubsystem.cpp index d651f6abbb..5b08ed5f84 100644 --- a/wpilibc/src/main/native/cpp/Commands/PIDSubsystem.cpp +++ b/wpilibc/src/main/native/cpp/Commands/PIDSubsystem.cpp @@ -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_ptrWARNING: This should NOT be called in a constructor if the - * subsystem is a singleton.
+ * WARNING: This should NOT 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) { diff --git a/wpilibc/src/main/native/cpp/Commands/WaitUntilCommand.cpp b/wpilibc/src/main/native/cpp/Commands/WaitUntilCommand.cpp index c7c060e82a..301d9bf237 100644 --- a/wpilibc/src/main/native/cpp/Commands/WaitUntilCommand.cpp +++ b/wpilibc/src/main/native/cpp/Commands/WaitUntilCommand.cpp @@ -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. diff --git a/wpilibc/src/main/native/cpp/DigitalGlitchFilter.cpp b/wpilibc/src/main/native/cpp/DigitalGlitchFilter.cpp index a9bd112b3f..ed49b2e17e 100644 --- a/wpilibc/src/main/native/cpp/DigitalGlitchFilter.cpp +++ b/wpilibc/src/main/native/cpp/DigitalGlitchFilter.cpp @@ -54,10 +54,10 @@ void DigitalGlitchFilter::Add(DigitalSource* input) { } void DigitalGlitchFilter::DoAdd(DigitalSource* input, int requested_index) { - // Some sources from Counters and Encoders are null. By pushing the check + // Some sources from Counters and Encoders are null. By pushing the check // here, we catch the issue more generally. if (input) { - // we don't support GlitchFilters on AnalogTriggers. + // We don't support GlitchFilters on AnalogTriggers. if (input->IsAnalogTrigger()) { wpi_setErrorWithContext( -1, "Analog Triggers not supported for DigitalGlitchFilters"); diff --git a/wpilibc/src/main/native/cpp/DigitalInput.cpp b/wpilibc/src/main/native/cpp/DigitalInput.cpp index f1c5873ecf..f2cfedf92d 100644 --- a/wpilibc/src/main/native/cpp/DigitalInput.cpp +++ b/wpilibc/src/main/native/cpp/DigitalInput.cpp @@ -61,7 +61,7 @@ DigitalInput::~DigitalInput() { if (m_interrupt != HAL_kInvalidHandle) { int32_t status = 0; HAL_CleanInterrupts(m_interrupt, &status); - // ignore status, as an invalid handle just needs to be ignored. + // Ignore status, as an invalid handle just needs to be ignored. m_interrupt = HAL_kInvalidHandle; } diff --git a/wpilibc/src/main/native/cpp/DoubleSolenoid.cpp b/wpilibc/src/main/native/cpp/DoubleSolenoid.cpp index 8ea046792b..6fc412bb82 100644 --- a/wpilibc/src/main/native/cpp/DoubleSolenoid.cpp +++ b/wpilibc/src/main/native/cpp/DoubleSolenoid.cpp @@ -174,8 +174,8 @@ bool DoubleSolenoid::IsFwdSolenoidBlackListed() const { * * If a solenoid is shorted, it is added to the blacklist and * disabled until power cycle, or until faults are cleared. - * @see ClearAllPCMStickyFaults() * + * @see ClearAllPCMStickyFaults() * @return If solenoid is disabled due to short. */ bool DoubleSolenoid::IsRevSolenoidBlackListed() const { diff --git a/wpilibc/src/main/native/cpp/DriverStation.cpp b/wpilibc/src/main/native/cpp/DriverStation.cpp index 2a0321acfa..963ce3174c 100644 --- a/wpilibc/src/main/native/cpp/DriverStation.cpp +++ b/wpilibc/src/main/native/cpp/DriverStation.cpp @@ -762,7 +762,7 @@ void DriverStation::Run() { * copied from the cache. * * @param force True to force an update to the cache, otherwise update if 50ms - * have passed. + * have passed. * @param controlWord Structure to put the return control word data into. */ void DriverStation::UpdateControlWord(bool force, diff --git a/wpilibc/src/main/native/cpp/ErrorBase.cpp b/wpilibc/src/main/native/cpp/ErrorBase.cpp index 24faeaac56..bbb266a3a1 100644 --- a/wpilibc/src/main/native/cpp/ErrorBase.cpp +++ b/wpilibc/src/main/native/cpp/ErrorBase.cpp @@ -29,6 +29,7 @@ ErrorBase::ErrorBase() { HAL_Initialize(500, 0); } /** * @brief Retrieve the current error. + * * Get the current error information associated with this sensor. */ Error& ErrorBase::GetError() { return m_error; } @@ -42,7 +43,7 @@ void ErrorBase::ClearError() const { m_error.Clear(); } /** * @brief Set error information associated with a C library call that set an - * error to the "errno" global variable. + * error to the "errno" global variable. * * @param contextMessage A custom message from the code that set the error. * @param filename Filename of the error source @@ -76,7 +77,7 @@ void ErrorBase::SetErrnoError(llvm::StringRef contextMessage, /** * @brief Set the current error information associated from the nivision Imaq - * API. + * API. * * @param success The return from the function * @param contextMessage A custom message from the code that set the error. diff --git a/wpilibc/src/main/native/cpp/I2C.cpp b/wpilibc/src/main/native/cpp/I2C.cpp index 989d5b0042..fb44a4789a 100644 --- a/wpilibc/src/main/native/cpp/I2C.cpp +++ b/wpilibc/src/main/native/cpp/I2C.cpp @@ -150,17 +150,6 @@ bool I2C::ReadOnly(int count, uint8_t* buffer) { return HAL_ReadI2C(m_port, m_deviceAddress, buffer, count) < 0; } -/** - * Send a broadcast write to all devices on the I2C bus. - * - * This is not currently implemented! - * - * @param registerAddress The register to write on all devices on the bus. - * @param data The value to write to the devices. - */ -// [[gnu::warning("I2C::Broadcast() is not implemented.")]] void I2C::Broadcast( -// int registerAddress, uint8_t data) {} - /** * Verify that a device's registers contain expected values. * diff --git a/wpilibc/src/main/native/cpp/InterruptableSensorBase.cpp b/wpilibc/src/main/native/cpp/InterruptableSensorBase.cpp index 65883ea481..ea002cf427 100644 --- a/wpilibc/src/main/native/cpp/InterruptableSensorBase.cpp +++ b/wpilibc/src/main/native/cpp/InterruptableSensorBase.cpp @@ -81,7 +81,7 @@ void InterruptableSensorBase::CancelInterrupts() { wpi_assert(m_interrupt != HAL_kInvalidHandle); int32_t status = 0; HAL_CleanInterrupts(m_interrupt, &status); - // ignore status, as an invalid handle just needs to be ignored. + // Ignore status, as an invalid handle just needs to be ignored. m_interrupt = HAL_kInvalidHandle; } diff --git a/wpilibc/src/main/native/cpp/IterativeRobot.cpp b/wpilibc/src/main/native/cpp/IterativeRobot.cpp index 60b42468f4..a2a2c694c2 100644 --- a/wpilibc/src/main/native/cpp/IterativeRobot.cpp +++ b/wpilibc/src/main/native/cpp/IterativeRobot.cpp @@ -32,7 +32,7 @@ void IterativeRobot::StartCompetition() { // Loop forever, calling the appropriate mode-dependent function while (true) { - // wait for driver station data so the loop doesn't hog the CPU + // Wait for driver station data so the loop doesn't hog the CPU DriverStation::GetInstance().WaitForData(); LoopFunc(); diff --git a/wpilibc/src/main/native/cpp/IterativeRobotBase.cpp b/wpilibc/src/main/native/cpp/IterativeRobotBase.cpp index a0b819be10..ad42abef4f 100644 --- a/wpilibc/src/main/native/cpp/IterativeRobotBase.cpp +++ b/wpilibc/src/main/native/cpp/IterativeRobotBase.cpp @@ -149,8 +149,8 @@ void IterativeRobotBase::TestPeriodic() { void IterativeRobotBase::LoopFunc() { // Call the appropriate function depending upon the current robot mode if (IsDisabled()) { - // call DisabledInit() if we are now just entering disabled mode from - // either a different mode or from power-on + // Call DisabledInit() if we are now just entering disabled mode from + // either a different mode or from power-on. if (m_lastMode != Mode::kDisabled) { LiveWindow::GetInstance()->SetEnabled(false); DisabledInit(); @@ -159,8 +159,8 @@ void IterativeRobotBase::LoopFunc() { HAL_ObserveUserProgramDisabled(); DisabledPeriodic(); } else if (IsAutonomous()) { - // call AutonomousInit() if we are now just entering autonomous mode from - // either a different mode or from power-on + // Call AutonomousInit() if we are now just entering autonomous mode from + // either a different mode or from power-on. if (m_lastMode != Mode::kAutonomous) { LiveWindow::GetInstance()->SetEnabled(false); AutonomousInit(); @@ -169,8 +169,8 @@ void IterativeRobotBase::LoopFunc() { HAL_ObserveUserProgramAutonomous(); AutonomousPeriodic(); } else if (IsOperatorControl()) { - // call TeleopInit() if we are now just entering teleop mode from - // either a different mode or from power-on + // Call TeleopInit() if we are now just entering teleop mode from + // either a different mode or from power-on. if (m_lastMode != Mode::kTeleop) { LiveWindow::GetInstance()->SetEnabled(false); TeleopInit(); @@ -180,8 +180,8 @@ void IterativeRobotBase::LoopFunc() { HAL_ObserveUserProgramTeleop(); TeleopPeriodic(); } else { - // call TestInit() if we are now just entering test mode from - // either a different mode or from power-on + // Call TestInit() if we are now just entering test mode from + // either a different mode or from power-on. if (m_lastMode != Mode::kTest) { LiveWindow::GetInstance()->SetEnabled(true); TestInit(); diff --git a/wpilibc/src/main/native/cpp/Joystick.cpp b/wpilibc/src/main/native/cpp/Joystick.cpp index c656443b33..7666d21e0f 100644 --- a/wpilibc/src/main/native/cpp/Joystick.cpp +++ b/wpilibc/src/main/native/cpp/Joystick.cpp @@ -297,9 +297,6 @@ double Joystick::GetDirectionRadians() const { * Get the direction of the vector formed by the joystick and its origin * in degrees. * - * uses std::acos(-1) to represent Pi due to absence of readily accessible Pi - * constant in C++ - * * @return The direction of the vector in degrees */ double Joystick::GetDirectionDegrees() const { diff --git a/wpilibc/src/main/native/cpp/MotorSafetyHelper.cpp b/wpilibc/src/main/native/cpp/MotorSafetyHelper.cpp index b8fc6b3dfb..0b5a56fd91 100644 --- a/wpilibc/src/main/native/cpp/MotorSafetyHelper.cpp +++ b/wpilibc/src/main/native/cpp/MotorSafetyHelper.cpp @@ -49,6 +49,7 @@ MotorSafetyHelper::~MotorSafetyHelper() { /** * Feed the motor safety object. + * * Resets the timer on this object that is used to do the timeouts. */ void MotorSafetyHelper::Feed() { @@ -58,6 +59,7 @@ void MotorSafetyHelper::Feed() { /** * Set the expiration time for the corresponding motor safety object. + * * @param expirationTime The timeout value in seconds. */ void MotorSafetyHelper::SetExpiration(double expirationTime) { @@ -67,6 +69,7 @@ void MotorSafetyHelper::SetExpiration(double expirationTime) { /** * Retrieve the timeout value for the corresponding motor safety object. + * * @return the timeout value in seconds. */ double MotorSafetyHelper::GetExpiration() const { @@ -76,6 +79,7 @@ double MotorSafetyHelper::GetExpiration() const { /** * Determine if the motor is still operating or has timed out. + * * @return a true value if the motor is still operating normally and hasn't * timed out. */ @@ -86,6 +90,7 @@ bool MotorSafetyHelper::IsAlive() const { /** * Check if this motor has exceeded its timeout. + * * This method is called periodically to determine if this motor has exceeded * its timeout value. If it has, the stop method is called, and the motor is * shut down until its value is updated again. @@ -107,7 +112,9 @@ void MotorSafetyHelper::Check() { /** * Enable/disable motor safety for this device + * * Turn on and off the motor safety option for this PWM object. + * * @param enabled True if motor safety is enforced for this object */ void MotorSafetyHelper::SetSafetyEnabled(bool enabled) { @@ -117,7 +124,9 @@ void MotorSafetyHelper::SetSafetyEnabled(bool enabled) { /** * Return the state of the motor safety enabled flag + * * Return if the motor safety is currently enabled for this devicce. + * * @return True if motor safety is enforced for this device */ bool MotorSafetyHelper::IsSafetyEnabled() const { @@ -127,8 +136,9 @@ bool MotorSafetyHelper::IsSafetyEnabled() const { /** * Check the motors to see if any have timed out. - * This static method is called periodically to poll all the motors and stop - * any that have timed out. + * + * This static method is called periodically to poll all the motors and stop any + * that have timed out. */ void MotorSafetyHelper::CheckMotors() { std::lock_guardThe PWM value is set using a range of -1.0 to 1.0, appropriately scaling - * the value for the FPGA. + * The PWM value is set using a range of -1.0 to 1.0, appropriately scaling the + * value for the FPGA. * * @param speed The speed value between -1.0 and 1.0 to set. */ @@ -91,13 +91,13 @@ double NidecBrushless::GetExpiration() const { * Check if the motor is currently alive or stopped due to a timeout. * * @return a bool value that is true if the motor has NOT timed out and should - * still be running. + * still be running. */ bool NidecBrushless::IsAlive() const { return m_safetyHelper.IsAlive(); } /** - * Stop the motor. This is called by the MotorSafetyHelper object - * when it has a timeout for this PWM and needs to stop it from running. + * Stop the motor. This is called by the MotorSafetyHelper object when it has a + * timeout for this PWM and needs to stop it from running. */ void NidecBrushless::StopMotor() { Disable(); } diff --git a/wpilibc/src/main/native/cpp/Preferences.cpp b/wpilibc/src/main/native/cpp/Preferences.cpp index 8aa5ebb38e..09fce71acc 100644 --- a/wpilibc/src/main/native/cpp/Preferences.cpp +++ b/wpilibc/src/main/native/cpp/Preferences.cpp @@ -17,7 +17,7 @@ using namespace frc; -/** The Preferences table name */ +// The Preferences table name static llvm::StringRef kTableName{"Preferences"}; Preferences::Preferences() @@ -124,8 +124,8 @@ int64_t Preferences::GetLong(llvm::StringRef key, int64_t defaultValue) { /** * Puts the given string into the preferences table. * - *
The value may not have quotation marks, nor may the key - * have any whitespace nor an equals sign
+ * The value may not have quotation marks, nor may the key have any whitespace + * nor an equals sign. * * @param key the key * @param value the value @@ -139,7 +139,7 @@ void Preferences::PutString(llvm::StringRef key, llvm::StringRef value) { /** * Puts the given int into the preferences table. * - *The key may not have any whitespace nor an equals sign
+ * The key may not have any whitespace nor an equals sign. * * @param key the key * @param value the value @@ -153,7 +153,7 @@ void Preferences::PutInt(llvm::StringRef key, int value) { /** * Puts the given double into the preferences table. * - *The key may not have any whitespace nor an equals sign
+ * The key may not have any whitespace nor an equals sign. * * @param key the key * @param value the value @@ -167,7 +167,7 @@ void Preferences::PutDouble(llvm::StringRef key, double value) { /** * Puts the given float into the preferences table. * - *The key may not have any whitespace nor an equals sign
+ * The key may not have any whitespace nor an equals sign. * * @param key the key * @param value the value @@ -181,7 +181,7 @@ void Preferences::PutFloat(llvm::StringRef key, float value) { /** * Puts the given boolean into the preferences table. * - *The key may not have any whitespace nor an equals sign
+ * The key may not have any whitespace nor an equals sign. * * @param key the key * @param value the value @@ -195,7 +195,7 @@ void Preferences::PutBoolean(llvm::StringRef key, bool value) { /** * Puts the given long (int64_t) into the preferences table. * - *The key may not have any whitespace nor an equals sign
+ * The key may not have any whitespace nor an equals sign. * * @param key the key * @param value the value diff --git a/wpilibc/src/main/native/cpp/Relay.cpp b/wpilibc/src/main/native/cpp/Relay.cpp index 9c5e0000fb..c5b5c090d3 100644 --- a/wpilibc/src/main/native/cpp/Relay.cpp +++ b/wpilibc/src/main/native/cpp/Relay.cpp @@ -179,7 +179,7 @@ void Relay::Set(Relay::Value value) { * Gets the current state of the relay. * * When set to kForwardOnly or kReverseOnly, value is returned as kOn/kOff not - * kForward/kReverse (per the recommendation in Set) + * kForward/kReverse (per the recommendation in Set). * * @return The current state of the relay as a Relay::Value */ @@ -220,7 +220,8 @@ Relay::Value Relay::Get() const { int Relay::GetChannel() const { return m_channel; } /** - * Set the expiration time for the Relay object + * Set the expiration time for the Relay object. + * * @param timeout The timeout (in seconds) for this relay object */ void Relay::SetExpiration(double timeout) { @@ -229,6 +230,7 @@ void Relay::SetExpiration(double timeout) { /** * Return the expiration time for the relay object. + * * @return The expiration time value. */ double Relay::GetExpiration() const { return m_safetyHelper->GetExpiration(); } diff --git a/wpilibc/src/main/native/cpp/RobotBase.cpp b/wpilibc/src/main/native/cpp/RobotBase.cpp index 087c33f53e..9ecfcedcb9 100644 --- a/wpilibc/src/main/native/cpp/RobotBase.cpp +++ b/wpilibc/src/main/native/cpp/RobotBase.cpp @@ -68,45 +68,51 @@ RobotBase::RobotBase() : m_ds(DriverStation::GetInstance()) { /** * Determine if the Robot is currently enabled. + * * @return True if the Robot is currently enabled by the field controls. */ bool RobotBase::IsEnabled() const { return m_ds.IsEnabled(); } /** * Determine if the Robot is currently disabled. + * * @return True if the Robot is currently disabled by the field controls. */ bool RobotBase::IsDisabled() const { return m_ds.IsDisabled(); } /** * Determine if the robot is currently in Autonomous mode. + * * @return True if the robot is currently operating Autonomously as determined - * by the field controls. + * by the field controls. */ bool RobotBase::IsAutonomous() const { return m_ds.IsAutonomous(); } /** * Determine if the robot is currently in Operator Control mode. + * * @return True if the robot is currently operating in Tele-Op mode as - * determined by the field controls. + * determined by the field controls. */ bool RobotBase::IsOperatorControl() const { return m_ds.IsOperatorControl(); } /** * Determine if the robot is currently in Test mode. + * * @return True if the robot is currently running tests as determined by the - * field controls. + * field controls. */ bool RobotBase::IsTest() const { return m_ds.IsTest(); } /** * Indicates if new data is available from the driver station. + * * @return Has new data arrived over the network since the last time this - * function was called? + * function was called? */ bool RobotBase::IsNewDataAvailable() const { return m_ds.IsNewControlData(); } /** - * Gets the ID of the main robot thread + * Gets the ID of the main robot thread. */ std::thread::id RobotBase::GetThreadId() { return m_threadId; } diff --git a/wpilibc/src/main/native/cpp/SmartDashboard/SmartDashboard.cpp b/wpilibc/src/main/native/cpp/SmartDashboard/SmartDashboard.cpp index 8a5bfc84b0..92051f187c 100644 --- a/wpilibc/src/main/native/cpp/SmartDashboard/SmartDashboard.cpp +++ b/wpilibc/src/main/native/cpp/SmartDashboard/SmartDashboard.cpp @@ -183,8 +183,9 @@ bool SmartDashboard::PutValue(llvm::StringRef keyName, /** * Gets the current value in the table, setting it if it does not exist. + * * @param key the key - * @param defaultValue the default value to set if key doesn't exist. + * @param defaultValue The default value to set if key doesn't exist. * @returns False if the table key exists with a different type */ bool SmartDashboard::SetDefaultValue(llvm::StringRef key, @@ -255,8 +256,9 @@ bool SmartDashboard::PutNumber(llvm::StringRef keyName, double value) { /** * Gets the current value in the table, setting it if it does not exist. - * @param key the key - * @param defaultValue the default value to set if key doesn't exist. + * + * @param key The key. + * @param defaultValue The default value to set if key doesn't exist. * @returns False if the table key exists with a different type */ bool SmartDashboard::SetDefaultNumber(llvm::StringRef key, @@ -315,13 +317,14 @@ std::string SmartDashboard::GetString(llvm::StringRef keyName, } /** - * Put a boolean array in the table + * Put a boolean array in the table. + * * @param key the key to be assigned to * @param value the value that will be assigned * @return False if the table key already exists with a different type * * @note The array must be of int's rather than of bool's because - * std::vectorDo not call this method directly from the main - * thread.
+ * Do not call this method directly from the main thread. */ void VisionRunnerBase::RunForever() { if (std::this_thread::get_id() == RobotBase::GetThreadId()) { diff --git a/wpilibc/src/main/native/include/ADXL345_I2C.h b/wpilibc/src/main/native/include/ADXL345_I2C.h index 425cb58b61..307936b249 100644 --- a/wpilibc/src/main/native/include/ADXL345_I2C.h +++ b/wpilibc/src/main/native/include/ADXL345_I2C.h @@ -21,40 +21,19 @@ namespace frc { * ADXL345 Accelerometer on I2C. * * This class allows access to a Analog Devices ADXL345 3-axis accelerometer on - * an I2C bus. - * This class assumes the default (not alternate) sensor address of 0x1D (7-bit - * address). + * an I2C bus. This class assumes the default (not alternate) sensor address of + * 0x1D (7-bit address). */ class ADXL345_I2C : public Accelerometer, public LiveWindowSendable { - protected: - static const int kAddress = 0x1D; - static const int kPowerCtlRegister = 0x2D; - static const int kDataFormatRegister = 0x31; - static const int kDataRegister = 0x32; - static constexpr double kGsPerLSB = 0.00390625; - enum PowerCtlFields { - kPowerCtl_Link = 0x20, - kPowerCtl_AutoSleep = 0x10, - kPowerCtl_Measure = 0x08, - kPowerCtl_Sleep = 0x04 - }; - enum DataFormatFields { - kDataFormat_SelfTest = 0x80, - kDataFormat_SPI = 0x40, - kDataFormat_IntInvert = 0x20, - kDataFormat_FullRes = 0x08, - kDataFormat_Justify = 0x04 - }; - public: enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 }; + struct AllAxes { double XAxis; double YAxis; double ZAxis; }; - public: explicit ADXL345_I2C(I2C::Port port, Range range = kRange_2G, int deviceAddress = kAddress); virtual ~ADXL345_I2C() = default; @@ -80,6 +59,27 @@ class ADXL345_I2C : public Accelerometer, public LiveWindowSendable { protected: I2C m_i2c; + static const int kAddress = 0x1D; + static const int kPowerCtlRegister = 0x2D; + static const int kDataFormatRegister = 0x31; + static const int kDataRegister = 0x32; + static constexpr double kGsPerLSB = 0.00390625; + + enum PowerCtlFields { + kPowerCtl_Link = 0x20, + kPowerCtl_AutoSleep = 0x10, + kPowerCtl_Measure = 0x08, + kPowerCtl_Sleep = 0x04 + }; + + enum DataFormatFields { + kDataFormat_SelfTest = 0x80, + kDataFormat_SPI = 0x40, + kDataFormat_IntInvert = 0x20, + kDataFormat_FullRes = 0x08, + kDataFormat_Justify = 0x04 + }; + private: nt::NetworkTableEntry m_xEntry; nt::NetworkTableEntry m_yEntry; diff --git a/wpilibc/src/main/native/include/ADXL345_SPI.h b/wpilibc/src/main/native/include/ADXL345_SPI.h index 3868606598..1699867178 100644 --- a/wpilibc/src/main/native/include/ADXL345_SPI.h +++ b/wpilibc/src/main/native/include/ADXL345_SPI.h @@ -25,32 +25,12 @@ class DigitalOutput; * ADXL345 Accelerometer on SPI. * * This class allows access to an Analog Devices ADXL345 3-axis accelerometer - * via SPI. - * This class assumes the sensor is wired in 4-wire SPI mode. + * via SPI. This class assumes the sensor is wired in 4-wire SPI mode. */ class ADXL345_SPI : public Accelerometer, public LiveWindowSendable { - protected: - static const int kPowerCtlRegister = 0x2D; - static const int kDataFormatRegister = 0x31; - static const int kDataRegister = 0x32; - static constexpr double kGsPerLSB = 0.00390625; - enum SPIAddressFields { kAddress_Read = 0x80, kAddress_MultiByte = 0x40 }; - enum PowerCtlFields { - kPowerCtl_Link = 0x20, - kPowerCtl_AutoSleep = 0x10, - kPowerCtl_Measure = 0x08, - kPowerCtl_Sleep = 0x04 - }; - enum DataFormatFields { - kDataFormat_SelfTest = 0x80, - kDataFormat_SPI = 0x40, - kDataFormat_IntInvert = 0x20, - kDataFormat_FullRes = 0x08, - kDataFormat_Justify = 0x04 - }; - public: enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 }; + struct AllAxes { double XAxis; double YAxis; @@ -82,6 +62,28 @@ class ADXL345_SPI : public Accelerometer, public LiveWindowSendable { protected: SPI m_spi; + static const int kPowerCtlRegister = 0x2D; + static const int kDataFormatRegister = 0x31; + static const int kDataRegister = 0x32; + static constexpr double kGsPerLSB = 0.00390625; + + enum SPIAddressFields { kAddress_Read = 0x80, kAddress_MultiByte = 0x40 }; + + enum PowerCtlFields { + kPowerCtl_Link = 0x20, + kPowerCtl_AutoSleep = 0x10, + kPowerCtl_Measure = 0x08, + kPowerCtl_Sleep = 0x04 + }; + + enum DataFormatFields { + kDataFormat_SelfTest = 0x80, + kDataFormat_SPI = 0x40, + kDataFormat_IntInvert = 0x20, + kDataFormat_FullRes = 0x08, + kDataFormat_Justify = 0x04 + }; + private: nt::NetworkTableEntry m_xEntry; nt::NetworkTableEntry m_yEntry; diff --git a/wpilibc/src/main/native/include/ADXRS450_Gyro.h b/wpilibc/src/main/native/include/ADXRS450_Gyro.h index ed7a3560b1..3816d8fa9f 100644 --- a/wpilibc/src/main/native/include/ADXRS450_Gyro.h +++ b/wpilibc/src/main/native/include/ADXRS450_Gyro.h @@ -16,6 +16,7 @@ namespace frc { /** * Use a rate gyro to return the robots heading relative to a starting position. + * * The Gyro class tracks the robots heading based on the starting position. As * the robot rotates the new heading is computed by integrating the rate of * rotation returned by the sensor. When the class is instantiated, it does a diff --git a/wpilibc/src/main/native/include/AnalogAccelerometer.h b/wpilibc/src/main/native/include/AnalogAccelerometer.h index ad3a53ddb6..ed3c9d96d1 100644 --- a/wpilibc/src/main/native/include/AnalogAccelerometer.h +++ b/wpilibc/src/main/native/include/AnalogAccelerometer.h @@ -20,6 +20,7 @@ namespace frc { /** * Handle operation of an analog accelerometer. + * * The accelerometer reads acceleration directly through the sensor. Many * sensors have multiple axis and can be treated as multiple devices. Each is * calibrated by finding the center value over a period of time. diff --git a/wpilibc/src/main/native/include/AnalogInput.h b/wpilibc/src/main/native/include/AnalogInput.h index f43e6123e9..3452c7cac0 100644 --- a/wpilibc/src/main/native/include/AnalogInput.h +++ b/wpilibc/src/main/native/include/AnalogInput.h @@ -26,8 +26,8 @@ namespace frc { * * Connected to each analog channel is an averaging and oversampling engine. * This engine accumulates the specified ( by SetAverageBits() and - * SetOversampleBits() ) number of samples before returning a new value. This - * is not a sliding window average. The only difference between the oversampled + * SetOversampleBits() ) number of samples before returning a new value. This is + * not a sliding window average. The only difference between the oversampled * samples and the averaged samples is that the oversampled samples are simply * accumulated effectively increasing the resolution, while the averaged samples * are divided by the number of samples to retain the resolution, but get more diff --git a/wpilibc/src/main/native/include/AnalogPotentiometer.h b/wpilibc/src/main/native/include/AnalogPotentiometer.h index ff1e2bf9ca..02b4da5077 100644 --- a/wpilibc/src/main/native/include/AnalogPotentiometer.h +++ b/wpilibc/src/main/native/include/AnalogPotentiometer.h @@ -18,30 +18,30 @@ namespace frc { /** - * Class for reading analog potentiometers. Analog potentiometers read - * in an analog voltage that corresponds to a position. The position is - * in whichever units you choose, by way of the scaling and offset - * constants passed to the constructor. + * Class for reading analog potentiometers. Analog potentiometers read in an + * analog voltage that corresponds to a position. The position is in whichever + * units you choose, by way of the scaling and offset constants passed to the + * constructor. */ class AnalogPotentiometer : public Potentiometer, public LiveWindowSendable { public: /** * AnalogPotentiometer constructor. * - * Use the fullRange and offset values so that the output produces - * meaningful values. I.E: you have a 270 degree potentiometer and - * you want the output to be degrees with the halfway point as 0 - * degrees. The fullRange value is 270.0(degrees) and the offset is - * -135.0 since the halfway point after scaling is 135 degrees. + * Use the fullRange and offset values so that the output produces meaningful + * values. I.E: you have a 270 degree potentiometer and you want the output to + * be degrees with the halfway point as 0 degrees. The fullRange value is + * 270.0 degrees and the offset is -135.0 since the halfway point after + * scaling is 135 degrees. * - * This will calculate the result from the fullRange times the - * fraction of the supply voltage, plus the offset. + * This will calculate the result from the fullRange times the fraction of the + * supply voltage, plus the offset. * - * @param channel The analog channel this potentiometer is plugged into. + * @param channel The analog channel this potentiometer is plugged into. * @param fullRange The scaling to multiply the voltage by to get a meaningful - * unit. - * @param offset The offset to add to the scaled value for controlling the - * zero value + * unit. + * @param offset The offset to add to the scaled value for controlling the + * zero value. */ explicit AnalogPotentiometer(int channel, double fullRange = 1.0, double offset = 0.0); diff --git a/wpilibc/src/main/native/include/Buttons/Button.h b/wpilibc/src/main/native/include/Buttons/Button.h index 1d2046ed7f..500d7fd7fc 100644 --- a/wpilibc/src/main/native/include/Buttons/Button.h +++ b/wpilibc/src/main/native/include/Buttons/Button.h @@ -15,14 +15,13 @@ namespace frc { /** * This class provides an easy way to link commands to OI inputs. * - * It is very easy to link a button to a command. For instance, you could - * link the trigger button of a joystick to a "score" command. + * It is very easy to link a button to a command. For instance, you could link + * the trigger button of a joystick to a "score" command. * * 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. + * names renamed to fit the Button object use. */ class Button : public Trigger { public: diff --git a/wpilibc/src/main/native/include/Buttons/Trigger.h b/wpilibc/src/main/native/include/Buttons/Trigger.h index 16e3e8770a..a5de72b6c3 100644 --- a/wpilibc/src/main/native/include/Buttons/Trigger.h +++ b/wpilibc/src/main/native/include/Buttons/Trigger.h @@ -20,17 +20,15 @@ class Command; /** * This class provides an easy way to link commands to inputs. * - * It is very easy to link a polled input to a command. For instance, you could + * It is very easy to link a polled input to a command. For instance, you could * link the trigger button of a joystick to a "score" command or an encoder - * reaching - * a particular value. + * reaching a particular value. * * It is encouraged that teams write a subclass of Trigger if they want to have * something unusual (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 + * 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. + * functionality of the Trigger class. */ class Trigger : public Sendable { public: diff --git a/wpilibc/src/main/native/include/CANSpeedController.h b/wpilibc/src/main/native/include/CANSpeedController.h index 43134f67c2..81ec6a0446 100644 --- a/wpilibc/src/main/native/include/CANSpeedController.h +++ b/wpilibc/src/main/native/include/CANSpeedController.h @@ -36,7 +36,7 @@ class CANSpeedController : public SpeedController { kTemperatureFault = 2, kBusVoltageFault = 4, kGateDriverFault = 8, - /* SRX extensions */ + // SRX extensions kFwdLimitSwitch = 0x10, kRevLimitSwitch = 0x20, kFwdSoftLimit = 0x40, @@ -46,22 +46,34 @@ class CANSpeedController : public SpeedController { enum Limits { kForwardLimit = 1, kReverseLimit = 2 }; enum NeutralMode { - /** Use the NeutralMode that is set by the jumper wire on the CAN device */ + /** + * Use the NeutralMode that is set by the jumper wire on the CAN device + */ kNeutralMode_Jumper = 0, - /** Stop the motor's rotation by applying a force. */ + /** + * Stop the motor's rotation by applying a force. + */ kNeutralMode_Brake = 1, - /** Do not attempt to stop the motor. Instead allow it to coast to a stop - without applying resistance. */ + /** + * Do not attempt to stop the motor. Instead allow it to coast to a stop + * without applying resistance. + */ kNeutralMode_Coast = 2 }; enum LimitMode { - /** Only use switches for limits */ + /** + * Only use switches for limits + */ kLimitMode_SwitchInputsOnly = 0, - /** Use both switches and soft limits */ + /** + * Use both switches and soft limits + */ kLimitMode_SoftPositionLimits = 1, - /* SRX extensions */ - /** Disable switches and disable soft limits */ + // SRX extensions + /** + * Disable switches and disable soft limits + */ kLimitMode_SrxDisableSwitchInputs = 2, }; @@ -98,9 +110,6 @@ class CANSpeedController : public SpeedController { virtual void ConfigReverseLimit(double reverseLimitPosition) = 0; virtual void ConfigMaxOutputVoltage(double voltage) = 0; virtual void ConfigFaultTime(double faultTime) = 0; - // Hold off on interface until we figure out ControlMode enums. - // virtual void SetControlMode(ControlMode mode) = 0; - // virtual ControlMode GetControlMode() const = 0; }; } // namespace frc diff --git a/wpilibc/src/main/native/include/CameraServer.h b/wpilibc/src/main/native/include/CameraServer.h index bf9d51958c..bad39d8ee8 100644 --- a/wpilibc/src/main/native/include/CameraServer.h +++ b/wpilibc/src/main/native/include/CameraServer.h @@ -27,6 +27,7 @@ namespace frc { /** * Singleton class for creating and keeping camera servers. + * * Also publishes camera information to NetworkTables. */ class CameraServer : public ErrorBase { @@ -42,26 +43,25 @@ class CameraServer : public ErrorBase { static CameraServer* GetInstance(); #ifdef __linux__ - // USBCamera does not work on anything except linux + // USBCamera does not work on anything except Linux. /** * Start automatically capturing images to send to the dashboard. * - *You should call this method to see a camera feed on the dashboard. - * If you also want to perform vision processing on the roboRIO, use - * getVideo() to get access to the camera images. + * You should call this method to see a camera feed on the dashboard. If you + * also want to perform vision processing on the roboRIO, use getVideo() to + * get access to the camera images. * - * The first time this overload is called, it calls - * {@link #StartAutomaticCapture(int)} with device 0, creating a camera - * named "USB Camera 0". Subsequent calls increment the device number - * (e.g. 1, 2, etc). + * The first time this overload is called, it calls StartAutomaticCapture() + * with device 0, creating a camera named "USB Camera 0". Subsequent calls + * increment the device number (e.g. 1, 2, etc). */ cs::UsbCamera StartAutomaticCapture(); /** * Start automatically capturing images to send to the dashboard. * - *
This overload calls {@link #StartAutomaticCapture(String, int)} with - * a name of "USB Camera {dev}". + * This overload calls StartAutomaticCapture() with a name of "USB Camera + * {dev}". * * @param dev The device number of the camera interface */ @@ -71,7 +71,7 @@ class CameraServer : public ErrorBase { * Start automatically capturing images to send to the dashboard. * * @param name The name to give the camera - * @param dev The device number of the camera interface + * @param dev The device number of the camera interface */ cs::UsbCamera StartAutomaticCapture(llvm::StringRef name, int dev); @@ -96,8 +96,7 @@ class CameraServer : public ErrorBase { /** * Adds an Axis IP camera. * - *
This overload calls {@link #AddAxisCamera(String, String)} with - * name "Axis Camera". + * This overload calls AddAxisCamera() with name "Axis Camera". * * @param host Camera host IP or DNS name (e.g. "10.x.y.11") */ @@ -106,8 +105,7 @@ class CameraServer : public ErrorBase { /** * Adds an Axis IP camera. * - *
This overload calls {@link #AddAxisCamera(String, String)} with - * name "Axis Camera". + * This overload calls AddAxisCamera() with name "Axis Camera". * * @param host Camera host IP or DNS name (e.g. "10.x.y.11") */ @@ -116,8 +114,7 @@ class CameraServer : public ErrorBase { /** * Adds an Axis IP camera. * - *
This overload calls {@link #AddAxisCamera(String, String)} with - * name "Axis Camera". + * This overload calls AddAxisCamera() with name "Axis Camera". * * @param host Camera host IP or DNS name (e.g. "10.x.y.11") */ @@ -126,8 +123,7 @@ class CameraServer : public ErrorBase { /** * Adds an Axis IP camera. * - *
This overload calls {@link #AddAxisCamera(String, String[])} with - * name "Axis Camera". + * This overload calls AddAxisCamera() with name "Axis Camera". * * @param hosts Array of Camera host IPs/DNS names */ @@ -136,8 +132,7 @@ class CameraServer : public ErrorBase { /** * Adds an Axis IP camera. * - *
This overload calls {@link #AddAxisCamera(String, String[])} with - * name "Axis Camera". + * This overload calls AddAxisCamera() with name "Axis Camera". * * @param hosts Array of Camera host IPs/DNS names */ @@ -253,8 +248,8 @@ class CameraServer : public ErrorBase { /** * Get server for the primary camera feed. * - *
This is only valid to call after a camera feed has been added - * with StartAutomaticCapture() or AddServer(). + * This is only valid to call after a camera feed has been added with + * StartAutomaticCapture() or AddServer(). */ cs::VideoSink GetServer(); @@ -285,7 +280,7 @@ class CameraServer : public ErrorBase { * StartAutomaticCapture method. * * @deprecated Use SetResolution on the UsbCamera returned by - * StartAutomaticCapture() instead. + * StartAutomaticCapture() instead. * @param size The size to use */ void SetSize(int size); diff --git a/wpilibc/src/main/native/include/Commands/Command.h b/wpilibc/src/main/native/include/Commands/Command.h index 1c4fcc7bb1..898f372b8a 100644 --- a/wpilibc/src/main/native/include/Commands/Command.h +++ b/wpilibc/src/main/native/include/Commands/Command.h @@ -22,29 +22,24 @@ class Subsystem; /** * The Command class is at the very core of the entire command framework. - * Every command can be started with a call to {@link Command#Start() Start()}. - * Once a command is started it will call {@link Command#Initialize() - * Initialize()}, and then will repeatedly call - * {@link Command#Execute() Execute()} until the - * {@link Command#IsFinished() IsFinished()} returns true. Once it does, - * {@link Command#End() End()} will be called. * - *
However, if at any point while it is running {@link Command#Cancel() - * Cancel()} is called, then the command will be stopped and - * {@link Command#Interrupted() Interrupted()} will be called.
+ * Every command can be started with a call to Start(). Once a command is + * started it will call Initialize(), and then will repeatedly call Execute() + * until the IsFinished() returns true. Once it does,End() will be called. * - *If a command uses a {@link Subsystem}, then it should specify that it does - * so by calling the {@link Command#Requires(Subsystem) Requires(...)} method - * in its constructor. Note that a Command may have multiple requirements, and - * {@link Command#Requires(Subsystem) Requires(...)} should be called for each - * one.
+ * However, if at any point while it is running Cancel() is called, then the + * command will be stopped and Interrupted() will be called. * - *If a command is running and a new command with shared requirements is - * started, then one of two things will happen. If the active command is - * interruptible, then {@link Command#Cancel() Cancel()} will be called and the - * command will be removed to make way for the new one. If the active command - * is not interruptible, the other one will not even be started, and the active - * one will continue functioning.
+ * If a command uses a Subsystem, then it should specify that it does so by + * calling the Requires() method in its constructor. Note that a Command may + * have multiple requirements, and Requires() should be called for each one. + * + * If a command is running and a new command with shared requirements is + * started, then one of two things will happen. If the active command is + * interruptible, then Cancel() will be called and the command will be removed + * to make way for the new one. If the active command is not interruptible, the + * other one will not even be started, and the active one will continue + * functioning. * * @see CommandGroup * @see Subsystem @@ -88,19 +83,19 @@ class Command : public ErrorBase, public NamedSendable { /** * Returns whether this command is finished. - * If it is, then the command will be removed and {@link Command#end() end()} - * will be called. * - *It may be useful for a team to reference the {@link Command#isTimedOut() - * isTimedOut()} method for time-sensitive commands.
+ * If it is, then the command will be removed and End() will be called. * - *Returning false will result in the command never ending automatically. + * It may be useful for a team to reference the IsTimedOut() method for + * time-sensitive commands. + * + * Returning false will result in the command never ending automatically. * It may still be cancelled manually or interrupted by another command. * Returning true will result in the command executing once and finishing - * immediately. We recommend using {@link InstantCommand} for this.
+ * immediately. We recommend using InstantCommand for this. * - * @return whether this command is finished. - * @see Command#isTimedOut() isTimedOut() + * @return Whether this command is finished. + * @see IsTimedOut() */ virtual bool IsFinished() = 0; @@ -117,42 +112,41 @@ class Command : public ErrorBase, public NamedSendable { private: void LockChanges(); - /*synchronized*/ void Removed(); + void Removed(); void StartRunning(); void StartTiming(); - /** The name of this command */ + // The name of this command std::string m_name; - /** The time since this command was initialized */ + // The time since this command was initialized double m_startTime = -1; - /** The time (in seconds) before this command "times out" (or -1 if no - * timeout) */ + // The time (in seconds) before this command "times out" (-1 if no timeout) double m_timeout; - /** Whether or not this command has been initialized */ + // Whether or not this command has been initialized bool m_initialized = false; - /** The requirements (or null if no requirements) */ + // The requirements (or null if no requirements) SubsystemSet m_requirements; - /** Whether or not it is running */ + // Whether or not it is running bool m_running = false; - /** Whether or not it is interruptible*/ + // Whether or not it is interruptible bool m_interruptible = true; - /** Whether or not it has been canceled */ + // Whether or not it has been canceled bool m_canceled = false; - /** Whether or not it has been locked */ + // Whether or not it has been locked bool m_locked = false; - /** Whether this command should run when the robot is disabled */ + // Whether this command should run when the robot is disabled bool m_runWhenDisabled = false; - /** The {@link CommandGroup} this is in */ + // The CommandGroup this is in CommandGroup* m_parent = nullptr; int m_commandID = m_commandCounter++; diff --git a/wpilibc/src/main/native/include/Commands/CommandGroup.h b/wpilibc/src/main/native/include/Commands/CommandGroup.h index 34f7767a04..f8bd70d98b 100644 --- a/wpilibc/src/main/native/include/Commands/CommandGroup.h +++ b/wpilibc/src/main/native/include/Commands/CommandGroup.h @@ -17,21 +17,18 @@ namespace frc { /** - * A {@link CommandGroup} is a list of commands which are executed in sequence. + * A CommandGroup is a list of commands which are executed in sequence. * - *Commands in a {@link CommandGroup} are added using the {@link - * CommandGroup#AddSequential(Command) AddSequential(...)} method and are - * called sequentially. {@link CommandGroup CommandGroups} are themselves - * {@link Command Commands} and can be given to other - * {@link CommandGroup CommandGroups}.
+ * Commands in a CommandGroup are added using the AddSequential() method and are + * called sequentially. CommandGroups are themselves Commands and can be given + * to other CommandGroups. * - *{@link CommandGroup CommandGroups} will carry all of the requirements of - * their {@link Command subcommands}. Additional requirements can be specified - * by calling {@link CommandGroup#Requires(Subsystem) Requires(...)} normally - * in the constructor.
+ * CommandGroups will carry all of the requirements of their Command + * subcommands. Additional requirements can be specified by calling Requires() + * normally in the constructor. * - *CommandGroups can also execute commands in parallel, simply by adding them - * using {@link CommandGroup#AddParallel(Command) AddParallel(...)}.
+ * CommandGroups can also execute commands in parallel, simply by adding them + * using AddParallel(). * * @see Command * @see Subsystem @@ -63,13 +60,13 @@ class CommandGroup : public Command { private: void CancelConflicts(Command* command); - /** The commands in this group (stored in entries) */ + // The commands in this group (stored in entries) std::vector- * A {@link ConditionalCommand} uses m_condition to determine whether it should - * run m_onTrue or m_onFalse. - *
+ * A ConditionalCommand uses m_condition to determine whether it should run + * m_onTrue or m_onFalse. * - *- * A {@link ConditionalCommand} adds the proper {@link Command} to the {@link - * Scheduler} during {@link ConditionalCommand#initialize()} and then {@link - * ConditionalCommand#isFinished()} will return true once that {@link Command} - * has finished executing. - *
+ * A ConditionalCommand adds the proper Command to the Scheduler during + * Initialize() and then IsFinished() will return true once that Command has + * finished executing. * - *- * If no {@link Command} is specified for m_onFalse, the occurrence of that - * condition will be a no-op. - *
+ * If no Command is specified for m_onFalse, the occurrence of that condition + * will be a no-op. * * @see Command * @see Scheduler @@ -59,21 +51,13 @@ class ConditionalCommand : public Command { void Interrupted() override; private: - /** - * The Command to execute if {@link ConditionalCommand#Condition()} returns - * true - */ + // The Command to execute if Condition() returns true Command* m_onTrue; - /** - * The Command to execute if {@link ConditionalCommand#Condition()} returns - * false - */ + // The Command to execute if Condition() returns false Command* m_onFalse; - /** - * Stores command chosen by condition - */ + // Stores command chosen by condition Command* m_chosenCommand = nullptr; }; diff --git a/wpilibc/src/main/native/include/Commands/InstantCommand.h b/wpilibc/src/main/native/include/Commands/InstantCommand.h index a2d22d5f3d..d69e3148ff 100644 --- a/wpilibc/src/main/native/include/Commands/InstantCommand.h +++ b/wpilibc/src/main/native/include/Commands/InstantCommand.h @@ -16,8 +16,7 @@ namespace frc { /** * This command will execute once, then finish immediately afterward. * - *Subclassing {@link InstantCommand} is shorthand for returning true from
- * {@link Command isFinished}.
+ * Subclassing InstantCommand is shorthand for returning true from IsFinished().
*/
class InstantCommand : public Command {
public:
diff --git a/wpilibc/src/main/native/include/Commands/PIDCommand.h b/wpilibc/src/main/native/include/Commands/PIDCommand.h
index e6bff27468..62c8e9528c 100644
--- a/wpilibc/src/main/native/include/Commands/PIDCommand.h
+++ b/wpilibc/src/main/native/include/Commands/PIDCommand.h
@@ -50,7 +50,7 @@ class PIDCommand : public Command, public PIDOutput, public PIDSource {
virtual void UsePIDOutput(double output) = 0;
private:
- /** The internal {@link PIDController} */
+ // The internal PIDController
std::shared_ptr It provides some convenience methods to run an internal {@link
- * PIDController}. It also allows access to the internal {@link PIDController}
- * in order to give total control to the programmer. This class loads and saves from a file inside the roboRIO. The user can
- * not access the file directly, but may modify values at specific fields which
- * will then be automatically periodically saved to the file by the NetworkTable
- * server. This class is thread safe. This will also interact with {@link NetworkTable} by creating a table
- * called "Preferences" with all the key-value pairs. For instance, you may wish to be able to select between multiple
- * autonomous modes. You can do this by putting every possible {@link Command}
- * you want to run as an autonomous into a {@link SendableChooser} and then put
- * it into the {@link SmartDashboard} to have a list of options appear on the
- * laptop. Once autonomous starts, simply ask the {@link SendableChooser} what
- * the selected value is.