From 9df3116c39e062aaa6951176db1a35654b4c0962 Mon Sep 17 00:00:00 2001 From: sciencewhiz Date: Thu, 21 Nov 2024 19:56:18 -0800 Subject: [PATCH] Simplify RLIs with :lineno-match: (#2851) * Simplify RLIs with :lineno-match: Don't need to specify the starting line number which is prone to errors * Avoid disjoint lines --- .../contributing/frc-docs/style-guide.rst | 12 +-- source/docs/romi-robot/programming-romi.rst | 3 +- .../controllers/profiled-pidcontroller.rst | 9 +-- .../controllers/trapezoidal-profiles.rst | 9 +-- .../state-space-flywheel-walkthrough.rst | 80 +++++++------------ .../state-space/state-space-observers.rst | 12 +-- .../state-space-pose-estimators.rst | 18 ++--- .../trajectories/troubleshooting.rst | 6 +- .../profiling-with-visualvm.rst | 3 +- .../software/basic-programming/java-gc.rst | 3 +- .../binding-commands-to-triggers.rst | 18 ++--- .../commandbased/command-compositions.rst | 18 ++--- .../commandbased/command-scheduler.rst | 39 +++------ .../docs/software/commandbased/commands.rst | 60 +++++--------- .../commandbased/cpp-command-discussion.rst | 3 +- .../commandbased/pid-subsystems-commands.rst | 9 +-- .../profile-subsystems-commands.rst | 9 +-- .../profilepid-subsystems-commands.rst | 9 +-- .../structuring-command-based-project.rst | 45 ++++------- .../docs/software/commandbased/subsystems.rst | 39 +++------ .../dashboards/glass/field2d-widget.rst | 6 +- .../dashboards/glass/mech2d-widget.rst | 36 +++------ ...autonomous-program-from-smartdashboard.rst | 14 ++-- .../hardware-apis/misc/addressable-leds.rst | 20 ++--- .../hardware-apis/pneumatics/solenoids.rst | 18 ++--- .../creating-drive-subsystem.rst | 69 ++++++---------- .../creating-following-trajectory.rst | 36 +++------ .../entering-constants.rst | 24 ++---- .../telemetry/writing-sendable-classes.rst | 12 +-- .../using-the-cameraserver-on-the-roborio.rst | 6 +- .../creating-robot-program.rst | 6 +- .../robot-simulation/physics-sim.rst | 24 ++---- .../robot-simulation/unit-testing.rst | 3 +- source/docs/xrp-robot/programming-xrp.rst | 3 +- ...est-drivetrain-program-cpp-java-python.rst | 57 +++++-------- 35 files changed, 247 insertions(+), 491 deletions(-) diff --git a/source/docs/contributing/frc-docs/style-guide.rst b/source/docs/contributing/frc-docs/style-guide.rst index af3181f2cd..63217ab0b5 100644 --- a/source/docs/contributing/frc-docs/style-guide.rst +++ b/source/docs/contributing/frc-docs/style-guide.rst @@ -104,20 +104,17 @@ When possible, instead of using code blocks, an RLI should be used. This pulls .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gettingstarted/Robot.java :language: java :lines: 19-25 - :linenos: - :lineno-start: 19 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/GettingStarted/cpp/Robot.cpp :language: c++ :lines: 50-60 - :linenos: - :lineno-start: 50 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/c6d0540b01e138725fad7366ff4e317e9994b78b/GettingStarted/robot.py :language: python - :linenos: :lines: 12-29 - :lineno-start: 12 + :lineno-match: ``` Make sure to link to the raw version of the file on GitHub. There is a handy ``Raw`` button in the top right corner of the page. @@ -132,8 +129,7 @@ To create code tabs in an article, you can use the ``.. tab-set-code::`` directi .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gettingstarted/Robot.java :language: java :lines: 19-25 - :linenos: - :lineno-start: 19 + :lineno-match: ```c++ // Start the timer. diff --git a/source/docs/romi-robot/programming-romi.rst b/source/docs/romi-robot/programming-romi.rst index b75358ba0e..2bd3e92c25 100644 --- a/source/docs/romi-robot/programming-romi.rst +++ b/source/docs/romi-robot/programming-romi.rst @@ -37,8 +37,7 @@ To run a Romi program, first, ensure that your Romi is powered on. Next, connect .. rli:: https://raw.githubusercontent.com/wpilibsuite/vscode-wpilib/v2025.1.1-beta-1/vscode-wpilib/resources/gradle/javaromi/build.gradle :language: groovy :lines: 44-47 - :linenos: - :lineno-start: 44 + :lineno-match: :emphasize-lines: 2 Now to start your Romi robot code, open the WPILib Command Palette (type :kbd:`Ctrl+Shift+P`) and select "Simulate Robot Code", or press :kbd:`F5`. diff --git a/source/docs/software/advanced-controls/controllers/profiled-pidcontroller.rst b/source/docs/software/advanced-controls/controllers/profiled-pidcontroller.rst index 1b16b60780..05d4acadf8 100644 --- a/source/docs/software/advanced-controls/controllers/profiled-pidcontroller.rst +++ b/source/docs/software/advanced-controls/controllers/profiled-pidcontroller.rst @@ -146,17 +146,14 @@ A more complete example of ``ProfiledPIDController`` usage is provided in the El .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatorprofiledpid/Robot.java :language: java :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/ElevatorProfiledPID/cpp/Robot.cpp :language: c++ :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/d89b0587a1e1111239728140466c7dc4324d4005/ElevatorProfiledPID/robot.py :language: python :lines: 8- - :linenos: - :lineno-start: 8 + :lineno-match: diff --git a/source/docs/software/advanced-controls/controllers/trapezoidal-profiles.rst b/source/docs/software/advanced-controls/controllers/trapezoidal-profiles.rst index 119105381c..211c27e1b5 100644 --- a/source/docs/software/advanced-controls/controllers/trapezoidal-profiles.rst +++ b/source/docs/software/advanced-controls/controllers/trapezoidal-profiles.rst @@ -165,17 +165,14 @@ A more complete example of ``TrapezoidProfile`` usage is provided in the Elevato .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatortrapezoidprofile/Robot.java :language: java :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/ElevatorTrapezoidProfile/cpp/Robot.cpp :language: c++ :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/d89b0587a1e1111239728140466c7dc4324d4005/ElevatorTrapezoidProfile/robot.py :language: python :lines: 8- - :linenos: - :lineno-start: 8 + :lineno-match: diff --git a/source/docs/software/advanced-controls/state-space/state-space-flywheel-walkthrough.rst b/source/docs/software/advanced-controls/state-space/state-space-flywheel-walkthrough.rst index 3fb41d5a4e..3dc2b9d30b 100644 --- a/source/docs/software/advanced-controls/state-space/state-space-flywheel-walkthrough.rst +++ b/source/docs/software/advanced-controls/state-space/state-space-flywheel-walkthrough.rst @@ -68,8 +68,7 @@ The ``LinearSystem`` class contains methods for easily creating state-space syst .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespaceflywheelsysid/Robot.java :language: java :lines: 32-46 - :linenos: - :lineno-start: 33 + :lineno-match: .. tab-item:: C++ @@ -78,28 +77,24 @@ The ``LinearSystem`` class contains methods for easily creating state-space syst .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheelSysId/cpp/Robot.cpp :language: c++ :lines: 17 - :linenos: - :lineno-start: 17 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheelSysId/cpp/Robot.cpp :language: c++ :lines: 30-46 - :linenos: - :lineno-start: 30 + :lineno-match: .. tab-item:: Python .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/d89b0587a1e1111239728140466c7dc4324d4005/StateSpaceFlywheelSysId/robot.py :language: python :lines: 23-27 - :linenos: - :lineno-start: 23 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/d89b0587a1e1111239728140466c7dc4324d4005/StateSpaceFlywheelSysId/robot.py :language: python :lines: 37-48 - :linenos: - :lineno-start: 37 + :lineno-match: ### Modeling Using Flywheel Moment of Inertia and Gearing @@ -120,8 +115,7 @@ The ``LinearSystem`` class contains methods to easily create a model of a flywhe .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespaceflywheel/Robot.java :language: java :lines: 33-46 - :linenos: - :lineno-start: 33 + :lineno-match: .. tab-item:: C++ :sync: c++ @@ -129,14 +123,12 @@ The ``LinearSystem`` class contains methods to easily create a model of a flywhe .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheel/cpp/Robot.cpp :language: c++ :lines: 17-17 - :linenos: - :lineno-start: 17 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheel/cpp/Robot.cpp :language: c++ - :lines: 17,31-46 - :linenos: - :lineno-start: 31 + :lines: 31-46 + :lineno-match: .. tab-item:: Python :sync: python @@ -144,14 +136,12 @@ The ``LinearSystem`` class contains methods to easily create a model of a flywhe .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/d89b0587a1e1111239728140466c7dc4324d4005/StateSpaceFlywheel/robot.py :language: python :lines: 21-25 - :linenos: - :lineno-start: 21 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/d89b0587a1e1111239728140466c7dc4324d4005/StateSpaceFlywheel/robot.py :language: python :lines: 37-46 - :linenos: - :lineno-start: 37 + :lineno-match: ## Kalman Filters: Observing Flywheel State @@ -174,8 +164,7 @@ Because the feedback controller computes error using the :term:`x-hat` estimated .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespaceflywheel/Robot.java :language: java :lines: 48-58 - :linenos: - :lineno-start: 48 + :lineno-match: .. tab-item:: C++ :sync: c++ @@ -183,14 +172,12 @@ Because the feedback controller computes error using the :term:`x-hat` estimated .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheelSysId/cpp/Robot.cpp :language: c++ :lines: 13-13 - :linenos: - :lineno-start: 13 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheel/cpp/Robot.cpp :language: c++ :lines: 48-53 - :linenos: - :lineno-start: 48 + :lineno-match: .. tab-item:: Python :sync: python @@ -198,8 +185,7 @@ Because the feedback controller computes error using the :term:`x-hat` estimated .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/d89b0587a1e1111239728140466c7dc4324d4005/StateSpaceFlywheel/robot.py :language: python :lines: 48-54 - :linenos: - :lineno-start: 48 + :lineno-match: Because Kalman filters use our state-space model in the :ref:`docs/software/advanced-controls/state-space/state-space-observers:Predict step`, it is important that our model is as accurate as possible. One way to verify this is to record a flywheel's input voltage and velocity over time, and replay this data by calling only ``predict`` on the Kalman filter. Then, the kV and kA gains (or moment of inertia and other constants) can be adjusted until the model closely matches the recorded data. @@ -219,8 +205,7 @@ Much like ``SimpleMotorFeedforward`` can be used to generate feedforward voltage .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespaceflywheel/Robot.java :language: java :lines: 59-70 - :linenos: - :lineno-start: 59 + :lineno-match: .. tab-item:: C++ :sync: c++ @@ -228,14 +213,12 @@ Much like ``SimpleMotorFeedforward`` can be used to generate feedforward voltage .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheelSysId/cpp/Robot.cpp :language: c++ :lines: 11 - :linenos: - :lineno-start: 11 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheel/cpp/Robot.cpp :language: c++ :lines: 55-75 - :linenos: - :lineno-start: 54 + :lineno-match: .. tab-item:: Python :sync: python @@ -243,8 +226,7 @@ Much like ``SimpleMotorFeedforward`` can be used to generate feedforward voltage .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/d89b0587a1e1111239728140466c7dc4324d4005/StateSpaceFlywheel/robot.py :language: python :lines: 56-66 - :linenos: - :lineno-start: 56 + :lineno-match: ## Bringing it All Together: LinearSystemLoop @@ -258,8 +240,7 @@ LinearSystemLoop combines our system, controller, and observer that we created e .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespaceflywheel/Robot.java :language: java :lines: 72-74 - :linenos: - :lineno-start: 72 + :lineno-match: .. tab-item:: C++ :sync: c++ @@ -267,14 +248,12 @@ LinearSystemLoop combines our system, controller, and observer that we created e .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheelSysId/cpp/Robot.cpp :language: c++ :lines: 15-15 - :linenos: - :lineno-start: 15 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheel/cpp/Robot.cpp :language: c++ :lines: 71-74 - :linenos: - :lineno-start: 71 + :lineno-match: .. tab-item:: Python :sync: python @@ -282,8 +261,7 @@ LinearSystemLoop combines our system, controller, and observer that we created e .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/d89b0587a1e1111239728140466c7dc4324d4005/StateSpaceFlywheel/robot.py :language: python :lines: 68-71 - :linenos: - :lineno-start: 68 + :lineno-match: Once we have our ``LinearSystemLoop``, the only thing left to do is actually run it. To do that, we'll periodically update our Kalman filter with our new encoder velocity measurements and apply new voltage commands to it. To do that, we first set the :term:`reference`, then ``correct`` with the current flywheel speed, ``predict`` the Kalman filter into the next timestep, and apply the inputs generated using ``getU``. @@ -295,8 +273,7 @@ Once we have our ``LinearSystemLoop``, the only thing left to do is actually run .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespaceflywheel/Robot.java :language: java :lines: 94-119 - :linenos: - :lineno-start: 94 + :lineno-match: .. tab-item:: C++ :sync: c++ @@ -304,14 +281,12 @@ Once we have our ``LinearSystemLoop``, the only thing left to do is actually run .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheelSysId/cpp/Robot.cpp :language: c++ :lines: 5-17 - :linenos: - :lineno-start: 5 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheel/cpp/Robot.cpp :language: c++ :lines: 92-114 - :linenos: - :lineno-start: 92 + :lineno-match: .. tab-item:: Python :sync: python @@ -319,8 +294,7 @@ Once we have our ``LinearSystemLoop``, the only thing left to do is actually run .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/d89b0587a1e1111239728140466c7dc4324d4005/StateSpaceFlywheel/robot.py :language: python :lines: 87-109 - :linenos: - :lineno-start: 87 + :lineno-match: ## Angle Wrap with LQR diff --git a/source/docs/software/advanced-controls/state-space/state-space-observers.rst b/source/docs/software/advanced-controls/state-space/state-space-observers.rst index 64108c3632..2b5234abdb 100644 --- a/source/docs/software/advanced-controls/state-space/state-space-observers.rst +++ b/source/docs/software/advanced-controls/state-space/state-space-observers.rst @@ -94,30 +94,26 @@ WPILib's Kalman Filter classes' constructors take a linear system, a vector of p .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespaceflywheel/Robot.java :language: java :lines: 48-57 - :linenos: - :lineno-start: 48 + :lineno-match: .. tab-item:: C++ .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheel/cpp/Robot.cpp :language: c++ :lines: 5-18 - :linenos: - :lineno-start: 5 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheel/cpp/Robot.cpp :language: c++ :lines: 48-53 - :linenos: - :lineno-start: 48 + :lineno-match: .. tab-item:: Python .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/d89b0587a1e1111239728140466c7dc4324d4005/StateSpaceFlywheel/robot.py :language: python :lines: 48-54 - :linenos: - :lineno-start: 48 + :lineno-match: ## Footnotes diff --git a/source/docs/software/advanced-controls/state-space/state-space-pose-estimators.rst b/source/docs/software/advanced-controls/state-space/state-space-pose-estimators.rst index 4eb65cdd33..eaf6ebb792 100644 --- a/source/docs/software/advanced-controls/state-space/state-space-pose-estimators.rst +++ b/source/docs/software/advanced-controls/state-space/state-space-pose-estimators.rst @@ -12,14 +12,12 @@ Here's how to initialize a ``DifferentialDrivePoseEstimator``: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/differentialdriveposeestimator/Drivetrain.java :language: java :lines: 86-94 - :linenos: - :lineno-start: 86 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/DifferentialDrivePoseEstimator/include/Drivetrain.h :language: c++ :lines: 158-165 - :linenos: - :lineno-start: 158 + :lineno-match: Add odometry measurements every loop by calling ``Update()``. @@ -28,14 +26,12 @@ Add odometry measurements every loop by calling ``Update()``. .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/differentialdriveposeestimator/Drivetrain.java :language: java :lines: 227-228 - :linenos: - :lineno-start: 227 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/DifferentialDrivePoseEstimator/cpp/Drivetrain.cpp :language: c++ :lines: 84-86 - :linenos: - :lineno-start: 84 + :lineno-match: Add vision pose measurements occasionally by calling ``AddVisionMeasurement()``. @@ -44,14 +40,12 @@ Add vision pose measurements occasionally by calling ``AddVisionMeasurement()``. .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/differentialdriveposeestimator/Drivetrain.java :language: java :lines: 236-245 - :linenos: - :lineno-start: 236 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/DifferentialDrivePoseEstimator/cpp/Drivetrain.cpp :language: c++ :lines: 93-106 - :linenos: - :lineno-start: 93 + :lineno-match: ## Tuning Pose Estimators diff --git a/source/docs/software/advanced-controls/trajectories/troubleshooting.rst b/source/docs/software/advanced-controls/trajectories/troubleshooting.rst index fdd4ba3e30..9c698045b0 100644 --- a/source/docs/software/advanced-controls/trajectories/troubleshooting.rst +++ b/source/docs/software/advanced-controls/trajectories/troubleshooting.rst @@ -99,14 +99,12 @@ If your feedforwards are bad then the P controllers for each side of the robot w .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/ramsetecommand/RobotContainer.java :language: java :lines: 123-124 - :linenos: - :lineno-start: 123 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibcExamples/src/main/cpp/examples/RamseteCommand/cpp/RobotContainer.cpp :language: c++ :lines: 79-80 - :linenos: - :lineno-start: 81 + :lineno-match: 1. Next, we want to disable the Ramsete controller to make it easier to isolate our problematic behavior. To do so, simply call ``setEnabled(false)`` on the ``RamseteController`` passed into your ``RamseteCommand``: diff --git a/source/docs/software/advanced-gradlerio/profiling-with-visualvm.rst b/source/docs/software/advanced-gradlerio/profiling-with-visualvm.rst index bb76cb52c8..b14fa98f62 100644 --- a/source/docs/software/advanced-gradlerio/profiling-with-visualvm.rst +++ b/source/docs/software/advanced-gradlerio/profiling-with-visualvm.rst @@ -13,8 +13,7 @@ GradleRIO supports passing JVM launch arguments, and this is what is necessary t .. rli:: https://raw.githubusercontent.com/wpilibsuite/vscode-wpilib/v2025.1.1-beta-1/vscode-wpilib/resources/gradle/java/build.gradle :language: groovy :lines: 15-40 - :linenos: - :lineno-start: 15 + :lineno-match: :emphasize-lines: 15-16 diff --git a/source/docs/software/basic-programming/java-gc.rst b/source/docs/software/basic-programming/java-gc.rst index a90eb3b48c..1134ff07ed 100644 --- a/source/docs/software/basic-programming/java-gc.rst +++ b/source/docs/software/basic-programming/java-gc.rst @@ -36,8 +36,7 @@ Since ``OutOfMemoryError``\ s both crash the program and are a common reason to .. rli:: https://raw.githubusercontent.com/wpilibsuite/vscode-wpilib/v2025.1.1-beta-1/vscode-wpilib/resources/gradle/java/build.gradle :language: groovy :lines: 15-40 - :linenos: - :lineno-start: 15 + :lineno-match: :emphasize-lines: 15-16 Add to the code block so that it contains two ``jvmArgs`` commands, as shown below: diff --git a/source/docs/software/commandbased/binding-commands-to-triggers.rst b/source/docs/software/commandbased/binding-commands-to-triggers.rst index 8caeaf5ecd..b7809ab4fb 100644 --- a/source/docs/software/commandbased/binding-commands-to-triggers.rst +++ b/source/docs/software/commandbased/binding-commands-to-triggers.rst @@ -78,15 +78,13 @@ This binding schedules a command when a trigger changes from ``false`` to ``true .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/rapidreactcommandbot/RapidReactCommandBot.java :language: java :lines: 65-66 - :linenos: - :lineno-start: 66 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/RapidReactCommandBot.cpp :language: c++ :lines: 28-29 - :linenos: - :lineno-start: 28 + :lineno-match: The ``onFalse`` binding is identical, only that it schedules on ``false`` instead of on ``true``. @@ -99,14 +97,12 @@ This binding schedules a command when a trigger changes from ``false`` to ``true .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/commandbased/RobotContainer.java :language: java :lines: 49-51 - :linenos: - :lineno-start: 49 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/templates/commandbased/cpp/RobotContainer.cpp :language: c++ :lines: 27-29 - :linenos: - :lineno-start: 27 + :lineno-match: The ``whileFalse`` binding is identical, only that it schedules on ``false`` and cancels on ``true``. @@ -119,14 +115,12 @@ This binding toggles a command, scheduling it when a trigger changes from ``fals .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/rapidreactcommandbot/RapidReactCommandBot.java :language: java :lines: 78-79 - :linenos: - :lineno-start: 78 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/RapidReactCommandBot.cpp :language: c++ :lines: 41-43 - :linenos: - :lineno-start: 41 + :lineno-match: The ``toggleOnFalse`` binding is identical, only that it toggles on ``false`` instead of on ``true``. diff --git a/source/docs/software/commandbased/command-compositions.rst b/source/docs/software/commandbased/command-compositions.rst index 4b747c51c1..45b235a4bb 100644 --- a/source/docs/software/commandbased/command-compositions.rst +++ b/source/docs/software/commandbased/command-compositions.rst @@ -175,8 +175,7 @@ The ``Select`` factory ([Java](https://github.wpilib.org/allwpilib/docs/developm .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/selectcommand/RobotContainer.java :language: java :lines: 20-45 - :linenos: - :lineno-start: 20 + :lineno-match: .. tab-item:: C++ (Header) :sync: C++ (Header) @@ -184,8 +183,7 @@ The ``Select`` factory ([Java](https://github.wpilib.org/allwpilib/docs/developm .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/SelectCommand/include/RobotContainer.h :language: c++ :lines: 26-43 - :linenos: - :lineno-start: 26 + :lineno-match: The ``Either`` factory ([Java](https://github.wpilib.org/allwpilib/docs/development/java/edu/wpi/first/wpilibj2/command/Commands.html#either(edu.wpi.first.wpilibj2.command.Command,edu.wpi.first.wpilibj2.command.Command,java.util.function.BooleanSupplier)), [C++](https://github.wpilib.org/allwpilib/docs/development/cpp/namespacefrc2_1_1cmd.html#a389d1d0055c3be03a852bfc88aaa2ee5), :external:py:func:[Python](commands2.cmd.either>`), backed by the ``ConditionalCommand`` class ([Java](https://github.wpilib.org/allwpilib/docs/development/java/edu/wpi/first/wpilibj2/command/ConditionalCommand.html), [C++](https://github.wpilib.org/allwpilib/docs/development/cpp/classfrc2_1_1_conditional_command.html), :external:py:class:`Python `), is a specialization accepting two commands and a boolean selector function. @@ -303,8 +301,7 @@ Command compositions can also be written as a constructor-only subclass of the m .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/hatchbottraditional/commands/ComplexAuto.java :language: java :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: .. tab-item:: C++ (Header) :sync: C++ (Header) @@ -312,8 +309,7 @@ Command compositions can also be written as a constructor-only subclass of the m .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/commands/ComplexAuto.h :language: c++ :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: .. tab-item:: C++ (Source) :sync: C++ (Source) @@ -321,8 +317,7 @@ Command compositions can also be written as a constructor-only subclass of the m .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/ComplexAuto.cpp :language: c++ :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: .. tab-item:: Python :sync: Python @@ -330,7 +325,6 @@ Command compositions can also be written as a constructor-only subclass of the m .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/main/HatchbotTraditional/commands/complexauto.py :language: python :lines: 7- - :linenos: - :lineno-start: 5 + :lineno-match: The advantages and disadvantages of this subclassing approach in comparison to others are discussed in :ref:`docs/software/commandbased/organizing-command-based:Subclassing Command Groups`. diff --git a/source/docs/software/commandbased/command-scheduler.rst b/source/docs/software/commandbased/command-scheduler.rst index fadf53458d..03c641a523 100644 --- a/source/docs/software/commandbased/command-scheduler.rst +++ b/source/docs/software/commandbased/command-scheduler.rst @@ -34,14 +34,12 @@ This method walks through the following steps: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2023.4.3/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java :language: java :lines: 202-245 - :linenos: - :lineno-start: 202 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2023.4.3/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java :language: java :lines: 181-191 - :linenos: - :lineno-start: 181 + :lineno-match: .. tab-item:: C++ (Source) :sync: tabcode-c++ @@ -49,8 +47,7 @@ This method walks through the following steps: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2023.4.3/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandScheduler.cpp :language: c++ :lines: 114-159 - :linenos: - :lineno-start: 114 + :lineno-match: ## The Scheduler Run Sequence @@ -70,8 +67,7 @@ First, the scheduler runs the ``periodic()`` method of each registered ``Subsyst .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2023.4.3/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java :language: java :lines: 278-285 - :linenos: - :lineno-start: 278 + :lineno-match: .. tab-item:: C++ (Source) :sync: tabcode-c++ @@ -79,8 +75,7 @@ First, the scheduler runs the ``periodic()`` method of each registered ``Subsyst .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2023.4.3/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandScheduler.cpp :language: c++ :lines: 183-190 - :linenos: - :lineno-start: 183 + :lineno-match: ### Step 2: Poll Command Scheduling Triggers @@ -96,8 +91,7 @@ Secondly, the scheduler polls the state of all registered triggers to see if any .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2023.4.3/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java :language: java :lines: 290-292 - :linenos: - :lineno-start: 290 + :lineno-match: .. tab-item:: C++ (Source) :sync: tabcode-c++ @@ -105,8 +99,7 @@ Secondly, the scheduler polls the state of all registered triggers to see if any .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2023.4.3/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandScheduler.cpp :language: c++ :lines: 195-197 - :linenos: - :lineno-start: 195 + :lineno-match: ### Step 3: Run/Finish Scheduled Commands @@ -122,8 +115,7 @@ Note that this sequence of calls is done in order for each command - thus, one c .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2023.4.3/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java :language: java :lines: 295-325 - :linenos: - :lineno-start: 295 + :lineno-match: :emphasize-lines: 16,21-22 .. tab-item:: C++ (Source) @@ -132,8 +124,7 @@ Note that this sequence of calls is done in order for each command - thus, one c .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2023.4.3/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandScheduler.cpp :language: c++ :lines: 201-226 - :linenos: - :lineno-start: 201 + :lineno-match: :emphasize-lines: 7,13-14 ### Step 4: Schedule Default Commands @@ -148,8 +139,7 @@ Finally, any registered ``Subsystem`` has its default command scheduled (if it h .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2023.4.3/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java :language: java :lines: 340-346 - :linenos: - :lineno-start: 340 + :lineno-match: .. tab-item:: C++ (Source) :sync: tabcode-c++ @@ -157,8 +147,7 @@ Finally, any registered ``Subsystem`` has its default command scheduled (if it h .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2023.4.3/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandScheduler.cpp :language: c++ :lines: 240-246 - :linenos: - :lineno-start: 240 + :lineno-match: ## Disabling the Scheduler @@ -188,8 +177,7 @@ A typical use-case for these methods is adding markers in an event log whenever .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/hatchbotinlined/RobotContainer.java :language: java :lines: 73-88 - :linenos: - :lineno-start: 73 + :lineno-match: .. tab-item:: C++ (Source) :sync: tabcode-c++ @@ -197,5 +185,4 @@ A typical use-case for these methods is adding markers in an event log whenever .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/RobotContainer.cpp :language: c++ :lines: 23-47 - :linenos: - :lineno-start: 23 + :lineno-match: diff --git a/source/docs/software/commandbased/commands.rst b/source/docs/software/commandbased/commands.rst index c375fb1239..23af80fd84 100644 --- a/source/docs/software/commandbased/commands.rst +++ b/source/docs/software/commandbased/commands.rst @@ -114,8 +114,7 @@ The ``runOnce`` factory, backed by the ``InstantCommand`` ([Java](https://github .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/hatchbotinlined/subsystems/HatchSubsystem.java :language: java :lines: 25-35 - :linenos: - :lineno-start: 25 + :lineno-match: .. tab-item:: C++ (Header) :sync: tabcode-c++ @@ -123,8 +122,7 @@ The ``runOnce`` factory, backed by the ``InstantCommand`` ([Java](https://github .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/include/subsystems/HatchSubsystem.h :language: c++ :lines: 20-28 - :linenos: - :lineno-start: 20 + :lineno-match: .. tab-item:: C++ (Source) :sync: tabcode-c++-source @@ -132,8 +130,7 @@ The ``runOnce`` factory, backed by the ``InstantCommand`` ([Java](https://github .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/subsystems/HatchSubsystem.cpp :language: c++ :lines: 15-25 - :linenos: - :lineno-start: 15 + :lineno-match: .. tab-item:: Python :sync: tabcode-python @@ -141,8 +138,7 @@ The ``runOnce`` factory, backed by the ``InstantCommand`` ([Java](https://github .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/main/HatchbotInlined/subsystems/hatchsubsystem.py :language: python :lines: 24-34 - :linenos: - :lineno-start: 24 + :lineno-match: The ``run`` factory, backed by the ``RunCommand`` ([Java](https://github.wpilib.org/allwpilib/docs/development/java/edu/wpi/first/wpilibj2/command/RunCommand.html), [C++](https://github.wpilib.org/allwpilib/docs/development/cpp/classfrc2_1_1_run_command.html), :external:py:class:`Python `) class, creates a command that calls a lambda repeatedly, until interrupted. @@ -329,14 +325,12 @@ To write a custom command class, subclass the abstract ``Command`` class ([Java] .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/commandbased/commands/ExampleCommand.java :language: java :lines: 7-24 - :linenos: - :lineno-start: 7 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/templates/commandbased/include/commands/ExampleCommand.h :language: c++ :lines: 5-31 - :linenos: - :lineno-start: 5 + :lineno-match: ## Simple Command Example @@ -350,8 +344,7 @@ What might a functional command look like in practice? As before, below is a sim .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/hatchbottraditional/commands/GrabHatch.java :language: java :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: .. tab-item:: C++ (Header) :sync: tabcode-c++ @@ -359,8 +352,7 @@ What might a functional command look like in practice? As before, below is a sim .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/commands/GrabHatch.h :language: c++ :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: .. tab-item:: C++ (Source) :sync: tabcode-c++-source @@ -368,8 +360,7 @@ What might a functional command look like in practice? As before, below is a sim .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/GrabHatch.cpp :language: c++ :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: .. tab-item:: Python :sync: tabcode-python @@ -377,8 +368,7 @@ What might a functional command look like in practice? As before, below is a sim .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/main/HatchbotTraditional/commands/grabhatch.py :language: python :lines: 7- - :linenos: - :lineno-start: 7 + :lineno-match: Notice that the hatch subsystem used by the command is passed into the command through the command’s constructor. This is a pattern called :term:`dependency injection`, and allows users to avoid declaring their subsystems as global variables. This is widely accepted as a best-practice - the reasoning behind this is discussed in a :doc:`later section `. @@ -394,8 +384,7 @@ What about a more complicated case? Below is a drive command, from the same exam .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/hatchbottraditional/commands/DefaultDrive.java :language: java :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: .. tab-item:: C++ (Header) :sync: tabcode-c++ @@ -403,8 +392,7 @@ What about a more complicated case? Below is a drive command, from the same exam .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/commands/DefaultDrive.h :language: c++ :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: .. tab-item:: C++ (Source) :sync: tabcode-c++-source @@ -412,8 +400,7 @@ What about a more complicated case? Below is a drive command, from the same exam .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/DefaultDrive.cpp :language: c++ :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: .. tab-item:: Python :sync: tabcode-python @@ -421,8 +408,7 @@ What about a more complicated case? Below is a drive command, from the same exam .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/main/HatchbotTraditional/commands/defaultdrive.py :language: python :lines: 7- - :linenos: - :lineno-start: 7 + :lineno-match: And then usage: @@ -431,20 +417,17 @@ And then usage: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/hatchbottraditional/RobotContainer.java :language: java :lines: 59-67 - :linenos: - :lineno-start: 59 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/RobotContainer.cpp :language: c++ :lines: 57-60 - :linenos: - :lineno-start: 57 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/main/HatchbotTraditional/robotcontainer.py :language: python :lines: 65-72 - :linenos: - :lineno-start: 65 + :lineno-match: Notice that this command does not override ``isFinished()``, and thus will never end; this is the norm for commands that are intended to be used as default commands. Once more, this command is rather simple and calls the subsystem method only from one place, and as such, could be more concisely written using factories: @@ -453,17 +436,14 @@ Notice that this command does not override ``isFinished()``, and thus will never .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/hatchbotinlined/RobotContainer.java :language: java :lines: 51-60 - :linenos: - :lineno-start: 51 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/RobotContainer.cpp :language: c++ :lines: 52-58 - :linenos: - :lineno-start: 52 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/main/HatchbotInlined/robotcontainer.py :language: python :lines: 53-65 - :linenos: - :lineno-start: 53 + :lineno-match: diff --git a/source/docs/software/commandbased/cpp-command-discussion.rst b/source/docs/software/commandbased/cpp-command-discussion.rst index f5d4c7df7c..43bb5103f4 100644 --- a/source/docs/software/commandbased/cpp-command-discussion.rst +++ b/source/docs/software/commandbased/cpp-command-discussion.rst @@ -194,7 +194,6 @@ For instance, consider the following from the [HatchbotInlined example project]( .. rli:: https://github.com/wpilibsuite/allwpilib/raw/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/commands/Autos.cpp :language: c++ :lines: 33-73 - :linenos: - :lineno-start: 33 + :lineno-match: To avoid breakage, command compositions still use ``unique_ptr``, so ``CommandPtr`` instances can be destructured into a ``unique_ptr`` using the ``Unwrap()`` rvalue-this method. For vectors, the static ``CommandPtr::UnwrapVector(vector)`` function exists. diff --git a/source/docs/software/commandbased/pid-subsystems-commands.rst b/source/docs/software/commandbased/pid-subsystems-commands.rst index 12122d3a73..3fd41db87e 100644 --- a/source/docs/software/commandbased/pid-subsystems-commands.rst +++ b/source/docs/software/commandbased/pid-subsystems-commands.rst @@ -15,8 +15,7 @@ One of the most common control algorithms used in FRC\ |reg| is the :term:`PID` .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/rapidreactcommandbot/subsystems/Shooter.java :language: java :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: .. tab-item:: C++ :sync: C++ (Header) @@ -24,8 +23,7 @@ One of the most common control algorithms used in FRC\ |reg| is the :term:`PID` .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/subsystems/Shooter.h :language: c++ :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: .. tab-item:: C++ (Source) :sync: C++ (Source) @@ -33,7 +31,6 @@ One of the most common control algorithms used in FRC\ |reg| is the :term:`PID` .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/subsystems/Shooter.cpp :language: c++ :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: A ``PIDController`` is declared inside the ``Shooter`` subsystem. It is used by ``ShootCommand`` alongside a feedforward to spin the shooter flywheel to the specified velocity. Once the ``PIDController`` reaches the specified velocity, the ``ShootCommand`` runs the feeder. diff --git a/source/docs/software/commandbased/profile-subsystems-commands.rst b/source/docs/software/commandbased/profile-subsystems-commands.rst index 3c6fcbfc27..9dedf034d8 100644 --- a/source/docs/software/commandbased/profile-subsystems-commands.rst +++ b/source/docs/software/commandbased/profile-subsystems-commands.rst @@ -19,8 +19,7 @@ The following examples are taken from the DriveDistanceOffboard example project .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/drivedistanceoffboard/subsystems/DriveSubsystem.java :language: java :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: .. tab-item:: C++ (Header) :sync: C++ (Header) @@ -28,8 +27,7 @@ The following examples are taken from the DriveDistanceOffboard example project .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/subsystems/DriveSubsystem.h :language: c++ :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: .. tab-item:: C++ (Source) :sync: C++ (Source) @@ -37,8 +35,7 @@ The following examples are taken from the DriveDistanceOffboard example project .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/cpp/subsystems/DriveSubsystem.cpp :language: c++ :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: There are two commands in this example. They function very similarly, with the main difference being that one resets encoders, and the other doesn't, which allows encoder data to be preserved. diff --git a/source/docs/software/commandbased/profilepid-subsystems-commands.rst b/source/docs/software/commandbased/profilepid-subsystems-commands.rst index aa20b4a3d4..99a03b7add 100644 --- a/source/docs/software/commandbased/profilepid-subsystems-commands.rst +++ b/source/docs/software/commandbased/profilepid-subsystems-commands.rst @@ -14,8 +14,7 @@ A common FRC\ |reg| controls solution is to pair a trapezoidal motion profile fo .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/rapidreactcommandbot/subsystems/Drive.java :language: java :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: .. tab-item:: C++ (Header) :sync: C++ (Header) @@ -23,8 +22,7 @@ A common FRC\ |reg| controls solution is to pair a trapezoidal motion profile fo .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/subsystems/Drive.h :language: c++ :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: .. tab-item:: C++ (Source) :sync: C++ (Source) @@ -32,7 +30,6 @@ A common FRC\ |reg| controls solution is to pair a trapezoidal motion profile fo .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/subsystems/Drive.cpp :language: c++ :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: ``turnToAngleCommand`` uses a ProfiledPIDController to smoothly turn the drivetrain. The ``startRun`` command factory is used to reset the ``ProfiledPIDController`` when the command is scheduled to avoid unwanted behavior, and to calculate PID and feedforward outputs to pass into the ``arcadeDrive`` method in order to drive the robot. The command is decorated using the ``until`` decorator to end the command when the ProfiledPIDController is finished with the profile. To ensure the drivetrain stops when the command ends, the ``finallyDo`` decorator is used to stop the drivetrain by setting the speed to zero. diff --git a/source/docs/software/commandbased/structuring-command-based-project.rst b/source/docs/software/commandbased/structuring-command-based-project.rst index 85af456363..11df7d9eb6 100644 --- a/source/docs/software/commandbased/structuring-command-based-project.rst +++ b/source/docs/software/commandbased/structuring-command-based-project.rst @@ -22,8 +22,7 @@ As ``Robot`` ([Java](https://github.com/wpilibsuite/allwpilib/blob/main/wpilibjE .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/commandbased/Robot.java :language: java :lines: 21-29 - :linenos: - :lineno-start: 21 + :lineno-match: In Java, an instance of ``RobotContainer`` should be constructed during the ``Robot`` constructor - this is important, as most of the declarative robot setup will be called from the ``RobotContainer`` constructor. @@ -37,8 +36,7 @@ In C++, this is not needed as RobotContainer is a value member and will be const .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/commandbased/Robot.java :language: java :lines: 31-45 - :linenos: - :lineno-start: 31 + :lineno-match: .. tab-item:: C++ (Source) :sync: C++ (Source) @@ -46,8 +44,7 @@ In C++, this is not needed as RobotContainer is a value member and will be const .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/templates/commandbased/cpp/Robot.cpp :language: c++ :lines: 11-22 - :linenos: - :lineno-start: 11 + :lineno-match: The inclusion of the ``CommandScheduler.getInstance().run()`` call in the ``robotPeriodic()`` method is essential; without this call, the scheduler will not execute any scheduled commands. Since ``TimedRobot`` runs with a default main loop frequency of 50Hz, this is the frequency with which periodic command and subsystem methods will be called. It is not recommended for new users to call this method from anywhere else in their code. @@ -59,8 +56,7 @@ The inclusion of the ``CommandScheduler.getInstance().run()`` call in the ``robo .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/commandbased/Robot.java :language: java :lines: 54-63 - :linenos: - :lineno-start: 54 + :lineno-match: .. tab-item:: C++ (Source) :sync: C++ (Source) @@ -68,8 +64,7 @@ The inclusion of the ``CommandScheduler.getInstance().run()`` call in the ``robo .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/templates/commandbased/cpp/Robot.cpp :language: c++ :lines: 32-42 - :linenos: - :lineno-start: 33 + :lineno-match: The ``autonomousInit()`` method schedules an autonomous command returned by the ``RobotContainer`` instance. The logic for selecting which autonomous command to run can be handled inside of ``RobotContainer``. @@ -81,8 +76,7 @@ The ``autonomousInit()`` method schedules an autonomous command returned by the .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/commandbased/Robot.java :language: java :lines: 69-78 - :linenos: - :lineno-start: 69 + :lineno-match: .. tab-item:: C++ (Source) :sync: C++ (Source) @@ -90,8 +84,7 @@ The ``autonomousInit()`` method schedules an autonomous command returned by the .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/templates/commandbased/cpp/Robot.cpp :language: c++ :lines: 46-55 - :linenos: - :lineno-start: 46 + :lineno-match: The ``teleopInit()`` method cancels any still-running autonomous commands. This is generally good practice. @@ -109,8 +102,7 @@ This class ([Java](https://github.com/wpilibsuite/allwpilib/blob/main/wpilibjExa .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/commandbased/RobotContainer.java :language: java :lines: 23 - :linenos: - :lineno-start: 23 + :lineno-match: .. tab-item:: C++ (Header) :sync: C++ (Header) @@ -118,8 +110,7 @@ This class ([Java](https://github.com/wpilibsuite/allwpilib/blob/main/wpilibjExa .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/templates/commandbased/include/RobotContainer.h :language: c++ :lines: 32 - :linenos: - :lineno-start: 32 + :lineno-match: Notice that subsystems are declared as private fields in ``RobotContainer``. This is in stark contrast to the previous incarnation of the command-based framework, but is much more-aligned with agreed-upon object-oriented best-practices. If subsystems are declared as global variables, it allows the user to access them from anywhere in the code. While this can make certain things easier (for example, there would be no need to pass subsystems to commands in order for those commands to access them), it makes the control flow of the program much harder to keep track of as it is not immediately obvious which parts of the code can change or be changed by which other parts of the code. This also circumvents the ability of the resource-management system to do its job, as ease-of-access makes it easy for users to accidentally make conflicting calls to subsystem methods outside of the resource-managed commands. @@ -131,8 +122,7 @@ Notice that subsystems are declared as private fields in ``RobotContainer``. Thi .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/commandbased/RobotContainer.java :language: java :lines: 61 - :linenos: - :lineno-start: 61 + :lineno-match: .. tab-item:: C++ (Source) :sync: C++ (Source) @@ -140,8 +130,7 @@ Notice that subsystems are declared as private fields in ``RobotContainer``. Thi .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/templates/commandbased/cpp/RobotContainer.cpp :language: c++ :lines: 34 - :linenos: - :lineno-start: 34 + :lineno-match: Since subsystems are declared as private members, they must be explicitly passed to commands (a pattern called "dependency injection") in order for those commands to call methods on them. This is done here with ``ExampleCommand``, which is passed a pointer to an ``ExampleSubsystem``. @@ -153,8 +142,7 @@ Since subsystems are declared as private members, they must be explicitly passed .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/commandbased/RobotContainer.java :language: java :lines: 35-52 - :linenos: - :lineno-start: 35 + :lineno-match: .. tab-item:: C++ (Source) :sync: C++ (Source) @@ -162,8 +150,7 @@ Since subsystems are declared as private members, they must be explicitly passed .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/templates/commandbased/cpp/RobotContainer.cpp :language: c++ :lines: 19-30 - :linenos: - :lineno-start: 19 + :lineno-match: As mentioned before, the ``RobotContainer()`` constructor is where most of the declarative setup for the robot should take place, including button bindings, configuring autonomous selectors, etc. If the constructor gets too "busy," users are encouraged to migrate code into separate subroutines (such as the ``configureBindings()`` method included by default) which are called from the constructor. @@ -175,8 +162,7 @@ As mentioned before, the ``RobotContainer()`` constructor is where most of the d .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/commandbased/RobotContainer.java :language: java :lines: 54-63 - :linenos: - :lineno-start: 54 + :lineno-match: .. tab-item:: C++ (Source) :sync: C++ (Source) @@ -184,8 +170,7 @@ As mentioned before, the ``RobotContainer()`` constructor is where most of the d .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/templates/commandbased/cpp/RobotContainer.cpp :language: c++ :lines: 32-35 - :linenos: - :lineno-start: 32 + :lineno-match: Finally, the ``getAutonomousCommand()`` method provides a convenient way for users to send their selected autonomous command to the main ``Robot`` class (which needs access to it to schedule it when autonomous starts). diff --git a/source/docs/software/commandbased/subsystems.rst b/source/docs/software/commandbased/subsystems.rst index 2e602e7bee..4b1f5dd86f 100644 --- a/source/docs/software/commandbased/subsystems.rst +++ b/source/docs/software/commandbased/subsystems.rst @@ -18,8 +18,7 @@ The recommended method to create a subsystem for most users is to subclass the a .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/commandbased/subsystems/ExampleSubsystem.java :language: java :lines: 7- - :linenos: - :lineno-start: 7 + :lineno-match: .. tab-item:: C++ :sync: C++ @@ -27,8 +26,7 @@ The recommended method to create a subsystem for most users is to subclass the a .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1/wpilibcExamples/src/main/cpp/templates/commandbased/include/subsystems/ExampleSubsystem.h :language: c++ :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: .. tab-item:: Python :sync: Python @@ -79,8 +77,7 @@ What might a functional subsystem look like in practice? Below is a simple pneum .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/hatchbottraditional/subsystems/HatchSubsystem.java :language: java :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: .. tab-item:: C++ (Header) :sync: C++ (Header) @@ -88,8 +85,7 @@ What might a functional subsystem look like in practice? Below is a simple pneum .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/subsystems/HatchSubsystem.h :language: c++ :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: .. tab-item:: C++ (Source) :sync: C++ (Source) @@ -97,8 +93,7 @@ What might a functional subsystem look like in practice? Below is a simple pneum .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/subsystems/HatchSubsystem.cpp :language: c++ :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: .. tab-item:: Python :sync: Python @@ -106,8 +101,7 @@ What might a functional subsystem look like in practice? Below is a simple pneum .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/main/HatchbotTraditional/subsystems/hatchsubsystem.py :language: python :lines: 7- - :linenos: - :lineno-start: 7 + :lineno-match: Notice that the subsystem hides the presence of the DoubleSolenoid from outside code (it is declared ``private``), and instead publicly exposes two higher-level, descriptive robot actions: ``grabHatch()`` and ``releaseHatch()``. It is extremely important that "implementation details" such as the double solenoid be "hidden" in this manner; this ensures that code outside the subsystem will never cause the solenoid to be in an unexpected state. It also allows the user to change the implementation (for instance, a motor could be used instead of a pneumatic) without any of the code outside of the subsystem having to change with it. @@ -121,8 +115,7 @@ Alternatively, instead of writing ``void`` public methods that are called from c .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/hatchbotinlined/subsystems/HatchSubsystem.java :language: java :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: .. tab-item:: C++ (Header) :sync: C++ (Header) @@ -130,8 +123,7 @@ Alternatively, instead of writing ``void`` public methods that are called from c .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/include/subsystems/HatchSubsystem.h :language: c++ :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: .. tab-item:: C++ (Source) :sync: C++ (Source) @@ -139,8 +131,7 @@ Alternatively, instead of writing ``void`` public methods that are called from c .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/subsystems/HatchSubsystem.cpp :language: c++ :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: .. tab-item:: Python :sync: Python @@ -148,8 +139,7 @@ Alternatively, instead of writing ``void`` public methods that are called from c .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/main/HatchbotInlined/subsystems/hatchsubsystem.py :language: python :lines: 7- - :linenos: - :lineno-start: 7 + :lineno-match: Note the qualification of the ``RunOnce`` factory used here: this isn't the static factory in ``Commands``! Subsystems have similar instance factories that return commands requiring ``this`` (Java/C++) or ``self`` (Python) subsystem. Here, the ``Subsystem.runOnce(Runnable)`` factory ([Java](https://github.wpilib.org/allwpilib/docs/development/java/edu/wpi/first/wpilibj2/command/Subsystem.html#runOnce(java.lang.Runnable)), [C++](https://github.wpilib.org/allwpilib/docs/development/cpp/classfrc2_1_1_subsystem.html#a6b8b3b7dab6f54fb8635e335dad448fe), :external:py:meth:`Python `) is used. @@ -168,8 +158,7 @@ Subsystems have a ``periodic`` method that is called once every scheduler iterat .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespacedifferentialdrivesimulation/subsystems/DriveSubsystem.java :language: java :lines: 117-125 - :linenos: - :lineno-start: 117 + :lineno-match: .. tab-item:: C++ (Header) :sync: C++ (Header) @@ -177,8 +166,7 @@ Subsystems have a ``periodic`` method that is called once every scheduler iterat .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/StateSpaceDifferentialDriveSimulation/include/subsystems/DriveSubsystem.h :language: c++ :lines: 30-30 - :linenos: - :lineno-start: 30 + :lineno-match: .. tab-item:: C++ (Source) :sync: C++ (Source) @@ -186,8 +174,7 @@ Subsystems have a ``periodic`` method that is called once every scheduler iterat .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/StateSpaceDifferentialDriveSimulation/cpp/subsystems/DriveSubsystem.cpp :language: c++ :lines: 30-36 - :linenos: - :lineno-start: 30 + :lineno-match: .. tab-item:: Python :sync: Python diff --git a/source/docs/software/dashboards/glass/field2d-widget.rst b/source/docs/software/dashboards/glass/field2d-widget.rst index de60c1e074..0c5689aff2 100644 --- a/source/docs/software/dashboards/glass/field2d-widget.rst +++ b/source/docs/software/dashboards/glass/field2d-widget.rst @@ -45,14 +45,12 @@ Visualizing your trajectory is a great debugging step for verifying that your tr .. rli:: https://github.com/wpilibsuite/allwpilib/raw/v2024.3.2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/ramsetecontroller/Robot.java :language: java :lines: 44-61 - :linenos: - :lineno-start: 44 + :lineno-match: .. rli:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibcExamples/src/main/cpp/examples/RamseteController/cpp/Robot.cpp :language: c++ :lines: 18-30 - :linenos: - :lineno-start: 18 + :lineno-match: .. rli:: https://raw.githubusercontent.com/robotpy/examples/2024.0.0b4/RamseteController/robot.py :language: python diff --git a/source/docs/software/dashboards/glass/mech2d-widget.rst b/source/docs/software/dashboards/glass/mech2d-widget.rst index c51ae8c288..7b4f0a578a 100644 --- a/source/docs/software/dashboards/glass/mech2d-widget.rst +++ b/source/docs/software/dashboards/glass/mech2d-widget.rst @@ -13,20 +13,17 @@ In the examples below, an elevator is drawn, with a rotational wrist on top of t .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/mechanism2d/Robot.java :language: java :lines: 43-46 - :linenos: - :lineno-start: 43 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/Mechanism2d/cpp/Robot.cpp :language: c++ :lines: 59-62 - :linenos: - :lineno-start: 59 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/2024.0.0b4/Mechanism2d/robot.py :language: python :lines: 32-35 - :linenos: - :lineno-start: 32 + :lineno-match: Each ``MechanismLigament2d`` object represents a stage of the mechanism. It has a three required parameters, a name, an initial length to draw (relative to the size of the ``Mechanism2d`` object), and an initial angle to draw the ligament in degrees. Ligament angles are relative to the parent ligament, and follow math notation - the same as :ref:`Rotation2d ` (counterclockwise-positive). A ligament based on the root with an angle of zero will point right. Two optional parameters let you change the width (also relative to the size of the Mechanism2d object) and the color. Call ``append()``/``Append()`` on a root node or ligament node to add another node to the figure. In Java, pass a constructed ``MechanismLigament2d`` object to add it. In C++, pass the construction parameters in order to construct and add a ligament. @@ -37,20 +34,17 @@ Each ``MechanismLigament2d`` object represents a stage of the mechanism. It has .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/mechanism2d/Robot.java :language: java :lines: 48-53 - :linenos: - :lineno-start: 48 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/Mechanism2d/cpp/Robot.cpp :language: c++ :lines: 63-69 - :linenos: - :lineno-start: 63 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/2024.0.0b4/Mechanism2d/robot.py :language: python :lines: 37-44 - :linenos: - :lineno-start: 37 + :lineno-match: Then, publish the ``Mechanism2d`` object to NetworkTables: @@ -59,20 +53,17 @@ Then, publish the ``Mechanism2d`` object to NetworkTables: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/mechanism2d/Robot.java :language: java :lines: 55-56 - :linenos: - :lineno-start: 55 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/Mechanism2d/cpp/Robot.cpp :language: c++ :lines: 36-37 - :linenos: - :lineno-start: 36 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/2024.0.0b4/Mechanism2d/robot.py :language: python :lines: 46-47 - :linenos: - :lineno-start: 46 + :lineno-match: .. note:: The ``Mechanism2d`` instance can also be sent using a lower-level NetworkTables API or using the :ref:`Shuffleboard API `. In this case, the ``SmartDashboard`` API was used, meaning that the :guilabel:`Mechanism2d` widget will appear under the ``SmartDashboard`` table name. @@ -83,20 +74,17 @@ To manipulate a ligament angle or length, call ``setLength()`` or ``setAngle()`` .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/mechanism2d/Robot.java :language: java :lines: 59-64 - :linenos: - :lineno-start: 59 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/Mechanism2d/cpp/Robot.cpp :language: c++ :lines: 40-45 - :linenos: - :lineno-start: 40 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/2024.0.0b4/Mechanism2d/robot.py :language: python :lines: 49-54 - :linenos: - :lineno-start: 49 + :lineno-match: ## Viewing the Mechanism2d in Glass diff --git a/source/docs/software/dashboards/smartdashboard/choosing-an-autonomous-program-from-smartdashboard.rst b/source/docs/software/dashboards/smartdashboard/choosing-an-autonomous-program-from-smartdashboard.rst index e2781d1acc..21fd4f5f2b 100644 --- a/source/docs/software/dashboards/smartdashboard/choosing-an-autonomous-program-from-smartdashboard.rst +++ b/source/docs/software/dashboards/smartdashboard/choosing-an-autonomous-program-from-smartdashboard.rst @@ -260,7 +260,7 @@ In ``Robot.java``, this will run the scheduler every driver station update perio :language: java :lines: 49-50,55-56 :linenos: - :lineno-start: 40 + :lineno-start: 49 .. tab-item:: C++ (Source) :sync: C++ (Source) @@ -268,8 +268,7 @@ In ``Robot.java``, this will run the scheduler every driver station update perio .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.0.0-alpha-2/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/Robot.cpp :language: c++ :lines: 29-31 - :linenos: - :lineno-start: 29 + :lineno-match: ### Canceling the Autonomous Command @@ -283,8 +282,7 @@ In ``Robot.java``, when the teleop period begins, the autonomous command will be .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/hatchbottraditional/Robot.java :language: java :lines: 87-96 - :linenos: - :lineno-start: 78 + :lineno-match: .. tab-item:: C++ (Source) :sync: C++ (Source) @@ -292,8 +290,7 @@ In ``Robot.java``, when the teleop period begins, the autonomous command will be .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.0.0-alpha-2/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/Robot.cpp :language: c++ :lines: 56-65 - :linenos: - :lineno-start: 56 + :lineno-match: .. tab-item:: Python :sync: Python @@ -301,8 +298,7 @@ In ``Robot.java``, when the teleop period begins, the autonomous command will be .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/2024.0.0b4/HatchbotTraditional/robot.py :language: Python :lines: 51-57 - :linenos: - :lineno-start: 51 + :lineno-match: ### SmartDashboard Display diff --git a/source/docs/software/hardware-apis/misc/addressable-leds.rst b/source/docs/software/hardware-apis/misc/addressable-leds.rst index d6a5686f36..45994b9853 100644 --- a/source/docs/software/hardware-apis/misc/addressable-leds.rst +++ b/source/docs/software/hardware-apis/misc/addressable-leds.rst @@ -22,8 +22,7 @@ After the length of the strip has been set, you'll have to create an ``Addressab .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/addressableled/Robot.java :language: java :lines: 17-32 - :linenos: - :lineno-start: 17 + :lineno-match: .. tab-item:: C++ :sync: C++ @@ -32,13 +31,12 @@ After the length of the strip has been set, you'll have to create an ``Addressab :language: c++ :lines: 12-12, 18-27 :linenos: - :lineno-start: 11 + :lineno-start: 12 .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibcExamples/src/main/cpp/examples/AddressableLED/cpp/Robot.cpp :language: c++ :lines: 7-13 - :linenos: - :lineno-start: 7 + :lineno-match: .. note:: The roboRIO only supports only 1 ``AddressableLED`` object. As WS2812B LEDs are connected in series, you can drive several strips connected in series from from ``AddressableLED`` object. @@ -121,8 +119,7 @@ Moving outside of the for loop, the ``m_rainbowFirstPixelHue`` then iterates the .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/addressableled/Robot.java :language: java :lines: 42-55 - :linenos: - :lineno-start: 42 + :lineno-match: .. tab-item:: C++ :sync: C++ @@ -130,8 +127,7 @@ Moving outside of the for loop, the ``m_rainbowFirstPixelHue`` then iterates the .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibcExamples/src/main/cpp/examples/AddressableLED/cpp/Robot.cpp :language: c++ :lines: 22-35 - :linenos: - :lineno-start: 22 + :lineno-match: Now that we have our ``rainbow`` method created, we have to actually call the method and set the data of the LED. @@ -143,8 +139,7 @@ Now that we have our ``rainbow`` method created, we have to actually call the me .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/addressableled/Robot.java :language: java :lines: 34-40 - :linenos: - :lineno-start: 34 + :lineno-match: .. tab-item:: C++ :sync: C++ @@ -152,5 +147,4 @@ Now that we have our ``rainbow`` method created, we have to actually call the me .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibcExamples/src/main/cpp/examples/AddressableLED/cpp/Robot.cpp :language: c++ :lines: 15-20 - :linenos: - :lineno-start: 15 + :lineno-match: diff --git a/source/docs/software/hardware-apis/pneumatics/solenoids.rst b/source/docs/software/hardware-apis/pneumatics/solenoids.rst index 1efca2b8d6..5f0dd31e29 100644 --- a/source/docs/software/hardware-apis/pneumatics/solenoids.rst +++ b/source/docs/software/hardware-apis/pneumatics/solenoids.rst @@ -18,13 +18,11 @@ Single solenoids in WPILib are controlled using the ``Solenoid`` class ([Java](h .. rli:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/solenoid/Robot.java :language: java :lines: 30-32 - :linenos: - :lineno-start: 30 + :lineno-match: .. rli:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-3/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/solenoid/Robot.java :language: java :lines: 88-93 - :linenos: - :lineno-start: 88 + :lineno-match: .. tab-item:: C++ (Header) :sync: C++ (Header) @@ -32,8 +30,7 @@ Single solenoids in WPILib are controlled using the ``Solenoid`` class ([Java](h .. rli:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/Solenoid/include/Robot.h :language: c++ :lines: 44-47 - :linenos: - :lineno-start: 44 + :lineno-match: .. tab-item:: C++ (Source) :sync: C++ (Source) @@ -41,8 +38,7 @@ Single solenoids in WPILib are controlled using the ``Solenoid`` class ([Java](h .. rli:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/Solenoid/cpp/Robot.cpp :language: c++ :lines: 42-47 - :linenos: - :lineno-start: 42 + :lineno-match: ## Double Solenoids in WPILib @@ -57,8 +53,7 @@ Double solenoids are controlled by the ``DoubleSolenoid`` class in WPILib ([Java .. rli:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/solenoid/Robot.java :language: java :lines: 34-37 - :linenos: - :lineno-start: 37 + :lineno-match: .. rli:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-3/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/solenoid/Robot.java :language: java :lines: 100, 102 @@ -71,8 +66,7 @@ Double solenoids are controlled by the ``DoubleSolenoid`` class in WPILib ([Java .. rli:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibcExamples/src/main/cpp/examples/Solenoid/include/Robot.h :language: c++ :lines: 49-52 - :linenos: - :lineno-start: 49 + :lineno-match: .. tab-item:: C++ (Source) :sync: C++ (Source) diff --git a/source/docs/software/pathplanning/trajectory-tutorial/creating-drive-subsystem.rst b/source/docs/software/pathplanning/trajectory-tutorial/creating-drive-subsystem.rst index 6392fee93c..92429c48dd 100644 --- a/source/docs/software/pathplanning/trajectory-tutorial/creating-drive-subsystem.rst +++ b/source/docs/software/pathplanning/trajectory-tutorial/creating-drive-subsystem.rst @@ -12,8 +12,7 @@ The full drive class from the RamseteCommand Example Project ([Java](https://git .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/ramsetecommand/subsystems/DriveSubsystem.java :language: java :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: .. tab-item:: C++ (Header) :sync: C++ (Header) @@ -21,8 +20,7 @@ The full drive class from the RamseteCommand Example Project ([Java](https://git .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibcExamples/src/main/cpp/examples/RamseteCommand/include/subsystems/DriveSubsystem.h :language: c++ :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: .. tab-item:: C++ (Source) :sync: C++ (Source) @@ -30,8 +28,7 @@ The full drive class from the RamseteCommand Example Project ([Java](https://git .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibcExamples/src/main/cpp/examples/RamseteCommand/cpp/subsystems/DriveSubsystem.cpp :language: c++ :lines: 5- - :linenos: - :lineno-start: 5 + :lineno-match: ## Configuring the Drive Encoders @@ -49,8 +46,7 @@ The encoder ports are specified in the encoder's constructor, like so: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/ramsetecommand/subsystems/DriveSubsystem.java :language: java :lines: 31-43 - :linenos: - :lineno-start: 31 + :lineno-match: .. tab-item:: C++ (Source) :sync: C++ (Source) @@ -58,8 +54,7 @@ The encoder ports are specified in the encoder's constructor, like so: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibcExamples/src/main/cpp/examples/RamseteCommand/cpp/subsystems/DriveSubsystem.cpp :language: c++ :lines: 17-18 - :linenos: - :lineno-start: 17 + :lineno-match: ### Encoder Distance per Pulse @@ -73,8 +68,7 @@ The distance per pulse is specified by calling the encoder's ``setDistancePerPul .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/ramsetecommand/subsystems/DriveSubsystem.java :language: java :lines: 65-66 - :linenos: - :lineno-start: 65 + :lineno-match: .. tab-item:: C++ (Source) :sync: C++ (Source) @@ -82,8 +76,7 @@ The distance per pulse is specified by calling the encoder's ``setDistancePerPul .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibcExamples/src/main/cpp/examples/RamseteCommand/cpp/subsystems/DriveSubsystem.cpp :language: c++ :lines: 32-33 - :linenos: - :lineno-start: 32 + :lineno-match: ### Encoder Accessor Method @@ -99,8 +92,7 @@ To access the values measured by the encoders, we include the following method: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/ramsetecommand/subsystems/DriveSubsystem.java :language: java :lines: 90-97 - :linenos: - :lineno-start: 90 + :lineno-match: .. tab-item:: C++ (Source) :sync: C++ (Source) @@ -108,8 +100,7 @@ To access the values measured by the encoders, we include the following method: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibcExamples/src/main/cpp/examples/RamseteCommand/cpp/subsystems/DriveSubsystem.cpp :language: c++ :lines: 88-91 - :linenos: - :lineno-start: 88 + :lineno-match: We wrap the measured encoder values in a ``DifferentialDriveWheelSpeeds`` object for easier integration with the ``RamseteCommand`` class later on. @@ -125,8 +116,7 @@ The gyroscope measures the rate of change of the robot's heading (which can then .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/ramsetecommand/subsystems/DriveSubsystem.java :language: java :lines: 45-46 - :linenos: - :lineno-start: 45 + :lineno-match: .. tab-item:: C++ (Header) :sync: C++ (Header) @@ -134,8 +124,7 @@ The gyroscope measures the rate of change of the robot's heading (which can then .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibcExamples/src/main/cpp/examples/RamseteCommand/include/subsystems/DriveSubsystem.h :language: c++ :lines: 134-135 - :linenos: - :lineno-start: 134 + :lineno-match: ### Gyroscope Accessor Method @@ -149,8 +138,7 @@ To access the current heading measured by the gyroscope, we include the followin .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/ramsetecommand/subsystems/DriveSubsystem.java :language: java :lines: 178-185 - :linenos: - :lineno-start: 178 + :lineno-match: .. tab-item:: C++ (Source) :sync: C++ (Source) @@ -158,8 +146,7 @@ To access the current heading measured by the gyroscope, we include the followin .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibcExamples/src/main/cpp/examples/RamseteCommand/cpp/subsystems/DriveSubsystem.cpp :language: c++ :lines: 76-78 - :linenos: - :lineno-start: 76 + :lineno-match: ## Configuring the Odometry @@ -175,8 +162,7 @@ First, we create a member instance of the ``DifferentialDriveOdometry`` class: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/ramsetecommand/subsystems/DriveSubsystem.java :language: java :lines: 48-49 - :linenos: - :lineno-start: 48 + :lineno-match: .. tab-item:: C++ (Header) :sync: C++ (Header) @@ -184,8 +170,7 @@ First, we create a member instance of the ``DifferentialDriveOdometry`` class: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibcExamples/src/main/cpp/examples/RamseteCommand/include/subsystems/DriveSubsystem.h :language: c++ :lines: 137-138 - :linenos: - :lineno-start: 137 + :lineno-match: Then we initialize the ``DifferentialDriveOdometry``. @@ -197,8 +182,7 @@ Then we initialize the ``DifferentialDriveOdometry``. .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/ramsetecommand/subsystems/DriveSubsystem.java :language: java :lines: 69-71 - :linenos: - :lineno-start: 69 + :lineno-match: .. tab-item:: C++ (Source) :sync: C++ (Source) @@ -206,8 +190,7 @@ Then we initialize the ``DifferentialDriveOdometry``. .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibcExamples/src/main/cpp/examples/RamseteCommand/cpp/subsystems/DriveSubsystem.cpp :language: c++ :lines: 19 - :linenos: - :lineno-start: 19 + :lineno-match: ### Updating the Odometry @@ -221,8 +204,7 @@ The odometry class must be regularly updated to incorporate new readings from th .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/ramsetecommand/subsystems/DriveSubsystem.java :language: java :lines: 74-79 - :linenos: - :lineno-start: 74 + :lineno-match: .. tab-item:: C++ (Source) :sync: C++ (Source) @@ -230,8 +212,7 @@ The odometry class must be regularly updated to incorporate new readings from th .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibcExamples/src/main/cpp/examples/RamseteCommand/cpp/subsystems/DriveSubsystem.cpp :language: c++ :lines: 38-43 - :linenos: - :lineno-start: 38 + :lineno-match: ### Odometry Accessor Method @@ -245,8 +226,7 @@ To access the robot's current computed pose, we include the following method: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/ramsetecommand/subsystems/DriveSubsystem.java :language: java :lines: 81-88 - :linenos: - :lineno-start: 81 + :lineno-match: .. tab-item:: C++ (Source) :sync: C++ (Source) @@ -254,8 +234,7 @@ To access the robot's current computed pose, we include the following method: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibcExamples/src/main/cpp/examples/RamseteCommand/cpp/subsystems/DriveSubsystem.cpp :language: c++ :lines: 84-86 - :linenos: - :lineno-start: 84 + :lineno-match: .. important:: Before running a ``RamseteCommand``, teams are strongly encouraged to deploy and test the odometry code alone, with values sent to the SmartDashboard or Shuffleboard during the ``DriveSubsystem``'s ``periodic()``. This odometry must be correct for a RamseteCommand to successfully work, as sign or unit errors can cause a robot to move at high speeds in unpredictable directions. @@ -271,8 +250,7 @@ Finally, we must include one additional method - a method that allows us to set .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/ramsetecommand/subsystems/DriveSubsystem.java :language: java :lines: 119-129 - :linenos: - :lineno-start: 119 + :lineno-match: .. tab-item:: C++ (Source) :sync: C++ (Source) @@ -280,8 +258,7 @@ Finally, we must include one additional method - a method that allows us to set .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibcExamples/src/main/cpp/examples/RamseteCommand/cpp/subsystems/DriveSubsystem.cpp :language: c++ :lines: 49-53 - :linenos: - :lineno-start: 49 + :lineno-match: It is very important to use the ``setVoltage()`` method rather than the ordinary ``set()`` method, as this will automatically compensate for battery "voltage sag" during operation. Since our feedforward voltages are physically-meaningful (as they are based on measured identification data), this is essential to ensuring their accuracy. diff --git a/source/docs/software/pathplanning/trajectory-tutorial/creating-following-trajectory.rst b/source/docs/software/pathplanning/trajectory-tutorial/creating-following-trajectory.rst index 5f93e40c68..d0ec93d086 100644 --- a/source/docs/software/pathplanning/trajectory-tutorial/creating-following-trajectory.rst +++ b/source/docs/software/pathplanning/trajectory-tutorial/creating-following-trajectory.rst @@ -12,8 +12,7 @@ As per the :ref:`standard command-based project structure `. @@ -123,8 +115,7 @@ We will first reset our robot's pose to the starting pose of the trajectory. Thi .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/ramsetecommand/RobotContainer.java :language: java :lines: 129-131 - :linenos: - :lineno-start: 129 + :lineno-match: .. tab-item:: C++ (Source) :sync: C++ (Source) @@ -133,8 +124,7 @@ We will first reset our robot's pose to the starting pose of the trajectory. Thi .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibcExamples/src/main/cpp/examples/RamseteCommand/cpp/RobotContainer.cpp :language: c++ :lines: 84-86 - :linenos: - :lineno-start: 84 + :lineno-match: It is very important that the initial robot pose match the first pose in the trajectory. For the purposes of our example, the robot will be reliably starting at a position of ``(0,0)`` with a heading of ``0``. In actual use, however, it is probably not desirable to base your coordinate system on the robot position, and so the starting position for both the robot and the trajectory should be set to some other value. If you wish to use a trajectory that has been defined in robot-centric coordinates in such a situation, you can transform it to be relative to the robot's current pose using the ``transformBy`` method ([Java](https://github.wpilib.org/allwpilib/docs/development/java/edu/wpi/first/math/trajectory/Trajectory.html#transformBy(edu.wpi.first.math.geometry.Transform2d)), [C++](https://github.wpilib.org/allwpilib/docs/development/cpp/classfrc_1_1_trajectory.html#a8edfbd82347bbf32ddfb092679336cd8)). For more information about transforming trajectories, see :ref:`docs/software/advanced-controls/trajectories/transforming-trajectories:Transforming Trajectories`. @@ -150,8 +140,7 @@ Now that we have a trajectory, we can create a command that, when executed, will .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/ramsetecommand/RobotContainer.java :language: java :lines: 112-127 - :linenos: - :lineno-start: 112 + :lineno-match: .. tab-item:: C++ (Source) :sync: C++ (Source) @@ -160,8 +149,7 @@ Now that we have a trajectory, we can create a command that, when executed, will .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibcExamples/src/main/cpp/examples/RamseteCommand/cpp/RobotContainer.cpp :language: c++ :lines: 71-82 - :linenos: - :lineno-start: 71 + :lineno-match: This declaration is fairly substantial, so we'll go through it argument-by-argument: diff --git a/source/docs/software/pathplanning/trajectory-tutorial/entering-constants.rst b/source/docs/software/pathplanning/trajectory-tutorial/entering-constants.rst index 0a33f85f9c..75783af52c 100644 --- a/source/docs/software/pathplanning/trajectory-tutorial/entering-constants.rst +++ b/source/docs/software/pathplanning/trajectory-tutorial/entering-constants.rst @@ -17,14 +17,12 @@ Firstly, we must enter the feedforward and feedback gains which we obtained from .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/ramsetecommand/Constants.java :language: java :lines: 39-49 - :linenos: - :lineno-start: 39 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibcExamples/src/main/cpp/examples/RamseteCommand/include/Constants.h :language: c++ :lines: 47-57 - :linenos: - :lineno-start: 47 + :lineno-match: ## DifferentialDriveKinematics @@ -35,14 +33,12 @@ Additionally, we must create an instance of the ``DifferentialDriveKinematics`` .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/ramsetecommand/Constants.java :language: java :lines: 29-31 - :linenos: - :lineno-start: 29 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibcExamples/src/main/cpp/examples/RamseteCommand/include/Constants.h :language: c++ :lines: 38-39 - :linenos: - :lineno-start: 38 + :lineno-match: ## Max Trajectory Velocity/Acceleration @@ -55,14 +51,12 @@ We must also decide on a nominal max acceleration and max velocity for the robot .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/ramsetecommand/Constants.java :language: java :lines: 57-58 - :linenos: - :lineno-start: 57 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibcExamples/src/main/cpp/examples/RamseteCommand/include/Constants.h :language: c++ :lines: 61-62 - :linenos: - :lineno-start: 61 + :lineno-match: ## Ramsete Parameters @@ -73,11 +67,9 @@ Finally, we must include a pair of parameters for the RAMSETE controller. The v .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/ramsetecommand/Constants.java :language: java :lines: 60-62 - :linenos: - :lineno-start: 60 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibcExamples/src/main/cpp/examples/RamseteCommand/include/Constants.h :language: c++ :lines: 64-67 - :linenos: - :lineno-start: 64 + :lineno-match: diff --git a/source/docs/software/telemetry/writing-sendable-classes.rst b/source/docs/software/telemetry/writing-sendable-classes.rst index bf1815d3f9..0e79645cc0 100644 --- a/source/docs/software/telemetry/writing-sendable-classes.rst +++ b/source/docs/software/telemetry/writing-sendable-classes.rst @@ -9,14 +9,12 @@ For example, here is the implementation of ``initSendable`` from WPILib's ``Bang .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1/wpimath/src/main/java/edu/wpi/first/math/controller/BangBangController.java :language: java :lines: 151-159 - :linenos: - :lineno-start: 151 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1/wpimath/src/main/native/cpp/controller/BangBangController.cpp :language: c++ :lines: 55-69 - :linenos: - :lineno-start: 55 + :lineno-match: To enable the automatic updating of values by WPILib "in the background", ``Sendable`` data names are bound to getter and setter functions rather than specific data values. If a field that you wish to log has no defined setters and getters, they can be defined inline with a lambda expression. @@ -47,13 +45,11 @@ To help users ensure safety when interfacing with dashboard values, ``SendableBu .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibj/src/main/java/edu/wpi/first/wpilibj/motorcontrol/PWMMotorController.java :language: java :lines: 120-126 - :linenos: - :lineno-start: 120 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.1.1-beta-4/wpilibc/src/main/native/cpp/motorcontrol/PWMMotorController.cpp :language: c++ :lines: 56-62 - :linenos: - :lineno-start: 56 + :lineno-match: Additionally, users may call ``builder.setActuator(true)`` to mark any mechanism that might move as a result of ``Sendable`` input as an actuator. Currently, this is used by :ref:`Shuffleboard ` to disable actuator widgets when not in :ref:`LiveWindow ` mode. diff --git a/source/docs/software/vision-processing/roborio/using-the-cameraserver-on-the-roborio.rst b/source/docs/software/vision-processing/roborio/using-the-cameraserver-on-the-roborio.rst index 332b3bae64..c4ed1c6026 100644 --- a/source/docs/software/vision-processing/roborio/using-the-cameraserver-on-the-roborio.rst +++ b/source/docs/software/vision-processing/roborio/using-the-cameraserver-on-the-roborio.rst @@ -12,8 +12,7 @@ The following program starts automatic capture of a USB camera like the Microsof .. rli:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/quickvision/Robot.java :language: java :lines: 7-19 - :linenos: - :lineno-start: 7 + :lineno-match: .. rli:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/QuickVision/cpp/Robot.cpp :language: c++ @@ -37,8 +36,7 @@ In the following example a thread created in ``Robot`` constructor gets the Came .. rli:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/intermediatevision/Robot.java :language: java :lines: 7-65 - :linenos: - :lineno-start: 7 + :lineno-match: .. tab-item:: c++ :sync: tabcode-c++ diff --git a/source/docs/software/vscode-overview/creating-robot-program.rst b/source/docs/software/vscode-overview/creating-robot-program.rst index ea0b41a126..6505fa7f41 100644 --- a/source/docs/software/vscode-overview/creating-robot-program.rst +++ b/source/docs/software/vscode-overview/creating-robot-program.rst @@ -25,14 +25,12 @@ The :code:`TimedRobot` class is the base class recommended for most users. It p .. rli:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/timedskeleton/Robot.java :language: java :lines: 7-53 - :linenos: - :lineno-start: 7 + :lineno-match: .. rli:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/templates/timedskeleton/cpp/Robot.cpp :language: c++ :lines: 5-29 - :linenos: - :lineno-start: 5 + :lineno-match: Periodic methods are called every 20 ms by default. This can be changed by calling the superclass constructor with the new desired update rate. diff --git a/source/docs/software/wpilib-tools/robot-simulation/physics-sim.rst b/source/docs/software/wpilib-tools/robot-simulation/physics-sim.rst index 8c33afb7d2..94b11640ea 100644 --- a/source/docs/software/wpilib-tools/robot-simulation/physics-sim.rst +++ b/source/docs/software/wpilib-tools/robot-simulation/physics-sim.rst @@ -45,8 +45,7 @@ In the following example, we simulate an elevator given the mass of the moving c .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatorsimulation/subsystems/Elevator.java :language: java :lines: 49-61 - :linenos: - :lineno-start: 49 + :lineno-match: .. tab-item:: C++ :sync: c++ @@ -54,8 +53,7 @@ In the following example, we simulate an elevator given the mass of the moving c .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/ElevatorSimulation/include/subsystems/Elevator.h :language: c++ :lines: 51-61 - :linenos: - :lineno-start: 51 + :lineno-match: Next, :code:`teleopPeriodic`/:code:`TeleopPeriodic` (Java/C++) uses a simple PID control loop to drive our elevator to a setpoint 30 inches off the ground. @@ -67,14 +65,12 @@ Next, :code:`teleopPeriodic`/:code:`TeleopPeriodic` (Java/C++) uses a simple PID .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatorsimulation/Robot.java :language: java :lines: 30-39 - :linenos: - :lineno-start: 30 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatorsimulation/subsystems/Elevator.java :language: java :lines: 102-109 - :linenos: - :lineno-start: 102 + :lineno-match: .. tab-item:: C++ :sync: c++ @@ -82,14 +78,12 @@ Next, :code:`teleopPeriodic`/:code:`TeleopPeriodic` (Java/C++) uses a simple PID .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/ElevatorSimulation/cpp/Robot.cpp :language: c++ :lines: 20-28 - :linenos: - :lineno-start: 20 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/ElevatorSimulation/cpp/subsystems/Elevator.cpp :language: c++ :lines: 42-50 - :linenos: - :lineno-start: 42 + :lineno-match: Next, :code:`simulationPeriodic`/:code:`SimulationPeriodic` (Java/C++) uses the voltage applied to the motor to update the simulated position of the elevator. We use :code:`SimulationPeriodic` because it runs periodically only for simulated robots. This means that our simulation code will not be run on a real robot. @@ -105,8 +99,7 @@ Finally, the simulated encoder's distance reading is set using the simulated ele .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatorsimulation/subsystems/Elevator.java :language: java :lines: 82-95 - :linenos: - :lineno-start: 82 + :lineno-match: .. tab-item:: C++ :sync: c++ @@ -114,5 +107,4 @@ Finally, the simulated encoder's distance reading is set using the simulated ele .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/ElevatorSimulation/cpp/subsystems/Elevator.cpp :language: c++ :lines: 20-35 - :linenos: - :lineno-start: 20 + :lineno-match: diff --git a/source/docs/software/wpilib-tools/robot-simulation/unit-testing.rst b/source/docs/software/wpilib-tools/robot-simulation/unit-testing.rst index 5fedef2a6b..ef130a260e 100644 --- a/source/docs/software/wpilib-tools/robot-simulation/unit-testing.rst +++ b/source/docs/software/wpilib-tools/robot-simulation/unit-testing.rst @@ -73,8 +73,7 @@ For Java tests to run, make sure that your ``build.gradle`` file contains the fo .. rli:: https://raw.githubusercontent.com/wpilibsuite/vscode-wpilib/v2025.1.1-beta-1/vscode-wpilib/resources/gradle/java/build.gradle :language: groovy :lines: 75-78 - :linenos: - :lineno-start: 75 + :lineno-match: Use :guilabel:`Test Robot Code` from the Command Palette to run the tests. Results will be reported in the terminal output, each test will have a ``FAILED`` or ``PASSED``/``OK`` label next to the test name in the output. JUnit (Java only) will generate a HTML document in ``build/reports/tests/test/index.html`` with a more detailed overview of the results; if there are any failed tests a link to render the document in your browser will be printed in the terminal output. diff --git a/source/docs/xrp-robot/programming-xrp.rst b/source/docs/xrp-robot/programming-xrp.rst index 6d14d96979..e2d9f975dd 100644 --- a/source/docs/xrp-robot/programming-xrp.rst +++ b/source/docs/xrp-robot/programming-xrp.rst @@ -37,8 +37,7 @@ To run an XRP program, first, ensure that your XRP is powered on. Next, connect .. rli:: https://raw.githubusercontent.com/wpilibsuite/vscode-wpilib/v2025.1.1-beta-1/vscode-wpilib/resources/gradle/javaxrp/build.gradle :language: groovy :lines: 44-47 - :linenos: - :lineno-start: 44 + :lineno-match: :emphasize-lines: 2 Now to start your XRP robot code, open the WPILib Command Palette (type :kbd:`Ctrl+Shift+P`) and select "Simulate Robot Code", or press :kbd:`F5`. diff --git a/source/docs/zero-to-robot/step-4/creating-test-drivetrain-program-cpp-java-python.rst b/source/docs/zero-to-robot/step-4/creating-test-drivetrain-program-cpp-java-python.rst index 6f2221ebce..f3aa1fd5b3 100644 --- a/source/docs/zero-to-robot/step-4/creating-test-drivetrain-program-cpp-java-python.rst +++ b/source/docs/zero-to-robot/step-4/creating-test-drivetrain-program-cpp-java-python.rst @@ -144,16 +144,14 @@ Now let's look at various parts of the code. .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/GettingStarted/cpp/Robot.cpp :language: c++ :lines: 5-9 - :linenos: - :lineno-start: 5 + :lineno-match: .. tab-item:: Python .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/d89b0587a1e1111239728140466c7dc4324d4005/GettingStarted/robot.py :language: python :lines: 8-9 - :linenos: - :lineno-start: 8 + :lineno-match: .. tab-item:: CTRE-Phoenix6 :sync: ctre6 @@ -258,8 +256,7 @@ Our code needs to reference the components of WPILib that are used. In C++ this .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gettingstarted/Robot.java :language: java :lines: 19-25 - :linenos: - :lineno-start: 19 + :lineno-match: .. tab-item:: C++ :sync: c++ @@ -267,8 +264,7 @@ Our code needs to reference the components of WPILib that are used. In C++ this .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/GettingStarted/cpp/Robot.cpp :language: c++ :lines: 50-60 - :linenos: - :lineno-start: 50 + :lineno-match: .. tab-item:: Python :sync: python @@ -303,14 +299,12 @@ Our code needs to reference the components of WPILib that are used. In C++ this .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/GettingStarted/cpp/Robot.cpp :language: c++ :lines: 12-13 - :linenos: - :lineno-start: 12 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/GettingStarted/cpp/Robot.cpp :language: c++ :lines: 17-23 - :linenos: - :lineno-start: 17 + :lineno-match: ```c++ private: @@ -371,14 +365,12 @@ Our code needs to reference the components of WPILib that are used. In C++ this .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/GettingStarted/cpp/Robot.cpp :language: c++ :lines: 12-13 - :linenos: - :lineno-start: 12 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/GettingStarted/cpp/Robot.cpp :language: c++ :lines: 17-23 - :linenos: - :lineno-start: 17 + :lineno-match: ```c++ private: @@ -424,14 +416,12 @@ Our code needs to reference the components of WPILib that are used. In C++ this .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/GettingStarted/cpp/Robot.cpp :language: c++ :lines: 12-13 - :linenos: - :lineno-start: 12 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/GettingStarted/cpp/Robot.cpp :language: c++ :lines: 17-23 - :linenos: - :lineno-start: 17 + :lineno-match: ```c++ private: @@ -499,20 +489,17 @@ The ``Robot`` constructor for our sample program inverts the right side of the d .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gettingstarted/Robot.java :language: java :lines: 38-54 - :linenos: - :lineno-start: 38 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/GettingStarted/cpp/Robot.cpp :language: c++ :lines: 25-36 - :linenos: - :lineno-start: 25 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/d89b0587a1e1111239728140466c7dc4324d4005/GettingStarted/robot.py :language: python :lines: 31-43 - :linenos: - :lineno-start: 31 + :lineno-match: The ``AutonomousInit`` method is run once each time the robot transitions to autonomous from another mode. In this program, we restart the ``Timer`` in this method. @@ -525,20 +512,17 @@ The ``AutonomousInit`` method is run once each time the robot transitions to aut .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gettingstarted/Robot.java :language: java :lines: 56-64 - :linenos: - :lineno-start: 56 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/GettingStarted/cpp/Robot.cpp :language: c++ :lines: 38-45 - :linenos: - :lineno-start: 38 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/d89b0587a1e1111239728140466c7dc4324d4005/GettingStarted/robot.py :language: python :lines: 45-52 - :linenos: - :lineno-start: 45 + :lineno-match: Like in Autonomous, the Teleop mode has a ``TeleopInit`` and ``TeleopPeriodic`` function. In this example we don't have anything to do in ``TeleopInit``, it is provided for illustration purposes only. In ``TeleopPeriodic``, the code uses the ``ArcadeDrive`` method to map the Y-axis of the left thumbstick of the ``XBoxController`` to forward/back motion of the drive motors and the X-axis to turning motion. @@ -549,20 +533,17 @@ Like in Autonomous, the Teleop mode has a ``TeleopInit`` and ``TeleopPeriodic`` .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gettingstarted/Robot.java :language: java :lines: 66-73 - :linenos: - :lineno-start: 66 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2025.1.1-beta-2/wpilibcExamples/src/main/cpp/examples/GettingStarted/cpp/Robot.cpp :language: c++ :lines: 45-48 - :linenos: - :lineno-start: 45 + :lineno-match: .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/d89b0587a1e1111239728140466c7dc4324d4005/GettingStarted/robot.py :language: python :lines: 54-58 - :linenos: - :lineno-start: 54 + :lineno-match: Test Mode is used for testing robot functionality. Similar to ``TeleopInit``, the ``TestInit`` and ``TestPeriodic`` methods are provided here for illustrative purposes only.