Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Configure Data Properties

.. image:: images/measuring-bandwidth-usage-5.png

Press ``Ctrl+Q`` to bring up the Properties window. Click on the dropdown next to ``Scale`` and select ``1.0``. Then click on the ``Graph`` tab.
Press :kbd:`Ctrl+Q` to bring up the Properties window. Click on the dropdown next to ``Scale`` and select ``1.0``. Then click on the ``Graph`` tab.

Configure Graph Properties
^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ You should see a screen similar to this

.. image:: images/image6.png

.. note:: The keyboard shortcut ``ctrl`` + ``~`` can be used to open a terminal in Visual Studio Code.
.. note:: The keyboard shortcut :kbd:`Ctrl+~` can be used to open a terminal in Visual Studio Code.

Now you'll want to open a PowerShell window and navigate to your project directory. An excellent tutorial on PowerShell can be found `here <https://programminghistorian.org/en/lessons/intro-to-powershell>`__. Please consult your search engine on how to open a terminal on alternative operating systems.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ WPILib Example Projects

.. warning:: While every attempt is made to keep WPILib examples functional, they are *not* intended to be used "as-is." At the very least, robot-specific constants will need to be changed for the code to work on a user robot. Many empirical constants have their values "faked" for demonstration purposes. Users are strongly encouraged to write their own code (from scratch or from an existing template) rather than copy example code.

WPILib example projects demonstrate a large number of library features and use patterns. Projects range from simple demonstrations of a single functionality to complete, competition-capable robot programs. All of these examples are available in VS Code by entering Control+Shift+P, then selecting `WPILib: Create a new project` and choosing example.
WPILib example projects demonstrate a large number of library features and use patterns. Projects range from simple demonstrations of a single functionality to complete, competition-capable robot programs. All of these examples are available in VS Code by entering :kbd:`Ctrl+Shift+P`, then selecting `WPILib: Create a new project` and choosing example.

.. image:: /docs/software/vscode-overview/images/creating-robot-program/create-new-project.png

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Tank Drive Tutorial

3. In the Project Explorer window, open up the ``Robot Main.vi``.

4. Push Ctrl + E to see the block diagram. It should look like the following image:
4. Push :kbd:`Ctrl+E` to see the block diagram. It should look like the following image:

.. image:: images/tank-drive-tutorial/block-diagram.png

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ Locating Loop 2 - Camera IP

.. image:: images/using-the-axis-camera-at-single-network-events/locating-loop-2-camera-ip.png

Double click on ``Dashboard Main.vi`` in the project explorer to open it and press Ctrl+e to see the block diagram. Scroll down to the loop with the comment that says Loop 2 and locate the "Camera IP" input.
Double click on ``Dashboard Main.vi`` in the project explorer to open it and press :kbd:`Ctrl+E` to see the block diagram. Scroll down to the loop with the comment that says Loop 2 and locate the "Camera IP" input.

Editing the Camera IP
^^^^^^^^^^^^^^^^^^^^^

.. image:: images/using-the-axis-camera-at-single-network-events/editing-the-camera-ip.png

Delete the Camera IP node, right click on the broken wire and click Create Constant (connect the constant to the wire if necessary). In the box, enter the mDNS name of your camera with a ``.local`` suffix (e.g. ``axis-cameraTEAM.local`` where ``TEAM`` is replaced with your team number). The example above shows a sample name for team 9999. Then click File->Save or Ctrl+S to save the VI.
Delete the Camera IP node, right click on the broken wire and click Create Constant (connect the constant to the wire if necessary). In the box, enter the mDNS name of your camera with a ``.local`` suffix (e.g. ``axis-cameraTEAM.local`` where ``TEAM`` is replaced with your team number). The example above shows a sample name for team 9999. Then click File->Save or :kbd:`Ctrl+S` to save the VI.

.. note:: You may also wish to make a minor modification to the Front Panel to verify that you are running the right dashboard later.

Expand Down Expand Up @@ -65,4 +65,4 @@ Modifying LabVIEW Robot Code

.. image:: images/using-the-axis-camera-at-single-network-events/modifying-labview-robot-code.png

In the Project Explorer, locate ``Vision Processing.VI`` and double click to open it. Then press Ctrl+e to open the Block Diagram. Locate the string ``axis-camera.local`` near the left of the image and replace with ``axis-cameraTEAM.local``. Also make sure the constant is set to ``False`` to use the Axis camera instead of USB.
In the Project Explorer, locate ``Vision Processing.VI`` and double click to open it. Then press :kbd:`Ctrl+E` to open the Block Diagram. Locate the string ``axis-camera.local`` near the left of the image and replace with ``axis-cameraTEAM.local``. Also make sure the constant is set to ``False`` to use the Axis camera instead of USB.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Adding an Offline-Installed Library

