You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
.. note:: The code snippets shown below are part of the HatchbotTraditional example project (`Java <https://github.com/wpilibsuite/allwpilib/tree/main/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/hatchbottraditional>`__, `C++ <https://github.com/wpilibsuite/allwpilib/tree/main/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional>`__):
117
+
.. note:: The code snippets shown below are part of the HatchbotTraditional example project (`Java <https://github.com/wpilibsuite/allwpilib/tree/main/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/hatchbottraditional>`__, `C++ <https://github.com/wpilibsuite/allwpilib/tree/main/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional>`__, `Python <https://github.com/robotpy/examples/tree/main/HatchbotTraditional>`__):
80
118
81
119
Creating the SendableChooser Object
82
120
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -89,23 +127,30 @@ In ``RobotContainer``, create a variable to hold a reference to a ``SendableChoo
In ``Robot.java``, this will run the scheduler every driver station update period (about every 20ms) and cause the selected autonomous command to run.
264
+
In ``Robot.java``, this will run the scheduler every driver station update period (about every 20ms) and cause the selected autonomous command to run. In Python the scheduler runs automatically when ``TimedCommandRobot`` is used.
186
265
187
266
.. note:: Running the scheduler can occur in the ``autonomousPeriodic()`` function or ``robotPeriodic()``, both will function similarly in autonomous mode.
188
267
@@ -231,6 +310,15 @@ In ``Robot.java``, when the teleop period begins, the autonomous command will be
You can display the status of the Scheduler (the code that schedules your commands to run). This is easily done by adding a single line to the ``RobotInit`` method in your RobotProgram as shown here. In this example the Scheduler instance is written using the ``putData`` method to SmartDashboard. This line of code produces the display in the previous image.
35
42
@@ -43,13 +50,19 @@ Displaying Subsystem Status
43
50
44
51
.. tab-set-code::
45
52
46
-
.. code-block:: java
53
+
.. code-block:: java
54
+
55
+
SmartDashboard.putData(exampleSubsystem);
56
+
57
+
.. code-block:: c++
47
58
48
-
SmartDashboard.putData(exampleSubsystem);
59
+
frc::SmartDashboard::PutData(&exampleSubsystem);
49
60
50
-
.. code-block:: c++
61
+
.. code-block:: python
51
62
52
-
frc::SmartDashboard::PutData(&exampleSubsystem);
63
+
from wpilib import SmartDashboard
64
+
65
+
SmartDashboard.putData(exampleSubsystem)
53
66
54
67
In this example we are writing the command instance, ``exampleSubsystem`` and instance of the ``ExampleSubsystem`` class to the SmartDashboard. This causes the display shown in the previous image. The text field will either contain a few dashes, ``---`` indicating that no command is current using this subsystem, or the name of the command currently using this subsystem.
55
68
@@ -63,13 +76,19 @@ Activating Commands with a Button
This is the code required to create a button for the command on SmartDashboard. Pressing the button will schedule the command. While the command is running, the button label changes from ``start`` to ``cancel`` and pressing the button will cancel the command.
0 commit comments