From 2831a83884f4705c2a3c2b01ed36f268c5956721 Mon Sep 17 00:00:00 2001 From: sciencewhiz Date: Mon, 20 Jan 2025 19:58:23 -0800 Subject: [PATCH 1/3] Update Python example RLIs --- .github/workflows/inspector.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/inspector.json b/.github/workflows/inspector.json index b6a661d446..fedbe7fc61 100644 --- a/.github/workflows/inspector.json +++ b/.github/workflows/inspector.json @@ -13,7 +13,7 @@ { "baseUrl": "https://raw.githubusercontent.com/robotpy/examples/", "versionScheme": "\\d{4}\\.\\d\\.\\d\\.\\d(?:-(?:alpha|beta)-\\d)?|[0-9a-f]{40}", - "latestVersion": "36c64f286a38478f5e04d60321c57b0a9d1c5f17" + "latestVersion": "4e7b525b47246e55ad617a66f2c3d9fda34484a3" }, { "baseUrl": "https://raw.githubusercontent.com/wpilibsuite/vscode-wpilib/", From 3732d32047aba478dda81c565b308b382d7e44be Mon Sep 17 00:00:00 2001 From: github-actions Date: Tue, 21 Jan 2025 04:00:40 +0000 Subject: [PATCH 2/3] Autofix RLIs --- source/docs/contributing/frc-docs/style-guide.rst | 2 +- .../controllers/profiled-pidcontroller.rst | 2 +- .../state-space/state-space-flywheel-walkthrough.rst | 4 ++-- .../software/basic-programming/robot-preferences.rst | 10 +++++----- .../software/can-devices/power-distribution-module.rst | 8 ++++---- .../roborio/using-the-cameraserver-on-the-roborio.rst | 6 +++--- ...reating-test-drivetrain-program-cpp-java-python.rst | 8 ++++---- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/source/docs/contributing/frc-docs/style-guide.rst b/source/docs/contributing/frc-docs/style-guide.rst index 0f3874e69a..3b5662b263 100644 --- a/source/docs/contributing/frc-docs/style-guide.rst +++ b/source/docs/contributing/frc-docs/style-guide.rst @@ -111,7 +111,7 @@ When possible, instead of using code blocks, an RLI should be used. This pulls :lines: 50-60 :lineno-match: -.. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/36c64f286a38478f5e04d60321c57b0a9d1c5f17/GettingStarted/robot.py +.. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/4e7b525b47246e55ad617a66f2c3d9fda34484a3/GettingStarted/robot.py :language: python :lines: 12-29 :lineno-match: diff --git a/source/docs/software/advanced-controls/controllers/profiled-pidcontroller.rst b/source/docs/software/advanced-controls/controllers/profiled-pidcontroller.rst index cde300943d..1f7033b631 100644 --- a/source/docs/software/advanced-controls/controllers/profiled-pidcontroller.rst +++ b/source/docs/software/advanced-controls/controllers/profiled-pidcontroller.rst @@ -153,7 +153,7 @@ A more complete example of ``ProfiledPIDController`` usage is provided in the El :lines: 5- :lineno-match: - .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/36c64f286a38478f5e04d60321c57b0a9d1c5f17/ElevatorProfiledPID/robot.py + .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/4e7b525b47246e55ad617a66f2c3d9fda34484a3/ElevatorProfiledPID/robot.py :language: python :lines: 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 45e72acf59..2907e1816a 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 @@ -86,12 +86,12 @@ The ``LinearSystem`` class contains methods for easily creating state-space syst .. tab-item:: Python - .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/36c64f286a38478f5e04d60321c57b0a9d1c5f17/StateSpaceFlywheelSysId/robot.py + .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/4e7b525b47246e55ad617a66f2c3d9fda34484a3/StateSpaceFlywheelSysId/robot.py :language: python :lines: 23-27 :lineno-match: - .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/36c64f286a38478f5e04d60321c57b0a9d1c5f17/StateSpaceFlywheelSysId/robot.py + .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/4e7b525b47246e55ad617a66f2c3d9fda34484a3/StateSpaceFlywheelSysId/robot.py :language: python :lines: 37-48 :lineno-match: diff --git a/source/docs/software/basic-programming/robot-preferences.rst b/source/docs/software/basic-programming/robot-preferences.rst index bee1674c8a..20482dd77b 100644 --- a/source/docs/software/basic-programming/robot-preferences.rst +++ b/source/docs/software/basic-programming/robot-preferences.rst @@ -34,11 +34,11 @@ This example shows how to utilize Preferences to change the setpoint of a PID co .. tab-item:: Python :sync: Python - .. rli:: https://raw.githubusercontent.com/robotpy/examples/36c64f286a38478f5e04d60321c57b0a9d1c5f17/ArmSimulation/constants.py + .. rli:: https://raw.githubusercontent.com/robotpy/examples/4e7b525b47246e55ad617a66f2c3d9fda34484a3/ArmSimulation/constants.py :language: python :lines: 18-23 - .. rli:: https://raw.githubusercontent.com/robotpy/examples/36c64f286a38478f5e04d60321c57b0a9d1c5f17/ArmSimulation/subsytems/arm.py + .. rli:: https://raw.githubusercontent.com/robotpy/examples/4e7b525b47246e55ad617a66f2c3d9fda34484a3/ArmSimulation/subsytems/arm.py :language: python :lines: 20-23,37-41 @@ -69,7 +69,7 @@ If using the Command Framework, this type of code could be placed in the constru .. tab-item:: Python :sync: Python - .. rli:: https://raw.githubusercontent.com/robotpy/examples/36c64f286a38478f5e04d60321c57b0a9d1c5f17/ArmSimulation/subsytems/arm.py + .. rli:: https://raw.githubusercontent.com/robotpy/examples/4e7b525b47246e55ad617a66f2c3d9fda34484a3/ArmSimulation/subsytems/arm.py :language: python :lines: 43-50 @@ -102,10 +102,10 @@ Depending on the data that is stored in preferences, you can use it when you rea .. tab-item:: Python :sync: Python - .. rli:: https://raw.githubusercontent.com/robotpy/examples/36c64f286a38478f5e04d60321c57b0a9d1c5f17/ArmSimulation/robot.py + .. rli:: https://raw.githubusercontent.com/robotpy/examples/4e7b525b47246e55ad617a66f2c3d9fda34484a3/ArmSimulation/robot.py :language: python :lines: 22-28 - .. rli:: https://raw.githubusercontent.com/robotpy/examples/36c64f286a38478f5e04d60321c57b0a9d1c5f17/ArmSimulation/subsytems/arm.py + .. rli:: https://raw.githubusercontent.com/robotpy/examples/4e7b525b47246e55ad617a66f2c3d9fda34484a3/ArmSimulation/subsytems/arm.py :language: python :lines: 52-57 diff --git a/source/docs/software/can-devices/power-distribution-module.rst b/source/docs/software/can-devices/power-distribution-module.rst index 2fe76d7258..1f42dd4afa 100644 --- a/source/docs/software/can-devices/power-distribution-module.rst +++ b/source/docs/software/can-devices/power-distribution-module.rst @@ -42,7 +42,7 @@ Note: it is not necessary to create a PowerDistribution object unless you need t :language: c++ :lines: 28-31 - .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/36c64f286a38478f5e04d60321c57b0a9d1c5f17/CANPDP/robot.py + .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/4e7b525b47246e55ad617a66f2c3d9fda34484a3/CANPDP/robot.py :language: python :lines: 34-37 @@ -61,7 +61,7 @@ Monitoring the bus voltage can be useful for (among other things) detecting when :language: c++ :lines: 33-35 - .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/36c64f286a38478f5e04d60321c57b0a9d1c5f17/CANPDP/robot.py + .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/4e7b525b47246e55ad617a66f2c3d9fda34484a3/CANPDP/robot.py :language: python :lines: 39-41 @@ -80,7 +80,7 @@ Monitoring the temperature can be useful for detecting if the robot has been dra :language: c++ :lines: 37-49 - .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/36c64f286a38478f5e04d60321c57b0a9d1c5f17/CANPDP/robot.py + .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/4e7b525b47246e55ad617a66f2c3d9fda34484a3/CANPDP/robot.py :language: python :lines: 43-55 @@ -101,7 +101,7 @@ The PDP/PDH also allows users to monitor the current drawn by the individual dev :language: c++ :lines: 22-26 - .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/36c64f286a38478f5e04d60321c57b0a9d1c5f17/CANPDP/robot.py + .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/4e7b525b47246e55ad617a66f2c3d9fda34484a3/CANPDP/robot.py :language: python :lines: 28-32 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 d7ea613c30..cd7e15e1ed 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 @@ -18,7 +18,7 @@ The following program starts automatic capture of a USB camera like the Microsof :language: c++ :lines: 7-8, 16-18, 20, 25-31 - .. rli:: https://raw.githubusercontent.com/robotpy/examples/36c64f286a38478f5e04d60321c57b0a9d1c5f17/QuickVision/robot.py + .. rli:: https://raw.githubusercontent.com/robotpy/examples/4e7b525b47246e55ad617a66f2c3d9fda34484a3/QuickVision/robot.py :language: python :lines: 8-17 :linenos: @@ -69,14 +69,14 @@ In the following example a thread created in ``Robot`` constructor gets the Came Here's what your ``robot.py`` needs to contain to launch the image processing process: - .. rli:: https://raw.githubusercontent.com/robotpy/examples/36c64f286a38478f5e04d60321c57b0a9d1c5f17/IntermediateVision/robot.py + .. rli:: https://raw.githubusercontent.com/robotpy/examples/4e7b525b47246e55ad617a66f2c3d9fda34484a3/IntermediateVision/robot.py :language: python :lines: 8-17 :linenos: The ``launch("vision.py")`` function says to launch ``vision.py`` and call the ``run`` function in that file. Here's what is in ``vision.py``: - .. rli:: https://raw.githubusercontent.com/robotpy/examples/36c64f286a38478f5e04d60321c57b0a9d1c5f17/IntermediateVision/vision.py + .. rli:: https://raw.githubusercontent.com/robotpy/examples/4e7b525b47246e55ad617a66f2c3d9fda34484a3/IntermediateVision/vision.py :language: python :lines: 12-55 :linenos: 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 aab83fbe92..f94aa1235d 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 @@ -148,7 +148,7 @@ Now let's look at various parts of the code. .. tab-item:: Python - .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/36c64f286a38478f5e04d60321c57b0a9d1c5f17/GettingStarted/robot.py + .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/4e7b525b47246e55ad617a66f2c3d9fda34484a3/GettingStarted/robot.py :language: python :lines: 8-9 :lineno-match: @@ -496,7 +496,7 @@ The ``Robot`` constructor for our sample program inverts the right side of the d :lines: 25-36 :lineno-match: - .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/36c64f286a38478f5e04d60321c57b0a9d1c5f17/GettingStarted/robot.py + .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/4e7b525b47246e55ad617a66f2c3d9fda34484a3/GettingStarted/robot.py :language: python :lines: 31-43 :lineno-match: @@ -519,7 +519,7 @@ The ``AutonomousInit`` method is run once each time the robot transitions to aut :lines: 38-45 :lineno-match: - .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/36c64f286a38478f5e04d60321c57b0a9d1c5f17/GettingStarted/robot.py + .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/4e7b525b47246e55ad617a66f2c3d9fda34484a3/GettingStarted/robot.py :language: python :lines: 45-52 :lineno-match: @@ -540,7 +540,7 @@ Like in Autonomous, the Teleop mode has a ``TeleopInit`` and ``TeleopPeriodic`` :lines: 45-48 :lineno-match: - .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/36c64f286a38478f5e04d60321c57b0a9d1c5f17/GettingStarted/robot.py + .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/4e7b525b47246e55ad617a66f2c3d9fda34484a3/GettingStarted/robot.py :language: python :lines: 54-58 :lineno-match: From 1c0e43cddd17160cb9da882c0f3bad6f9a068dd1 Mon Sep 17 00:00:00 2001 From: sciencewhiz Date: Mon, 20 Jan 2025 20:08:50 -0800 Subject: [PATCH 3/3] Manually fix RLIs --- .../controllers/trapezoidal-profiles.rst | 2 +- .../state-space-flywheel-walkthrough.rst | 24 +++++++++---------- .../state-space/state-space-observers.rst | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/source/docs/software/advanced-controls/controllers/trapezoidal-profiles.rst b/source/docs/software/advanced-controls/controllers/trapezoidal-profiles.rst index f1ae0b0856..016acab0e3 100644 --- a/source/docs/software/advanced-controls/controllers/trapezoidal-profiles.rst +++ b/source/docs/software/advanced-controls/controllers/trapezoidal-profiles.rst @@ -172,7 +172,7 @@ A more complete example of ``TrapezoidProfile`` usage is provided in the Elevato :lines: 5- :lineno-match: - .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/36c64f286a38478f5e04d60321c57b0a9d1c5f17/ElevatorTrapezoidProfile/robot.py + .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/4e7b525b47246e55ad617a66f2c3d9fda34484a3/ElevatorTrapezoidProfile/robot.py :language: python :lines: 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 2907e1816a..65cb9a852c 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 @@ -133,14 +133,14 @@ The ``LinearSystem`` class contains methods to easily create a model of a flywhe .. tab-item:: Python :sync: python - .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/36c64f286a38478f5e04d60321c57b0a9d1c5f17/StateSpaceFlywheel/robot.py + .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/4e7b525b47246e55ad617a66f2c3d9fda34484a3/StateSpaceFlywheel/robot.py :language: python - :lines: 21-25 + :lines: 22-26 :lineno-match: - .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/36c64f286a38478f5e04d60321c57b0a9d1c5f17/StateSpaceFlywheel/robot.py + .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/4e7b525b47246e55ad617a66f2c3d9fda34484a3/StateSpaceFlywheel/robot.py :language: python - :lines: 37-46 + :lines: 38-47 :lineno-match: ## Kalman Filters: Observing Flywheel State @@ -182,9 +182,9 @@ Because the feedback controller computes error using the :term:`x-hat` estimated .. tab-item:: Python :sync: python - .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/36c64f286a38478f5e04d60321c57b0a9d1c5f17/StateSpaceFlywheel/robot.py + .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/4e7b525b47246e55ad617a66f2c3d9fda34484a3/StateSpaceFlywheel/robot.py :language: python - :lines: 48-54 + :lines: 49-55 :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. @@ -223,9 +223,9 @@ Much like ``SimpleMotorFeedforward`` can be used to generate feedforward voltage .. tab-item:: Python :sync: python - .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/36c64f286a38478f5e04d60321c57b0a9d1c5f17/StateSpaceFlywheel/robot.py + .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/4e7b525b47246e55ad617a66f2c3d9fda34484a3/StateSpaceFlywheel/robot.py :language: python - :lines: 56-66 + :lines: 57-67 :lineno-match: ## Bringing it All Together: LinearSystemLoop @@ -258,9 +258,9 @@ LinearSystemLoop combines our system, controller, and observer that we created e .. tab-item:: Python :sync: python - .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/36c64f286a38478f5e04d60321c57b0a9d1c5f17/StateSpaceFlywheel/robot.py + .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/4e7b525b47246e55ad617a66f2c3d9fda34484a3/StateSpaceFlywheel/robot.py :language: python - :lines: 68-71 + :lines: 69-72 :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``. @@ -291,9 +291,9 @@ Once we have our ``LinearSystemLoop``, the only thing left to do is actually run .. tab-item:: Python :sync: python - .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/36c64f286a38478f5e04d60321c57b0a9d1c5f17/StateSpaceFlywheel/robot.py + .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/4e7b525b47246e55ad617a66f2c3d9fda34484a3/StateSpaceFlywheel/robot.py :language: python - :lines: 87-109 + :lines: 88-110 :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 2df123cb56..8f2e9cb078 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 @@ -110,9 +110,9 @@ WPILib's Kalman Filter classes' constructors take a linear system, a vector of p .. tab-item:: Python - .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/36c64f286a38478f5e04d60321c57b0a9d1c5f17/StateSpaceFlywheel/robot.py + .. remoteliteralinclude:: https://raw.githubusercontent.com/robotpy/examples/4e7b525b47246e55ad617a66f2c3d9fda34484a3/StateSpaceFlywheel/robot.py :language: python - :lines: 48-54 + :lines: 49-55 :lineno-match: ## Footnotes