.. image:: images/3rd-party-libraries/adding-offline-library.png

To add a vendor library that has been installed by an offline installer, press **Ctrl+Shift+P** and type WPILib or click on the WPILib icon in the top right to open the WPILib Command Palette and begin typing **Manage Vendor Libraries**, then select it from the menu. Select the option to **Install new libraries (offline)**.
To add a vendor library that has been installed by an offline installer, press :kbd:`Ctrl+Shift+P` and type WPILib or click on the WPILib icon in the top right to open the WPILib Command Palette and begin typing **Manage Vendor Libraries**, then select it from the menu. Select the option to **Install new libraries (offline)**.

.. image:: images/3rd-party-libraries/library-installer-steptwo.png

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ If desired, users can omit a base class entirely and simply write their program
Creating a New WPILib Project
-----------------------------

Once we've decided on a base class, we can create our new robot project. Bring up the Visual Studio Code command palette with :kbd:"Control+Shift+P":
Once we've decided on a base class, we can create our new robot project. Bring up the Visual Studio Code command palette with :kbd:`Ctrl+Shift+P`:

|Command Palette|

Expand Down Expand Up @@ -177,7 +177,7 @@ An example after all options are selected is shown below.
Opening The New Project
-----------------------

After successfully creating your project, VS Code will give the option of opening the project as shown below. We can choose to do that now or later by typing :kbd:`Ctrl-K` then :kbd:`Ctrl-O` (or just :kbd:`Command+O` on macOS) and select the folder where We saved our project.
After successfully creating your project, VS Code will give the option of opening the project as shown below. We can choose to do that now or later by typing :kbd:`Ctrl+K` then :kbd:`Ctrl+O` (or just :kbd:`Command+O` on macOS) and select the folder where We saved our project.

Once opened we will see the project hierarchy on the left. Double clicking on the file will open that file in the editor.

Expand Down
79 changes: 31 additions & 48 deletions source/docs/software/vscode-overview/debugging-robot-program.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,70 +7,53 @@ A debugger is a tool used to control program flow and monitor variables in order

.. note:: For beginning users who need to debug their programs but do not know/have time to learn how to use a debugger, it is often possible to debug a program simply by printing the relevant program state to the console. However, it is strongly recommended that students eventually learn to use a debugger.

Breakpoints
-----------

A "breakpoint" is a line of code at which the debugger will stop the program execution so that the user can examine the program state. This is extremely useful while debugging, as it allows the user to pause the program at specific points in problematic code to determine where exactly the program is deviating from the expected behavior.

Setting a Breakpoint
~~~~~~~~~~~~~~~~~~~~

|Setting a Breakpoint|

Double-click in the left margin of the source code window to set a breakpoint in your user program: A small red circle indicates the breakpoint has been set on the corresponding line.

Viewing Program State
~~~~~~~~~~~~~~~~~~~~~

|Debug Tab|
Running the Debugger
--------------------

When the program is stopped at a breakpoint, various pieces of program state can be viewed from the debug tab. The Debug tab is accessed by clicking on the debug icon on the far left pane. Within the debug tab, the program state can be viewed from an assortment of "panes."
.. image:: images/debugging-robot-program/start-debugging.png
:alt: Shows running the debugger via the Command Palette.

The Variables Pane
^^^^^^^^^^^^^^^^^^
Press :kbd:`Ctrl+Shift+P` and type ``WPILib`` or click on the :guilabel:`WPILib Menu Item` to open the Command palette with WPILib pre-populated. Type Debug and select the Debug Robot Code menu item to start debugging. The code will download to the roboRIO and begin debugging.

|Variables Pane|
Breakpoints
-----------

The Variables view shows the current values of variables. To see a variable that is not displayed, select the “Watch” pane and enter the variable name. This will show the variable’s value if it’s in-scope. Clicking on the arrows next to a variable name will expand the tree and show its `fields <https://en.wikipedia.org/wiki/Field_(computer_science)>`__.
A "breakpoint" is a line of code at which the debugger will pause the program execution so that the user can examine the program state. This is extremely useful while debugging, as it allows the user to pause the program at specific points in problematic code to determine where exactly the program is deviating from the expected behavior.

Watch Pane
^^^^^^^^^^
The debugger will automatically pause at the first breakpoint it encounters.

