Skip to content

Commit c961f1e

Browse files
authored
Fix apriltag detection draw bug (#1467)
We accidentally copied more settings then we wanted. This adds an annotation that we can mark variables with that will prevent them from being copied when we switch pipeline types.
1 parent 189da52 commit c961f1e

File tree

4 files changed

+34
-6
lines changed

4 files changed

+34
-6
lines changed

photon-core/src/main/java/org/photonvision/vision/pipeline/AdvancedPipelineSettings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public AdvancedPipelineSettings() {
8080

8181
// 3d settings
8282
public boolean solvePNPEnabled = false;
83-
public TargetModel targetModel = TargetModel.k2020HighGoalOuter;
83+
@SuppressSettingCopy public TargetModel targetModel = TargetModel.k2020HighGoalOuter;
8484

8585
// Corner detection settings
8686
public CornerDetectionPipe.DetectionStrategy cornerDetectionStrategy =

photon-core/src/main/java/org/photonvision/vision/pipeline/CVPipelineSettings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
})
3838
public class CVPipelineSettings implements Cloneable {
3939
public int pipelineIndex = 0;
40-
public PipelineType pipelineType = PipelineType.DriverMode;
40+
@SuppressSettingCopy public PipelineType pipelineType = PipelineType.DriverMode;
4141
public ImageRotationMode inputImageRotationMode = ImageRotationMode.DEG_0;
4242
public String pipelineNickname = "New Pipeline";
4343
public boolean cameraAutoExposure = false;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (C) Photon Vision.
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
18+
package org.photonvision.vision.pipeline;
19+
20+
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
25+
@Target(ElementType.FIELD)
26+
@Retention(RetentionPolicy.RUNTIME)
27+
/** This annotation is used to suppress copying the settings from one pipeline to the next */
28+
public @interface SuppressSettingCopy {}

photon-core/src/main/java/org/photonvision/vision/processes/PipelineManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,10 @@ public void changePipelineType(int newType) {
518518
// Copy all fields from AdvancedPipelineSettings/its superclasses from old to new
519519
try {
520520
for (Field field : getAllFields(AdvancedPipelineSettings.class)) {
521+
if (field.isAnnotationPresent(SuppressSettingCopy.class)) {
522+
// Skip fields that are annotated with SuppressSettingCopy
523+
continue;
524+
}
521525
Object value = field.get(oldSettings);
522526
logger.debug("setting " + field.getName() + " to " + value);
523527
field.set(newSettings, value);
@@ -528,10 +532,6 @@ public void changePipelineType(int newType) {
528532

529533
logger.info("Adding new pipe of type " + type + " at idx " + idx);
530534

531-
// type gets overritten by reflction hackery above
532-
newSettings.pipelineIndex = idx;
533-
newSettings.pipelineType = type;
534-
535535
userPipelineSettings.set(idx, newSettings);
536536

537537
setPipelineInternal(idx);

0 commit comments

Comments
 (0)