VS Code Remote Debugging
When connected to the robot’s WiFi hotspot, it is possible to attach VS Code’s debugger to the robot by performing the following steps:
- Ensure the Python extension is installed.
- Open the Run and Debug panel.
- Click the cog icon at the top of the panel.
- Paste the following configuration:
{ "version": "0.2.0", "configurations": [ { "name": "Attach to Robot", "type": "python", "request": "attach", "connect": { "host": "robot.lan", "port": 5678 }, "pathMappings": [ { "localRoot": "${workspaceFolder}", "remoteRoot": "." } ], "justMyCode": true } ] } - Add the following snippet to the top of your code:
import debugpy debugpy.listen(("0.0.0.0", 5678))
If you would like for your code to not run until the debugger is attached, you can also add the following:
print("Waiting for debugger...")
debugpy.wait_for_client()
- In order to debug, you can now either click the green play button at the top of the Run and Debug panel or press F5.
For more information on debugging with Visual Studio Code, please visit the VS Code documentation