|Watch Pane|
Setting a Breakpoint
^^^^^^^^^^^^^^^^^^^^

The Watch Pane can be used to monitor specific variables or expressions while debugging. To add an expression, right-click and select Add Expression.
.. image:: images/debugging-robot-program/setting-a-breakpoint.png
:alt: Shows where to place the cursor to create a breakpoint.

Call Stack
^^^^^^^^^^
Click in the left margin of the source code window (to the left of the line number) to set a breakpoint in your user program: A small red circle indicates the breakpoint has been set on the corresponding line.

|Call Stack|
Debugging with Print Statements
-------------------------------

The Call Stack pane is used to display the current `call stack <https://en.wikipedia.org/wiki/Call_stack>`__ of the running program. This can be used to monitor the current call hierarchy of the program while debugging.
Another way to debug your program is to use print statements in your code and view them using the RioLog in Visual Studio Code or the Driver Station. Print statements should be added with care as they are not very efficient especially when used in high quantities. They should be removed for competition as they can cause loop overruns.

Breakpoint Pane
^^^^^^^^^^^^^^^
.. tabs::

|Breakpoint Pane|
.. code-tab:: java

The Breakpoint Pane displays all of the current breakpoints. To temporarily disable a breakpoint without permanently removing it, click the corresponding checkbox.
System.out.print("example");

Running the Debugger
--------------------
.. code-tab:: c++

|Start Debugging|
wpi::outs() << "example\n";

Press Ctrl+Shift+P and type WPILib or click on the WPILib Menu item to open the Command palette with WPILib pre-populated. Type Debug and select the Debug Robot Code menu item to start debugging. The code will download to the roboRIO and begin debugging.
Debugging with Network Tables
-----------------------------

The debugger will automatically pause at the first breakpoint it encounters. The user can then tell the debugger when to proceed to the next breakpoint.
:doc:`Network Tables </docs/software/networktables/networktables-intro>` can be used to share robot information with your debugging computer. Network Tables can be viewed with your favorite Dashboard or OutlineViewer. One advantage of Network Tables is that tools like :doc:`Shuffleboard </docs/software/wpilib-tools/shuffleboard/getting-started/shuffleboard-tour>` can be used to graphically analyze the data. These same tools can then be used with same data to later provide an operator interface for your drivers.

Debugging with Console
----------------------
Another way to debug your program is to use System.out.println statements in your code and receive them using the RioLog in Visual Studio Code.
Learn More
----------

.. |Setting a Breakpoint| image:: images/debugging-robot-program/setting-a-breakpoint.png
.. |Debug Tab| image:: images/debugging-robot-program/debug-tab.png
.. |Variables Pane| image:: images/debugging-robot-program/variables-pane.png
.. |Watch Pane| image:: images/debugging-robot-program/watch-pane.png
.. |Call Stack| image:: images/debugging-robot-program/call-stack.png
.. |Breakpoint Pane| image:: images/debugging-robot-program/breakpoint-pane.png
.. |Start Debugging| image:: images/debugging-robot-program/start-debugging.png
- To learn more about debugging with VS Code see this `link <https://code.visualstudio.com/docs/editor/debugging>`__.
- Some of the features mentioned in this VS Code `article <https://code.visualstudio.com/docs/editor/editingevolved>`__ will help you understand and diagnose problems with your code. The Quick Fix (yellow light bulb) feature can be very helpful with a variety of problems including what to import.
- One of the best ways to prevent having to debug so many issues is to do Unit Testing.
- Verifying that your robot works in :doc:`Simulation </docs/software/wpilib-tools/robot-simulation/introduction>` is also a great way to prevent having to do complex debugging on the actual robot.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Launching the Import Wizard
|Launching Import Wizard|


Press Ctrl+Shift+P and type "WPILib" or click the WPILib icon to locate the WPILib commands. Begin typing "Import a WPILib Eclipse project" and select it from the dropdown.
Press :kbd:`Ctrl+Shift+P` and type "WPILib" or click the WPILib icon to locate the WPILib commands. Begin typing "Import a WPILib Eclipse project" and select it from the dropdown.

|Eclipse Project Importer|

Expand All @@ -23,7 +23,7 @@ You'll be presented with the WPILib Eclipse Project Upgrade window. This is simi

Click "Upgrade Project" to begin the upgrade.

