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

Commit f65a587

Browse files
authored
RLI updates (#252)
1 parent 9de6219 commit f65a587

File tree

6 files changed

+42
-134
lines changed

6 files changed

+42
-134
lines changed

source/docs/examples/aimandrange.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,23 @@ Now that you know how to both aim and get in range of the target, it is time to
1818

1919
.. tab-item:: Java
2020

21-
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/661f8b2c0495474015f6ea9a89d65f9788436a05/photonlib-java-examples/src/main/java/org/photonlib/examples/aimandrange/Robot.java
21+
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/ebef19af3d926cf87292177c9a16d01b71219306/photonlib-java-examples/aimandrange/src/main/java/frc/robot/Robot.java
2222
:language: java
2323
:lines: 42-111
2424
:linenos:
2525
:lineno-start: 42
2626

2727
.. tab-item:: C++ (Header)
2828

29-
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/661f8b2c0495474015f6ea9a89d65f9788436a05/photonlib-cpp-examples/src/main/cpp/examples/aimandrange/include/Robot.h
29+
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/ebef19af3d926cf87292177c9a16d01b71219306/photonlib-cpp-examples/aimandrange/src/main/include/Robot.h
3030
:language: cpp
3131
:lines: 27-71
3232
:linenos:
3333
:lineno-start: 27
3434

3535
.. tab-item:: C++ (Source)
3636

37-
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/661f8b2c0495474015f6ea9a89d65f9788436a05/photonlib-cpp-examples/src/main/cpp/examples/aimandrange/cpp/Robot.cpp
37+
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/ebef19af3d926cf87292177c9a16d01b71219306/photonlib-cpp-examples/aimandrange/src/main/cpp/Robot.cpp
3838
:language: cpp
3939
:lines: 25-67
4040
:linenos:

source/docs/examples/aimingatatarget.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,23 @@ In this example, while the operator holds a button down, the robot will turn tow
2323

2424
.. tab-item:: Java
2525

26-
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/661f8b2c0495474015f6ea9a89d65f9788436a05/photonlib-java-examples/src/main/java/org/photonlib/examples/aimattarget/Robot.java
26+
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/ebef19af3d926cf87292177c9a16d01b71219306/photonlib-java-examples/aimattarget/src/main/java/frc/robot/Robot.java
2727
:language: java
2828
:lines: 41-98
2929
:linenos:
3030
:lineno-start: 41
3131

3232
.. tab-item:: C++ (Header)
3333

34-
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/661f8b2c0495474015f6ea9a89d65f9788436a05/photonlib-cpp-examples/src/main/cpp/examples/aimattarget/include/Robot.h
34+
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/ebef19af3d926cf87292177c9a16d01b71219306/photonlib-cpp-examples/aimattarget/src/main/include/Robot.h
3535
:language: c++
3636
:lines: 27-53
3737
:linenos:
3838
:lineno-start: 27
3939

4040
.. tab-item:: C++ (Source)
4141

42-
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/661f8b2c0495474015f6ea9a89d65f9788436a05/photonlib-cpp-examples/src/main/cpp/examples/aimattarget/cpp/Robot.cpp
42+
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/ebef19af3d926cf87292177c9a16d01b71219306/photonlib-cpp-examples/aimattarget/src/main/cpp/Robot.cpp
4343
:language: c++
4444
:lines: 25-52
4545
:linenos:

source/docs/examples/gettinginrangeofthetarget.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,23 @@ This example uses P term of the PID loop and PhotonLib and the distance function
2929

3030
.. tab-item:: Java
3131

32-
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/661f8b2c0495474015f6ea9a89d65f9788436a05/photonlib-java-examples/src/main/java/org/photonlib/examples/getinrange/Robot.java
32+
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/ebef19af3d926cf87292177c9a16d01b71219306/photonlib-java-examples/getinrange/src/main/java/frc/robot/Robot.java
3333
:language: java
3434
:lines: 42-107
3535
:linenos:
3636
:lineno-start: 42
3737

3838
.. tab-item:: C++ (Header)
3939

40-
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/661f8b2c0495474015f6ea9a89d65f9788436a05/photonlib-cpp-examples/src/main/cpp/examples/getinrange/include/Robot.h
40+
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/ebef19af3d926cf87292177c9a16d01b71219306/photonlib-cpp-examples/getinrange/src/main/include/Robot.h
4141
:language: c++
4242
:lines: 27-67
4343
:linenos:
4444
:lineno-start: 27
4545

4646
.. tab-item:: C++ (Source)
4747

48-
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/661f8b2c0495474015f6ea9a89d65f9788436a05/photonlib-cpp-examples/src/main/cpp/examples/getinrange/cpp/Robot.cpp
48+
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/ebef19af3d926cf87292177c9a16d01b71219306/photonlib-cpp-examples/getinrange/src/main/cpp/Robot.cpp
4949
:language: c++
5050
:lines: 25-58
5151
:linenos:

source/docs/examples/simaimandrange.rst

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,12 @@ First, in the main :code:`Robot` source file, we add support to periodically upd
3030

3131
.. tab-set-code::
3232

33-
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/661f8b2c0495474015f6ea9a89d65f9788436a05/photonlib-java-examples/src/main/java/org/photonlib/examples/simaimandrange/Robot.java
33+
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/ebef19af3d926cf87292177c9a16d01b71219306/photonlib-java-examples/simaimandrange/src/main/java/frc/robot/Robot.java
3434
:language: java
3535
:lines: 118-128
3636
:linenos:
3737
:lineno-start: 118
3838

39-
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/661f8b2c0495474015f6ea9a89d65f9788436a05/photonlib-cpp-examples/src/main/cpp/examples/simaimandrange/cpp/Robot.cpp
40-
:language: c++
41-
:lines: 72
42-
:linenos:
43-
:lineno-start: 72
44-
4539
Then, we add in the implementation of our new `DrivetrainSim` class. Please reference the `WPILib documentation on physics simulation <https://docs.wpilib.org/en/stable/docs/software/wpilib-tools/robot-simulation/physics-sim.html>`_.
4640

4741
Simulated Vision support is added with the following steps:
@@ -53,50 +47,32 @@ First, we create a new :code:`SimVisionSystem` to represent our camera and copro
5347

5448
.. tab-set-code::
5549

56-
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/661f8b2c0495474015f6ea9a89d65f9788436a05/photonlib-java-examples/src/main/java/org/photonlib/examples/simaimandrange/sim/DrivetrainSim.java
50+
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/ebef19af3d926cf87292177c9a16d01b71219306/photonlib-java-examples/simaimandrange/src/main/java/frc/robot/sim/DrivetrainSim.java
5751
:language: java
58-
:lines: 72-93
52+
:lines: 73-93
5953
:linenos:
6054
:lineno-start: 72
6155

62-
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/661f8b2c0495474015f6ea9a89d65f9788436a05/photonlib-cpp-examples/src/main/cpp/examples/simaimandrange/include/DrivetrainSim.h
63-
:language: c++
64-
:lines: 78-92
65-
:linenos:
66-
:lineno-start: 78
67-
68-
6956
Next, we create objects to represent the physical location and size of the vision targets we are calibrated to detect. This example models the down-field high goal vision target from the 2020 and 2021 games.
7057

7158
.. tab-set-code::
7259

73-
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/661f8b2c0495474015f6ea9a89d65f9788436a05/photonlib-java-examples/src/main/java/org/photonlib/examples/simaimandrange/sim/DrivetrainSim.java
60+
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/ebef19af3d926cf87292177c9a16d01b71219306/photonlib-java-examples/simaimandrange/src/main/java/frc/robot/sim/DrivetrainSim.java
7461
:language: java
75-
:lines: 95-108
62+
:lines: 95-111
7663
:linenos:
7764
:lineno-start: 95
7865

79-
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/661f8b2c0495474015f6ea9a89d65f9788436a05/photonlib-cpp-examples/src/main/cpp/examples/simaimandrange/include/DrivetrainSim.h
80-
:language: c++
81-
:lines: 94-109
82-
:linenos:
83-
:lineno-start: 94
84-
8566
Finally, we add our target to the simulated vision system.
8667

8768
.. tab-set-code::
8869

89-
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/661f8b2c0495474015f6ea9a89d65f9788436a05/photonlib-java-examples/src/main/java/org/photonlib/examples/simaimandrange/sim/DrivetrainSim.java
70+
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/ebef19af3d926cf87292177c9a16d01b71219306/photonlib-java-examples/simaimandrange/src/main/java/frc/robot/sim/DrivetrainSim.java
9071
:language: java
91-
:lines: 113-114
72+
:lines: 116-117
9273
:linenos:
9374
:lineno-start: 113
9475

95-
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/661f8b2c0495474015f6ea9a89d65f9788436a05/photonlib-cpp-examples/src/main/cpp/examples/simaimandrange/include/DrivetrainSim.h
96-
:language: c++
97-
:lines: 45-49
98-
:linenos:
99-
:lineno-start: 45
10076

10177
If you have additional targets you want to detect, you can add them in the same way as the first one.
10278

@@ -108,16 +84,11 @@ Once we have all the properties of our simulated vision system defined, the work
10884

10985
.. tab-set-code::
11086

111-
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/661f8b2c0495474015f6ea9a89d65f9788436a05/photonlib-java-examples/src/main/java/org/photonlib/examples/simaimandrange/sim/DrivetrainSim.java
87+
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/ebef19af3d926cf87292177c9a16d01b71219306/photonlib-java-examples/simaimandrange/src/main/java/frc/robot/sim/DrivetrainSim.java
11288
:language: java
113-
:lines: 122-140
89+
:lines: 124-142
11490
:linenos:
11591
:lineno-start: 122
11692

117-
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/661f8b2c0495474015f6ea9a89d65f9788436a05/photonlib-cpp-examples/src/main/cpp/examples/simaimandrange/cpp/sim/DrivetrainSim.cpp
118-
:language: c++
119-
:lines: 31-50
120-
:linenos:
121-
:lineno-start: 31
12293

12394
The rest is done behind the scenes.

source/docs/examples/simposeest.rst

Lines changed: 18 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -40,36 +40,25 @@ For both simulation and on-robot code, we create objects to represent the physic
4040
.. tab-item:: Java
4141
:sync: java
4242

43-
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/661f8b2c0495474015f6ea9a89d65f9788436a05/photonlib-java-examples/src/main/java/org/photonlib/examples/simposeest/robot/Constants.java
43+
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/80e16ece87c735e30755dea271a56a2ce217b588/photonlib-java-examples/simposeest/src/main/java/frc/robot/Constants.java
4444
:language: java
45-
:lines: 79-101
45+
:lines: 83-106
4646
:linenos:
47-
:lineno-start: 79
47+
:lineno-start: 83
4848

4949

50-
.. tab-item:: C++
51-
:sync: cpp
52-
53-
:code:`//Coming soon!`
54-
5550
To incorporate Photon Vision, we need to create a :code:`PhotonCamera`:
5651

5752
.. tab-set::
5853

5954
.. tab-item:: Java
6055
:sync: java
6156

62-
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/661f8b2c0495474015f6ea9a89d65f9788436a05/photonlib-java-examples/src/main/java/org/photonlib/examples/simposeest/robot/DrivetrainPoseEstimator.java
57+
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/80e16ece87c735e30755dea271a56a2ce217b588/photonlib-java-examples/simposeest/src/main/java/frc/robot/DrivetrainPoseEstimator.java
6358
:language: java
64-
:lines: 49
59+
:lines: 46
6560
:linenos:
66-
:lineno-start: 49
67-
68-
69-
.. tab-item:: C++
70-
:sync: cpp
71-
72-
:code:`//Coming soon!`
61+
:lineno-start: 46
7362

7463
During periodic execution, we read back camera results. If we see a target in the image, we pass the camera-measured pose of the robot to the :code:`DifferentialDrivePoseEstimator`.
7564

@@ -78,17 +67,12 @@ During periodic execution, we read back camera results. If we see a target in th
7867
.. tab-item:: Java
7968
:sync: java
8069

81-
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/661f8b2c0495474015f6ea9a89d65f9788436a05/photonlib-java-examples/src/main/java/org/photonlib/examples/simposeest/robot/DrivetrainPoseEstimator.java
70+
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/80e16ece87c735e30755dea271a56a2ce217b588/photonlib-java-examples/simposeest/src/main/java/frc/robot/DrivetrainPoseEstimator.java
8271
:language: java
83-
:lines: 82-94
72+
:lines: 81-92
8473
:linenos:
85-
:lineno-start: 82
86-
87-
88-
.. tab-item:: C++
89-
:sync: cpp
74+
:lineno-start: 81
9075

91-
:code:`//Coming soon!`
9276

9377
That's it!
9478

@@ -102,36 +86,25 @@ First, we create a new :code:`SimVisionSystem` to represent our camera and copro
10286
.. tab-item:: Java
10387
:sync: java
10488

105-
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/661f8b2c0495474015f6ea9a89d65f9788436a05/photonlib-java-examples/src/main/java/org/photonlib/examples/simposeest/sim/DrivetrainSim.java
89+
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/80e16ece87c735e30755dea271a56a2ce217b588/photonlib-java-examples/simposeest/src/main/java/frc/robot/DrivetrainSim.java
10690
:language: java
107-
:lines: 77-98
91+
:lines: 76-95
10892
:linenos:
109-
:lineno-start: 77
93+
:lineno-start: 76
11094

11195

112-
.. tab-item:: C++
113-
:sync: cpp
114-
115-
:code:`//Coming soon!`
116-
11796
Then, we add our target to the simulated vision system.
11897

11998
.. tab-set::
12099

121100
.. tab-item:: Java
122101
:sync: java
123102

124-
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/661f8b2c0495474015f6ea9a89d65f9788436a05/photonlib-java-examples/src/main/java/org/photonlib/examples/simposeest/sim/DrivetrainSim.java
125-
:language: java
126-
:lines: 100-102
103+
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/80e16ece87c735e30755dea271a56a2ce217b588/photonlib-java-examples/simposeest/src/main/java/frc/robot/DrivetrainSim.java
104+
:lines: 97-99
127105
:linenos:
128-
:lineno-start: 100
129-
106+
:lineno-start: 97
130107

131-
.. tab-item:: C++
132-
:sync: cpp
133-
134-
:code:`//Coming soon!`
135108

136109
If you have additional targets you want to detect, you can add them in the same way as the first one.
137110

@@ -146,17 +119,12 @@ Once we have all the properties of our simulated vision system defined, the rema
146119
.. tab-item:: Java
147120
:sync: java
148121

149-
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/661f8b2c0495474015f6ea9a89d65f9788436a05/photonlib-java-examples/src/main/java/org/photonlib/examples/simposeest/sim/DrivetrainSim.java
122+
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/80e16ece87c735e30755dea271a56a2ce217b588/photonlib-java-examples/simposeest/src/main/java/frc/robot/DrivetrainSim.java
150123
:language: java
151-
:lines: 141-142
124+
:lines: 138-139
152125
:linenos:
153-
:lineno-start: 141
154-
155-
156-
.. tab-item:: C++
157-
:sync: cpp
126+
:lineno-start: 138
158127

159-
:code:`//Coming soon!`
160128

161129
The rest is done behind the scenes.
162130

source/docs/programming/photonlib/simulation.rst

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -38,37 +38,26 @@ It requires a number of pieces of configuration to accurately simulate your phys
3838

3939
.. tab-set-code::
4040

41-
.. rli:: https://github.com/PhotonVision/photonvision/raw/a3bcd3ac4f88acd4665371abc3073bdbe5effea8/photonlib-java-examples/src/main/java/org/photonlib/examples/simaimandrange/sim/DrivetrainSim.java
41+
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/80e16ece87c735e30755dea271a56a2ce217b588/photonlib-java-examples/simaimandrange/src/main/java/frc/robot/sim/DrivetrainSim.java
4242
:language: java
43-
:lines: 72-93
43+
:lines: 73-93
4444

45-
.. rli:: https://github.com/PhotonVision/photonvision/raw/a3bcd3ac4f88acd4665371abc3073bdbe5effea8/photonlib-cpp-examples/src/main/cpp/examples/simaimandrange/include/DrivetrainSim.h
46-
:language: c++
47-
:lines: 78-92
4845

4946
After declaring the system, you should create and add one ``SimVisionTarget`` per target on the field you are attempting to detect.
5047

5148
.. tab-set-code::
5249

53-
.. rli:: https://github.com/PhotonVision/photonvision/raw/a3bcd3ac4f88acd4665371abc3073bdbe5effea8/photonlib-java-examples/src/main/java/org/photonlib/examples/simaimandrange/sim/DrivetrainSim.java
50+
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/80e16ece87c735e30755dea271a56a2ce217b588/photonlib-java-examples/simaimandrange/src/main/java/frc/robot/sim/DrivetrainSim.java
5451
:language: java
55-
:lines: 95-116
56-
57-
.. rli:: https://github.com/PhotonVision/photonvision/raw/a3bcd3ac4f88acd4665371abc3073bdbe5effea8/photonlib-cpp-examples/src/main/cpp/examples/simaimandrange/include/DrivetrainSim.h
58-
:language: c++
59-
:lines: 94-109, 45-49
52+
:lines: 95-111
6053

6154
Finally, while running the simulation, process simulated camera frames by providing the robot's pose to the system.
6255

6356
.. tab-set-code::
6457

65-
.. rli:: https://github.com/PhotonVision/photonvision/raw/a3bcd3ac4f88acd4665371abc3073bdbe5effea8/photonlib-java-examples/src/main/java/org/photonlib/examples/simaimandrange/sim/DrivetrainSim.java
58+
.. rli:: https://raw.githubusercontent.com/PhotonVision/photonvision/80e16ece87c735e30755dea271a56a2ce217b588/photonlib-java-examples/simaimandrange/src/main/java/frc/robot/sim/DrivetrainSim.java
6659
:language: java
67-
:lines: 136-137
68-
69-
.. rli:: https://github.com/PhotonVision/photonvision/raw/a3bcd3ac4f88acd4665371abc3073bdbe5effea8/photonlib-cpp-examples/src/main/cpp/examples/simaimandrange/cpp/sim/DrivetrainSim.cpp
70-
:language: c++
71-
:lines: 46-47
60+
:lines: 138-139
7261

7362
This will cause most NetworkTables fields to update properly, representing any targets that are in view of the robot.
7463

@@ -101,24 +90,4 @@ A ``SimPhotonCamera`` can be created for this purpose. It provides an interface
10190
// ...
10291
}
10392
104-
.. code-block:: c++
105-
106-
#include "photonlib/SimPhotonCamera.h"
107-
108-
// ...
109-
110-
void Robot::SimulationInit(){
111-
// ...
112-
cam = SimPhotonCamera("MyCamera");
113-
// ...
114-
}
115-
116-
void Robot::SimulationPeriodic(){
117-
// ...
118-
std::vector<PhotonTrackedTarget> visibleTgtList = {};
119-
visibleTgtList.push_back(PhotonTrackedTarget(yawAngle, pitchAngle, area, 0.0, camToTargetTrans));
120-
cam.SubmitProcessedFrame(0_sec, wpi::MutableArrayRef<PhotonTrackedTarget>(visibleTgtList));
121-
// ...
122-
}
123-
12493
Note that while there is less code and configuration required to get basic data into the simulation, this approach will cause the user to need to implement much more code on their end to calculate the relative positions of the robot and target. If you already have this, the raw interface may be helpful. However, if you don't, you'll likely want to be looking at the Simulated Vision System first.

0 commit comments

Comments
 (0)