-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: main
Are you sure you want to change the base?
Conversation
@@ -54,6 +54,8 @@ public class PhotonRunnable implements Runnable { | |||
|
|||
private final Supplier<Pose2d> poseSupplier; | |||
|
|||
public boolean isCameraConnected; |
There was a problem hiding this comment.
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
.
final PhotonCamera leftCamera = new PhotonCamera("Left"); | ||
final PhotonCamera rightCamera = new PhotonCamera("Right"); | ||
if (leftCamera.isConnected() && rightCamera.isConnected()) { | ||
isCameraConnected = true; | ||
leftCamera.close(); | ||
rightCamera.close(); | ||
} |
There was a problem hiding this comment.
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.
based on this post in slack