Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to user selected camera matching #1556

Merged
merged 98 commits into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
b7147d2
Removed matching logic
oh-yes-0-fps Nov 11, 2024
010cf54
Create camera configs UI thingy?
mcm001 Nov 11, 2024
f2f1bd4
idk
oh-yes-0-fps Nov 11, 2024
61be2d1
comment out vision source manager unit tests for now
oh-yes-0-fps Nov 11, 2024
3a38e75
Maybe make things prettier
mcm001 Nov 12, 2024
a08aa7b
More styling
mcm001 Nov 12, 2024
eca56e1
Telemeter sequence ID
mcm001 Nov 12, 2024
59c9555
renamed camera info
oh-yes-0-fps Nov 12, 2024
ff3985b
Merge branch 'matts-camera-ui-stuff' into camera-match
oh-yes-0-fps Nov 13, 2024
38b6e16
dawg idk
oh-yes-0-fps Nov 13, 2024
4bd2df4
fdsa
mcm001 Nov 13, 2024
19b3701
Fix typos and run lint
mcm001 Nov 13, 2024
cdff7b5
Run vue lint
mcm001 Nov 13, 2024
743aabf
added support for unplugging and removing to backend
oh-yes-0-fps Nov 13, 2024
34e4ed0
added camera module disabling to backend
oh-yes-0-fps Nov 14, 2024
8944f93
added camera unasigning to frontend
oh-yes-0-fps Nov 14, 2024
9be154d
fixed equality check
oh-yes-0-fps Nov 15, 2024
e842f8f
hopefully fixed native resource cleanup
oh-yes-0-fps Nov 15, 2024
9e75c52
all my homies hate camera server
oh-yes-0-fps Nov 15, 2024
d72f664
UI styling and push full settings
mcm001 Nov 15, 2024
04f183c
Yet more coherancy and destruction ordering
mcm001 Nov 15, 2024
4f56628
Fix stream index assignment issue
mcm001 Nov 15, 2024
ba31e1a
run lint
mcm001 Nov 15, 2024
6e552ad
Run lint
mcm001 Nov 15, 2024
bb7df87
broken blinkinlits
mcm001 Nov 15, 2024
4216a9c
Merge branch 'master' into camera-match
Juniormunk Nov 17, 2024
9ec07d7
Add UML diagrams
mcm001 Nov 24, 2024
d37868a
whoops
mcm001 Nov 24, 2024
d37cc4d
Refactor to create VsmState/differentiate unmatched vs disabled
mcm001 Nov 24, 2024
b1479f9
Add new card
mcm001 Nov 24, 2024
8f1f558
Half maybe works, ugly still
mcm001 Nov 24, 2024
6adf947
Add docs
mcm001 Nov 24, 2024
5aaa788
Run lint
mcm001 Nov 24, 2024
9bfb221
Proof of concept refactoring
mcm001 Nov 25, 2024
26dae86
Ooga booga
mcm001 Nov 26, 2024
84a6739
Trim down registerLoadedConfigs
Nov 27, 2024
63698ba
Add subtype for file sources
mcm001 Nov 26, 2024
3f640a3
Slowly getting back up to working again
mcm001 Nov 27, 2024
c586e6b
Yay things mostly work!
mcm001 Nov 27, 2024
f523340
Sketch out test
mcm001 Nov 28, 2024
9b59e40
yeet
mcm001 Nov 28, 2024
ed5f8bf
replaced `discoveredCameras` with `visionSourceManager`
oh-yes-0-fps Nov 28, 2024
0fce810
kinda out of scope but if we don't do it now who knows when it will b…
oh-yes-0-fps Nov 28, 2024
dfa63c8
Fixup UI, run lint
mcm001 Nov 28, 2024
1abf298
active modules ui cleanup
mcm001 Nov 28, 2024
c0f760c
Yet more noodling
mcm001 Nov 28, 2024
0ea853d
a;sdlkfj UI
mcm001 Nov 28, 2024
58534b5
Fix deactivate/reactivate
mcm001 Nov 30, 2024
a9c34fd
First pass at checking if device connected yet
mcm001 Dec 3, 2024
2665f89
More broken refactoring
mcm001 Dec 3, 2024
a9379ce
Revert "More broken refactoring"
mcm001 Dec 4, 2024
8e094bb
ooga booga
mcm001 Dec 4, 2024
637743a
Less ui crimes
Juniormunk Dec 18, 2024
aadac87
woops
Juniormunk Dec 18, 2024
4e7cde0
Fix NPE, and cleanup card
mcm001 Dec 20, 2024
d594919
run settable changes synchronously
Juniormunk Dec 23, 2024
8f50525
One single future
Juniormunk Dec 23, 2024
c6247cc
Make nickname a uuid, again
mcm001 Dec 24, 2024
b441176
Fist pass at fixing UI memery
mcm001 Dec 24, 2024
928a1d9
Pain, death, suffering
mcm001 Dec 24, 2024
6401d59
Allow PhotonCameraStream to use any camera
Juniormunk Dec 24, 2024
91196ce
Start with libcamera
Juniormunk Dec 25, 2024
922a370
UI account for disconnected cameras better
Juniormunk Dec 26, 2024
318076c
Add hasConnected
Juniormunk Dec 27, 2024
f46f647
Fix beyond-scroll background
DevonRD Dec 27, 2024
be044fe
Fix UI crimes
DevonRD Dec 27, 2024
e93462d
Update CameraMatchingView.vue
Juniormunk Dec 28, 2024
f36c6b8
Fix all expanding bug
Juniormunk Dec 28, 2024
04ecd10
Start on debugging stuff
mcm001 Dec 28, 2024
0e5b611
Merge remote-tracking branch 'upstream/main' into camera-match
mcm001 Dec 28, 2024
eab28d5
Fix merge conflicts
mcm001 Dec 28, 2024
0fc81a9
Merge branch 'camera-match' of https://github.com/oh-yes-0-fps/photon…
mcm001 Dec 28, 2024
6c5bee4
Re-cache properties on settable remake
mcm001 Dec 28, 2024
06ed322
Merge remote-tracking branch 'upstream/main' into camera-match
mcm001 Dec 28, 2024
9e6a20e
Run lint
mcm001 Dec 28, 2024
ae4e7f6
Reconnect on stream load error
Juniormunk Dec 28, 2024
9b1d5ef
Javadocs Build
Juniormunk Dec 30, 2024
cd27fce
Test grid-style camera matching modules
DevonRD Dec 30, 2024
1855a73
Merge branch 'camera-match' of https://github.com/oh-yes-0-fps/photon…
DevonRD Dec 30, 2024
28a0fd8
Merge remote-tracking branch 'upstream/main' into camera-match
mcm001 Dec 30, 2024
491a486
Add a delete button with zero protection
mcm001 Dec 30, 2024
3f91b39
Fixup unit tests
Juniormunk Dec 31, 2024
d7b5d82
Fix Merge Conflicts
Juniormunk Dec 31, 2024
be318f2
Spotless
Juniormunk Dec 31, 2024
947b4d9
Photon-Client lint
Juniormunk Dec 31, 2024
68c3751
Oops
Juniormunk Dec 31, 2024
096929f
Fix PhotonClient Lint
Juniormunk Dec 31, 2024
e3a51a1
Ui error, Fix Config Test
Juniormunk Dec 31, 2024
8078264
Libcamera Working
Juniormunk Dec 31, 2024
84bd76b
Camera details modal
DevonRD Dec 31, 2024
43350b1
warn if camera info chages
mcm001 Dec 31, 2024
b49146a
Camera object comparison + status
DevonRD Dec 31, 2024
f2e9fa6
Oops
DevonRD Dec 31, 2024
ea1a4b5
Run lint
mcm001 Dec 31, 2024
4fd0e2e
Fix file sources always reporting disconnected
mcm001 Dec 31, 2024
e8399d8
Add a silly little modal
mcm001 Dec 31, 2024
6516d78
whoops
mcm001 Dec 31, 2024
c76b12d
Fix Lint
Juniormunk Jan 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ public class NetworkConfig {
public boolean shouldManage;
public boolean shouldPublishProto = false;

/**
* If we should ONLY match cameras by path, and NEVER only by base-name. For now default to false
* to preserve old matching logic.
*
* <p>This also disables creating new CameraConfigurations for detected "new" cameras.
*/
public boolean matchCamerasOnlyByPath = false;

@JsonIgnore public static final String NM_IFACE_STRING = "${interface}";
@JsonIgnore public static final String NM_IP_STRING = "${ipaddr}";

Expand Down Expand Up @@ -74,8 +66,7 @@ public NetworkConfig(
@JsonProperty("shouldPublishProto") boolean shouldPublishProto,
@JsonProperty("networkManagerIface") String networkManagerIface,
@JsonProperty("setStaticCommand") String setStaticCommand,
@JsonProperty("setDHCPcommand") String setDHCPcommand,
@JsonProperty("matchCamerasOnlyByPath") boolean matchCamerasOnlyByPath) {
@JsonProperty("setDHCPcommand") String setDHCPcommand) {
this.ntServerAddress = ntServerAddress;
this.connectionType = connectionType;
this.staticIp = staticIp;
Expand All @@ -85,7 +76,6 @@ public NetworkConfig(
this.networkManagerIface = networkManagerIface;
this.setStaticCommand = setStaticCommand;
this.setDHCPcommand = setDHCPcommand;
this.matchCamerasOnlyByPath = matchCamerasOnlyByPath;
setShouldManage(shouldManage);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,105 +19,204 @@

import edu.wpi.first.cscore.UsbCameraInfo;
import java.util.Arrays;
import java.util.Optional;
import org.photonvision.common.hardware.Platform;

public class CameraInfo extends UsbCameraInfo {
public final CameraType cameraType;

public CameraInfo(
int dev, String path, String name, String[] otherPaths, int vendorId, int productId) {
super(dev, path, name, otherPaths, vendorId, productId);
cameraType = CameraType.UsbCamera;
}

public CameraInfo(
int dev,
String path,
String name,
String[] otherPaths,
int vendorId,
int productId,
CameraType cameraType) {
super(dev, path, name, otherPaths, vendorId, productId);
this.cameraType = cameraType;
}

public CameraInfo(UsbCameraInfo info) {
super(info.dev, info.path, info.name, info.otherPaths, info.vendorId, info.productId);
cameraType = CameraType.UsbCamera;
}
import org.photonvision.common.configuration.CameraConfiguration;
import org.photonvision.common.hardware.Platform;

public sealed interface CameraInfo {
/**
* @return True, if this camera is reported from V4L and is a CSI camera.
* @return The path of the camera. This is the path that is used to open the camera.
*/
public boolean getIsV4lCsiCamera() {
return (Arrays.stream(otherPaths).anyMatch(it -> it.contains("csi-video"))
|| getBaseName().equals("unicam"));
}
String path();

/**
* @return The base name of the camera aka the name as just ascii.
*/
public String getBaseName() {
return name.replaceAll("[^\\x00-\\x7F]", "");
}
String name();

/**
* @return Returns a human readable name
*/
public String getHumanReadableName() {
return getBaseName().replaceAll(" ", "_");
default String humanReadableName() {
return name().replaceAll(" ", "_");
}

/**
* Get a unique descriptor of the USB port this camera is attached to. EG
* "/dev/v4l/by-path/platform-fc800000.usb-usb-0:1.3:1.0-video-index0"
* If the camera is a USB camera this method returns
* a unique descriptor of the USB port this camera is attached to. EG
* "/dev/v4l/by-path/platform-fc800000.usb-usb-0:1.3:1.0-video-index0".
* If the camera is a CSI camera this method returns the path of the camera.
*
* @return
* @return The unique path of the camera
*/
public Optional<String> getUSBPath() {
return Arrays.stream(otherPaths).filter(path -> path.contains("/by-path/")).findFirst();
String uniquePath();

String[] otherPaths();

CameraType type();

public static final class PVUsbCameraInfo extends UsbCameraInfo implements CameraInfo {

private PVUsbCameraInfo(
int dev, String path, String name, String[] otherPaths, int vendorId, int productId) {
super(dev, path, name, otherPaths, vendorId, productId);
}

private PVUsbCameraInfo(UsbCameraInfo info) {
super(info.dev, info.path, info.name, info.otherPaths, info.vendorId, info.productId);
}

@Override
public String path() {
return super.path;
}

@Override
public String name() {
return super.name.replaceAll("[^\\x00-\\x7F]", "");
}

@Override
public String uniquePath() {
return Arrays.stream(super.otherPaths).filter(path -> path.contains("/by-path/")).findFirst()
.orElse(path());
}

@Override
public String[] otherPaths() {
return super.otherPaths;
}

@Override
public CameraType type() {
return CameraType.UsbCamera;
}

@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
PVUsbCameraInfo other = (PVUsbCameraInfo) obj;

// Windows device number is not significant. See
Juniormunk marked this conversation as resolved.
Show resolved Hide resolved
// https://github.com/wpilibsuite/allwpilib/blob/4b94a64b06057c723d6fcafeb1a45f55a70d179a/cscore/src/main/native/windows/UsbCameraImpl.cpp#L1128
if (!Platform.isWindows()) {
if (dev != other.dev) return false;
}

if (!path.equals(other.path)) return false;
if (!name.equals(other.name)) return false;
if (!this.uniquePath().contains(other.uniquePath())) return false;
if (vendorId != other.vendorId) return false;
if (productId != other.productId) return false;

// Don't trust super.equals, as it compares references. Should PR this to allwpilib at some point
return true;
}
}

@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
CameraInfo other = (CameraInfo) obj;
public static final class PVCSICameraInfo implements CameraInfo {
public final String path;
public final String baseName;

// Windows device number is not significant. See
// https://github.com/wpilibsuite/allwpilib/blob/4b94a64b06057c723d6fcafeb1a45f55a70d179a/cscore/src/main/native/windows/UsbCameraImpl.cpp#L1128
if (!Platform.isWindows()) {
if (dev != other.dev) return false;
private PVCSICameraInfo(String path, String baseName) {
this.path = path;
this.baseName = baseName;
}

if (!path.equals(other.path)) return false;
if (!name.equals(other.name)) return false;
if (!Arrays.asList(this.getUSBPath()).contains(other.getUSBPath())) return false;
if (vendorId != other.vendorId) return false;
if (productId != other.productId) return false;
@Override
public String path() {
return path;
}

@Override
public String name() {
return baseName.replaceAll("[^\\x00-\\x7F]", "");
}

@Override
public String uniquePath() {
return path();
}

@Override
public String[] otherPaths() {
return new String[0];
}

@Override
public CameraType type() {
return CameraType.ZeroCopyPicam;
}

@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
PVCSICameraInfo other = (PVCSICameraInfo) obj;

if (!path.equals(other.path)) return false;
if (!baseName.equals(other.baseName)) return false;

return true;
}
}

public static final class PVReconstructedCameraInfo implements CameraInfo {
private final String path;
private final String name;
private final String[] otherPaths;
private final CameraType type;

public PVReconstructedCameraInfo(String path, String name, String[] otherPaths, CameraType type) {
this.path = path;
this.name = name;
this.otherPaths = otherPaths;
this.type = type;
}

@Override
public String path() {
return path;
}

@Override
public String name() {
return name;
}

@Override
public String uniquePath() {
return path;
}

@Override
public String[] otherPaths() {
return otherPaths;
}

@Override
public CameraType type() {
return type;
}
}

public static CameraInfo fromUsbCameraInfo(UsbCameraInfo info) {
return new PVUsbCameraInfo(info);
}

public static CameraInfo fromUsbCameraInfo(
int dev, String path, String name, String[] otherPaths, int vendorId, int productId) {
return new PVUsbCameraInfo(dev, path, name, otherPaths, vendorId, productId);
}

// Don't trust super.equals, as it compares references. Should PR this to allwpilib at some
// point
return true;
public static CameraInfo fromCSICameraInfo(String path, String baseName) {
return new PVCSICameraInfo(path, baseName);
}

@Override
public String toString() {
return "CameraInfo [cameraType="
+ cameraType
+ ", baseName="
+ getBaseName()
+ ", vid="
+ vendorId
+ ", pid="
+ productId
+ ", path="
+ path
+ ", otherPaths="
+ Arrays.toString(otherPaths)
+ "]";
public static CameraInfo fromCameraConfig(CameraConfiguration config) {
return new PVReconstructedCameraInfo(config.path, config.baseName, config.otherPaths, config.cameraType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@

public enum CameraType {
UsbCamera,
HttpCamera,
ZeroCopyPicam
}

This file was deleted.

Loading
Loading