View Single Post
  #1   Spotlight this post!  
Unread 11-02-2015, 17:49
razar51 razar51 is offline
Registered User
AKA: John Faulkner
FRC #1288 (Raven Robotics)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2007
Location: St. Charles, MO
Posts: 10
razar51 is an unknown quantity at this point
Prevent code crash when Camera unplugged.

I am currently using the automatic capture function to display a USB camera feed on the driver station, and I ran into a potential problem.

Since the roborio assigns a name to the USB camera, and the code must call out that name in order to define the correct camera object, when the camera is unplugged the code will crash on Init. This means that if someone accidentally unplugs the camera before a match the robot code will crash and the robot will do nothing for the whole match.

The same thing happens if the camera is replaced by a different camera (since the roborio assigns a different name).

Is there a way to wrap some protective code around the camera initialization so that it will not cause the code to crash in the absence of a camera? Or is there a way to query the names of the devices currently plugged into the roborio?
Reply With Quote