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

Flashing red LEDs when the camera is disconnected from the robot #22

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

finnsherman
Copy link
Contributor

based on this post in slack

@@ -54,6 +54,8 @@ public class PhotonRunnable implements Runnable {

private final Supplier<Pose2d> poseSupplier;

public boolean isCameraConnected;
Copy link
Collaborator

@agasser agasser Aug 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field shouldn't be public. By making it public, its value can be modified outside of the class. You already have a getter/accessor, so just make it private.

Comment on lines +105 to +111
final PhotonCamera leftCamera = new PhotonCamera("Left");
final PhotonCamera rightCamera = new PhotonCamera("Right");
if (leftCamera.isConnected() && rightCamera.isConnected()) {
isCameraConnected = true;
leftCamera.close();
rightCamera.close();
}
Copy link
Collaborator

@agasser agasser Aug 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to do a little thinking on how to detect if the cameras are connected. What you have would work, but only if the cameras are connected when PhotonRunnable is instantiated. It only runs once, so if they come online later it wouldn't detect it. It would also fail to detect if the cameras were connected, but then disconnected later.

We probably need to have a timeout where we consider a camera disconnected if it hasn't sent we haven't received any data for a while, maybe one second. We have to do something within the run() method, this is the thread's code that runs continuously. One consideration is that the thread blocks (waits) at WPIUtilJNI.waitForObjects() if there is no new camera data, so the thread can tell you when the cameras are connected, but something else will have to watch for when we stop receiving data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants