Skip to content

Commit d1a15b9

Browse files
Update Livewindow docs (#1674)
* Update SmartDashboard Livewindow / Test Mode docs Fix code examples Update screenshots Rewrite Test Mode article to reference exiting LiveWindow Smartdashboard docs, removing duplicated and conflicting information Moves Test mode article from VS Code to Basic Programming Add link to Test mode article from DS, and add other mode descriptions Fixes #514 * Apply suggestions from code review Co-authored-by: Dalton Smith <[email protected]> * Fix AddLW usage Co-authored-by: Dalton Smith <[email protected]>
1 parent dc238f0 commit d1a15b9

File tree

10 files changed

+100
-86
lines changed

10 files changed

+100
-86
lines changed

source/docs/software/basic-programming/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ Basic Programming
77
git-getting-started.rst
88
cpp-units
99
joystick
10+
using-test-mode
1011
reading-stacktraces
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Using Test Mode
2+
===============
3+
4+
Test mode is designed to enable programmers to have a place to put code to verify that all systems on the robot are functioning. In each of the robot program templates there is a place to add test code to the robot.
5+
6+
Enabling Test Mode
7+
------------------
8+
9+
.. image:: /docs/software/dashboards/smartdashboard/test-mode-and-live-window/images/enabling-test-mode/setting-test-mode-driver-station.png
10+
:alt: Selecting the "Test" button on the Driver Station and then "Enable".
11+
12+
Test mode on the robot can be enabled from the Driver Station just like autonomous or teleop. To enable test mode in the Driver Station, select the "Test" button and enable the robot. The test mode code will then run.
13+
14+
LiveWindow in Test Mode
15+
-----------------------
16+
17+
With LiveWindow, all actuator's outputs can be controlled on the Dashboard and all sensor values can be seen. PID Controllers can also be tuned. The sensors and actuators are added automatically, no code is necessary. See :doc:`/docs/software/dashboards/smartdashboard/test-mode-and-live-window/index` for more details.
18+
19+
Adding Test mode code to your robot code
20+
----------------------------------------
21+
22+
When in test mode, the ``testInit`` method is run once, and the testPeriodic method is run once per tick, in addition to ``robotPeriodic``, similar to teleop and autonomous control modes.
23+
24+
Adding test mode can be as painless as calling your already written Teleop methods from Test. Or you can write special code to try out a new feature that is only run in Test mode, before integrating it into your teleop or autonomous code. You could even write code to move all motors and check all sensors to help the pit crew!
25+
26+
.. warning:: If you write your own test code, it may interfere with the LiveWindow code that can control actuators and is enabled automatically. You may need to call ``LiveWindow.getInstance().setEnabled(false)`` in your testInit method to avoid this.

source/docs/software/dashboards/smartdashboard/test-mode-and-live-window/displaying-LiveWindow-values.rst

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
Displaying LiveWindow Values
22
============================
33

4-
.. note:: LiveWindow will automatically add your sensors for you. There is no need to do it manually.
5-
6-
LiveWindow values may also be displayed by writing the code yourself and adding it to your robot program. LiveWindow will display values grouped in subsystems. This is a convenient method of displaying whether they are actual command based program subsystems or just a grouping that you decide to use in your program.
4+
LiveWindow will automatically add your sensors and actuators for you. There is no need to do it manually. LiveWindow values may also be displayed by writing the code yourself and adding it to your robot program. This allows you to customize the names and group them in subsystems. This is a convenient method of displaying whether they are actual command based program subsystems or just a grouping that you decide to use in your program.
75

86
Adding the Necessary Code to your Program
97
-----------------------------------------
@@ -15,24 +13,50 @@ For each sensor or actuator that is created, set the subsystem name and display
1513
.. code-tab:: java
1614

1715
Ultrasonic ultrasonic = new Ultrasonic(1, 2);
18-
ultrasonic.setName("Arm", "Ultrasonic");
16+
SendableRegistry.setName(ultrasonic, "Arm", "Ultrasonic");
17+
18+
Jaguar elbow = new Jaguar(1);
19+
SendableRegistry.setName(elbow, "Arm", "Elbow");
20+
21+
Victor wrist = new Victor(2);
22+
SendableRegistry.setName(wrist, "Arm", "Wrist");
23+
24+
.. code-tab:: cpp
25+
26+
frc::Ultrasonic ultrasonic{1, 2};
27+
SendableRegistry::SetName(ultrasonic, "Arm", "Ultrasonic");
28+
29+
frc::Jaguar elbow{1};
30+
SendableRegistry::SetName(elbow, "Arm", "Elbow");
31+
32+
frc::Victor wrist{2};
33+
SendableRegistry::SetName(wrist, "Arm", "Wrist");
34+
35+
If your objects are in a ``Subsystem``, this can be simplified using the addChild method of ``SubsystemBase``
36+
37+
.. tabs::
38+
39+
.. code-tab:: java
40+
41+
Ultrasonic ultrasonic = new Ultrasonic(1, 2);
42+
addChild("Ultrasonic", ultrasonic);
1943

2044
Jaguar elbow = new Jaguar(1);
21-
elbow.setName("Arm", "Elbow");
45+
addChild("Elbow", elbow);
2246

2347
Victor wrist = new Victor(2);
24-
wrist.setName("Arm", "Wrist");
48+
addChild("Wrist", wrist);
2549

2650
.. code-tab:: cpp
2751

2852
frc::Ultrasonic ultrasonic{1, 2};
29-
ultrasonic.SetName("Arm", "Ultrasonic");
53+
AddChild("Ultrasonic", ultrasonic);
3054

3155
frc::Jaguar elbow{1};
32-
elbow.SetName("Arm", "Elbow");
56+
AddChild("Elbow", elbow);
3357

3458
frc::Victor wrist{2};
35-
wrist.SetName("Arm", "Wrist");
59+
AddChild("Wrist", wrist);
3660

3761
Viewing the Display in SmartDashboard
3862
-----------------------------------------

source/docs/software/dashboards/smartdashboard/test-mode-and-live-window/enabling-test-mode.rst

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,43 @@ Enable Test Mode in the Driver Station by clicking on the "Test" button and sett
1414
Explicitly vs. implicit test mode display
1515
-----------------------------------------
1616

17-
.. image:: images/enabling-test-mode/explicit-test-mode-display.png
18-
:alt: Highlights explicitly adding sensors to test in code.
17+
.. tabs::
1918

20-
All sensors and actuators will automatically be displayed on the SmartDashboard in test mode and will be named using the object type (such as Jaguar, Analog, Victor, etc.) with the module number and channel number with which the object was created. In addition, the program can explicitly add sensors and actuators to the test mode display, in which case programmer-defined subsystem and object names can be specified making the program clearer. This example illustrates explicitly defining those sensors and actuators in the highlighted code.
19+
.. code-tab:: java
20+
21+
PWMSparkMax leftDrive;
22+
PWMSparkMax rightDrive;
23+
PWMVictorSPX arm;
24+
BuiltInAccelerometer accel;
25+
26+
@Override
27+
public void robotInit() {
28+
leftDrive = new PWMSparkMax(0);
29+
rightDrive = new PWMSparkMax(1);
30+
arm = new PWMVictorSPX(2);
31+
accel = new BuiltInAccelerometer();
32+
SendableRegistry.setName(arm, "SomeSubsystem", "Arm");
33+
SendableRegistry.setName(accel, "SomeSubsystem", "Accelerometer");
34+
}
35+
36+
.. code-tab:: cpp
37+
38+
frc::PWMSparkMax leftDrive{0};
39+
frc::PWMSparkMax rigthDrive{1};
40+
frc::BuiltInAccelerometer accel{};
41+
frc::PWMVictorSPX arm{3};
42+
43+
void Robot::RobotInit() {
44+
wpi::SendableRegistry::SetName(&arm, "SomeSubsystem", "Arm");
45+
wpi::SendableRegistry::SetName(&accel, "SomeSubsystem", "Accelerometer");
46+
}
47+
48+
All sensors and actuators will automatically be displayed on the SmartDashboard in test mode and will be named using the object type (such as PWMSparkMax, PWMVictorSPX, BuiltInAccelerometer, etc.) with channel number with which the object was created. In addition, the program can explicitly add sensors and actuators to the test mode display, in which case programmer-defined subsystem and object names can be specified making the program clearer. This example illustrates explicitly defining those sensors and actuators.
2149

2250
Understanding what is displayed in Test mode
2351
--------------------------------------------
2452

2553
.. image:: images/enabling-test-mode/test-mode-display.png
2654
:alt: Highlights both ungrouped and subsystem motors displayed in test mode.
2755

28-
This is the output in the SmartDashboard display when the robot is placed into test mode. In the display shown above the objects listed as Ungrouped were implicitly created by WPILib when the corresponding objects were created. These objects are contained in a subsystem group called "Ungrouped" **(1)** and are named with the device type (Analog, Jaguar in this case), and the module and channel numbers. The objects shown in the "SomeSubsystem" **(2)** group are explicitly created by the programmer from the code example in the previous section. These are named in the calls to ``LiveWindow.addActuator()`` and ``LiveWindow.AddSensor()``. Explicitly created sensors and actuators will be grouped by the specified subsystem.
56+
This is the output in the SmartDashboard display when the robot is placed into test mode. In the display shown above the objects listed as Ungrouped were implicitly created by WPILib when the corresponding objects were created. These objects are contained in a subsystem group called "Ungrouped" **(1)** and are named with the device type (PWMSparkMax in this case), and the channel numbers. The objects shown in the "SomeSubsystem" **(2)** group are explicitly created by the programmer from the code example in the previous section. These are named in the calls to ``SendableRegistry.setName()``. Explicitly created sensors and actuators will be grouped by the specified subsystem.
Loading

source/docs/software/driverstation/driver-station.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@ Operation Tab
4848

4949
The Operations Tab is used to control the mode of the robot and provide additional key status indicators while the robot is running.
5050

51-
1. Robot Mode - This section controls the Robot Mode. Practice Mode causes the robot to cycle through the same transitions as an FRC match after the Enable button is pressed (timing for practice mode can be found on the setup tab).
51+
1. Robot Mode - This section controls the Robot Mode.
52+
53+
- Teleoperated Mode causes the robot to run the code in the Teleoperated portion of the match.
54+
- Autonomous Mode causes the robot to run the code in the Autonomous portion of the match.
55+
- Practice Mode causes the robot to cycle through the same transitions as an FRC match after the Enable button is pressed (timing for practice mode can be found on the setup tab).
56+
- :doc:`Test Mode </docs/software/basic-programming/using-test-mode>` is an additional mode where test code that doesn't run in a regular match can be tested.
57+
5258
2. Enable/Disable - These controls enable and disable the robot. See also `Driver Station Key Shortcuts`_
5359
3. Elapsed Time - Indicates the amount of time the robot has been enabled
5460
4. PC Battery - Indicates current state of DS PC battery and whether the PC is plugged in

source/docs/software/vscode-overview/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ VS Code Overview
1212
viewing-console-output
1313
debugging-robot-program
1414
importing-gradle-project
15-
using-test-mode

source/docs/software/vscode-overview/using-test-mode.rst

Lines changed: 0 additions & 71 deletions
This file was deleted.

source/redirects.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,3 +247,4 @@
247247
"docs/yearly-overview/2020-Game-Data.rst" "docs/yearly-overview/index.rst"
248248
"docs/software/labview/creating-robot-programs/creating-building-and-loading-your-benchtop-test-program.rst" "docs/zero-to-robot/step-4/creating-benchtop-test-program-labview.rst"
249249
"docs/software/labview/resources/talon-srx-can.rst" "docs/software/labview/resources/index.rst"
250+
"docs/software/vscode-overview/using-test-mode.rst" "docs/software/basic-programming/using-test-mode.rst"

0 commit comments

Comments
 (0)