The eclipse project will be upgraded and copied into the new project directory. You can then either open the new project immediately (the pop-up shown below should appear in the bottom right) or open it later using the Ctrl-O (or Command-O for macOS) shortcut.
The eclipse project will be upgraded and copied into the new project directory. You can then either open the new project immediately (the pop-up shown below should appear in the bottom right) or open it later using the :kbd:`Ctrl+O` (or Command-O for macOS) shortcut.

|Opening Project|

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Launching the Import Wizard

When you open a previous year's project, you will be prompted to import that project. Click :guilabel:`yes`.

Alternately, you can chose to import it from the menu. Press Ctrl+Shift+P and type "WPILib" or click the WPILib icon to locate the WPILib commands. Begin typing "Import a WPILib 2020 Gradle project" and select it from the dropdown as shown below.
Alternately, you can chose to import it from the menu. Press :kbd:`Ctrl+Shift+P` and type "WPILib" or click the WPILib icon to locate the WPILib commands. Begin typing "Import a WPILib 2020 Gradle project" and select it from the dropdown as shown below.

.. image:: images/importing-previous-project/ImportGradleMenu.png

Expand All @@ -29,7 +29,7 @@ You'll be presented with the WPILib Project Importer window. This is similar to

Click :guilabel:`Import Project` to begin the upgrade.

The gradle project will be upgraded and copied into the new project directory. You can then either open the new project immediately (the pop-up shown below should appear in the bottom right) or open it later using the Ctrl-O (or Command-O for macOS) shortcut.
The gradle project will be upgraded and copied into the new project directory. You can then either open the new project immediately (the pop-up shown below should appear in the bottom right) or open it later using the :kbd:`Ctrl+O` (or :kbd:`Command+O` for macOS) shortcut.

.. image:: images/importing-eclipse-project/opening-project.png

Expand Down
2 changes: 1 addition & 1 deletion source/docs/software/vscode-overview/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ VS Code Overview
vscode-basics
wpilib-commands-vscode
creating-robot-program
3rd-party-libraries
deploying-robot-code
viewing-console-output
debugging-robot-program
3rd-party-libraries
importing-eclipse-project
importing-gradle-project
using-test-mode
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Opening the RioLog View

|Opening Riolog View|

By default, the RioLog view will open automatically at the end of each roboRIO deploy. To launch the RioLog view manually, press Ctrl+Shift+P to open the command palette and start typing "RioLog", then select the WPILib: Start RioLog option.
By default, the RioLog view will open automatically at the end of each roboRIO deploy. To launch the RioLog view manually, press :kbd:`Ctrl+Shift+P` to open the command palette and start typing "RioLog", then select the WPILib: Start RioLog option.

Riolog Window
~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion source/docs/software/vscode-overview/vscode-basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The most important link to take a look at is probably the basic User Interface d
Command Palette
---------------

The Command Palette can be used to access or run almost any function or feature in Visual Studio Code (including those from the WPILib extension). The Command Palette can be accessed from the View menu or by pressing Ctrl+Shift+P (Cmd+Shift+P on macOS). Typing text into the window will dynamically narrow the search to relevant commands and show them in the dropdown.
The Command Palette can be used to access or run almost any function or feature in Visual Studio Code (including those from the WPILib extension). The Command Palette can be accessed from the View menu or by pressing :kbd:`Ctrl+Shift+P` (:kbd:`Cmd+Shift+P` on macOS). Typing text into the window will dynamically narrow the search to relevant commands and show them in the dropdown.

In the following example "wpilib" is typed into the search box after activating the Command Palette, and it narrows the list to functions containing WPILib.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ To access these commands, press Ctrl+Shift+P to open the Command Palette, then b
- **WPILib: Manage Vendor Libraries** - Install/update 3rd party libraries
- **WPILib: Open API Documentation** - Opens either the WPILib Javadocs or C++ Doxygen documentation
- **WPILib: Open Project Information** - Opens a widget with project information (Project version, extension version, etc.)
- **WPILib: Open WPILib Command Palette** - This command is used to open a WPILib Command Palette (equivalent of hitting Ctrl+Shift+P and typing WPILib)
- **WPILib: Open WPILib Command Palette** - This command is used to open a WPILib Command Palette (equivalent of hitting :kbd:`Ctrl+Shift+P` and typing ``WPILib``)
- **WPILib: Open WPILib Help** - This opens a simple page which links to the WPILib documentation (this site)
- **WPILib: Reset Ask for WPILib Updates Flag** - This will clear the flag on the current project, allowing you to re-prompt to update a project to the latest WPILib version if you previously chose to not update.
- **WPILib: Run a command in Gradle** - This lets you run an arbitrary command in the GradleRIO command environment
Expand Down
Loading