Skip to content
This repository was archived by the owner on Jul 16, 2024. It is now read-only.

Commit 190a02d

Browse files
authored
Add debug instructions (#264)
* Add debug instructions * Add build instructions
1 parent e87fc77 commit 190a02d

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

source/docs/contributing/photonvision/build-instructions.rst

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,59 @@ After adding the generated vendordep to your project, add the following to your
137137
repositories {
138138
mavenLocal()
139139
}
140+
141+
142+
Debugging a local PhotonVision build
143+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
144+
145+
One way is by running the program using gradle with the :code:`--debug-jvm` flag. Run the program with :code:`./gradlew run --debug-jvm`, and attach to it with VSCode by adding the following to launch.json. Note args can be passed with :code:`--args="foobar"`.
146+
147+
.. code-block::
148+
149+
{
150+
// Use IntelliSense to learn about possible attributes.
151+
// Hover to view descriptions of existing attributes.
152+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
153+
"version": "0.2.0",
154+
"configurations": [
155+
{
156+
"type": "java",
157+
"name": "Attach to Remote Program",
158+
"request": "attach",
159+
"hostName": "localhost",
160+
"port": "5005",
161+
"projectName": "photon-core",
162+
}
163+
]
164+
}
165+
166+
PhotonVision can also be run using the gradle tasks plugin with :code:`"args": "--debug-jvm"` added to launch.json.
167+
168+
Running examples
169+
~~~~~~~~~~~~~~~~
170+
171+
You can run one of the many built in examples straight from the command line, too! They contain a fully featured robot project, and some include simulation support. The projects can be found inside the photonlib-java-examples and photonlib-cpp-examples subdirectories, respectively. The projects currently available include:
172+
173+
- photonlib-java-examples:
174+
- aimandrange:simulateJava
175+
- aimattarget:simulateJava
176+
- getinrange:simulateJava
177+
- simaimandrange:simulateJava
178+
- simposeest:simulateJava
179+
- photonlib-cpp-examples:
180+
- aimandrange:simulateNative
181+
- getinrange:simulateNative
182+
183+
To run them, use the commands listed below. Photonlib must first be published to your local maven repository, then the copyPhotonlib task will copy the generated vendordep json file into each example. After that, the simulateJava/simulateNative task can be used like a normal robot project. Robot simulation with attached debugger is technically possible by using simulateExternalJava and modifying the launch script it exports, though unsupported.
184+
185+
.. code-block::
186+
187+
~/photonvision$ ./gradlew publishToMavenLocal
188+
189+
~/photonvision$ cd photonlib-java-examples
190+
~/photonvision/photonlib-java-examples$ ./gradlew copyPhotonlib
191+
~/photonvision/photonlib-java-examples$ ./gradlew <example-name>:simulateJava
192+
193+
~/photonvision$ cd photonlib-cpp-examples
194+
~/photonvision/photonlib-cpp-examples$ ./gradlew copyPhotonlib
195+
~/photonvision/photonlib-cpp-examples$ ./gradlew <example-name>:simulateNative

0 commit comments

Comments
 (0)