Skip to content

Commit 296dcc4

Browse files
committed
Delete debugging instructions for now
We're not completely sure that there will be a reliable network connection to the robots yet (or even that we're shipping WiFi), so remove this for now. We would very much like to restore this though!
1 parent ff532b3 commit 296dcc4

File tree

1 file changed

+0
-145
lines changed

1 file changed

+0
-145
lines changed

programming/editors/vscode.md

Lines changed: 0 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -35,148 +35,3 @@ you'll need to make the library available within the Python environment that you
3535
3. Run `pip install sr.robot3`.
3636

3737
[code-completion]: https://en.wikipedia.org/wiki/Autocomplete#In_source_code_editors
38-
39-
## Interactive Debugging
40-
41-
<div class="info">
42-
This section refers to a feature which is only available within the simulator.
43-
<!--
44-
Pedantic note: yes, you can actually make this work on the kits too (very easily
45-
it turns out), however the steps to set this up on the kits are a bit different
46-
so for now we just document the simulator version.
47-
-->
48-
</div>
49-
50-
Interactive debugging is a great way to inspect what your code is doing whilst
51-
the simulator is actually running. It will allow you to inspect the values of
52-
variables throughout the code and even re-run sections to understand how they
53-
interact.
54-
55-
There are two initial setup steps (installing `debugpy` and configuring VSCode)
56-
and then two steps each time you want to debug your code.
57-
58-
### Install `debugpy`
59-
60-
In order for VSCode to be able to debug your code as it runs in the simulator
61-
you will need to install the [`debugpy`][debugpy] Python package. You will use
62-
this package in your Python code to signal that it is ready for VSCode to attach
63-
to it, so it needs to be installed into the same Python environment that Webots
64-
is configured to use.
65-
66-
``` shell
67-
python -m pip install debugpy
68-
```
69-
70-
You may need to use the full path to your `python`, or on some platforms it may
71-
be called `python3`.
72-
73-
On Windows, if specifying a full path to `python.exe`, you should use the basic
74-
Command Prompt (and not the terminal within VSCode or PowerShell).
75-
76-
### Configure VSCode
77-
78-
Next, we are going to create a [debug configuration][debug-config] so that
79-
VSCode knows what you want it to debug.
80-
81-
<!--
82-
If the user hasn't activated their Python extension in the current editor
83-
session then it won't yet have registered itself. Additionally if the currently
84-
focused file is not a Python file then they will be asked for the environment
85-
they want to debug. Avoid both of these by instructing the user to open their
86-
`robot.py` before attempting to configure debugging.
87-
-->
88-
89-
1. Open the workspace containing your code.
90-
2. Open your `robot.py` file.
91-
3. Select the Run view in the sidebar (or press
92-
<kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>D</kbd> /
93-
<kbd>⌘</kbd> + <kbd>⇧</kbd> + <kbd>D</kbd> on macOS)
94-
4. Click "create a launch.json file".
95-
5. In the menu which appears, if you are asked to select an environment select **Python**.
96-
6. When asked for a Debug Configuration, select **Remote Attach**.
97-
7. Leave the subsequent values at their defaults (press <kbd>Enter</kbd> twice).
98-
99-
This will create a new file in your project which contains the configuration.
100-
101-
Depending on the location of your robot code is within your project, you may
102-
need to adjust the configuration further.
103-
104-
If your code is in the root of your workspace:
105-
106-
```
107-
.
108-
└── robot.py
109-
```
110-
111-
then no further changes are needed.
112-
113-
If your code is within a folder, perhaps because your workspace includes the
114-
simulator folder and your code is in `zone-0` or `zone-1`:
115-
116-
```
117-
.
118-
├── competition-simulator-<version>
119-
│ ├── ...
120-
│ └─ worlds
121-
│ └── Arena.wbt
122-
└── zone-1
123-
└── robot.py
124-
```
125-
126-
then you will need to modify the `pathMappings` key within the configuration.
127-
The change you'll need to make is to alter the `localRoot` key such that it
128-
accounts for the sub-directory containing the robot code.
129-
130-
In the above example, the change would be to update the line:
131-
132-
``` json
133-
"localRoot": "${workspaceFolder}",
134-
```
135-
136-
to instead be:
137-
138-
``` json
139-
"localRoot": "${workspaceFolder}/zone-1",
140-
```
141-
142-
[debugpy]: https://pypi.org/project/debugpy/
143-
[debug-config]: https://code.visualstudio.com/docs/python/debugging
144-
145-
### Configure your code
146-
147-
To debug a given part of your code, you will need to insert into your code a
148-
statement which will launch the debugger.
149-
150-
At the place in your code that you would like the debugger to start, insert the
151-
following snippet:
152-
153-
``` python
154-
import debugpy
155-
debugpy.listen(5678)
156-
debugpy.wait_for_client()
157-
breakpoint()
158-
```
159-
160-
This code (specifically the `wait_for_client` call) will block until the
161-
debugger is attached.
162-
163-
### Run and debug
164-
165-
You can now launch your code in the simulator exactly as you would normally.
166-
When your code stops running (the simulation will also stop processing) change
167-
to VSCode and select **Run** > **Start Debugging** or press <kbd>F5</kbd>.
168-
169-
VSCode will attach to your code, paused at the `breakpoint()` line.
170-
171-
A full tutorial of [debugging in VSCode][vscode-debugging] is beyond the scope
172-
of this article, though the most common commands (all available from the **Run**
173-
menu) are:
174-
175-
* Step Over (<kbd>F10</kbd>)
176-
* Step Into (<kbd>F11</kbd>)
177-
* Step Out (<kbd>Shift</kbd> + <kbd>F11</kbd>)
178-
* Continue (<kbd>F5</kbd>)
179-
180-
You can also inspect the values of variables in your code by hovering over them.
181-
182-
[vscode-debugging]: https://code.visualstudio.com/docs/editor/debugging

0 commit comments

Comments
 (0)