NUbots / robocup

The NUbot's RoboCup Code
GNU General Public License v3.0
34 stars 17 forks source link

Catch camera connection issues in DarwinCamera not in Vision-GreenHorizonCH #25

Closed mmetcalfe closed 8 years ago

mmetcalfe commented 11 years ago

When the camera is broken, disconnected or otherwise inaccessible we get the following error in Vision.

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb23cbb70 (LWP 3108)]
0x081a4f76 in GreenHorizonCH::calculateHorizon() ()

The DarwinCamera class needs to more correctly detect these faults and give useful warning messages instead of allowing Vision to receive unallocated pointers.

Important to fix, but not urgent for RC2013 as most members currently know the root cause of the issue, and it doesn't occur in playable scenarios (i.e. if this segfault happens we couldn't have been playing anyway as we have no camera stream).

WongAaronSW commented 11 years ago

This occurs from the reason being that the Green Horizon calculation is the first function to use the image. When the SEGFAULT error occurs, usually its to do with accessing invalid memory space. From my previous experience, usually you get a NULL pointer when the device has failed the transfer. Solution: Would have to catch this inside the NUbot\SeeThinkThread.cpp and throw an exception or a new error, "Camera Exception" -> best notification would be to get the robot to "Say" -> "Camera Exception", and Sit down. You might also consider replacing the cable from the HEAD. Or a swap Cameras to verify is this is a problem localised with the camera, or cable.

shannonfenn commented 11 years ago

I tried adding code to Vision to check for a null image as soon as it was retrieved from the blackboard and that didn't solve the problem, since the image pointer was non null but pointing to invalid memory (at that particular time). Either way a closer look at the DarwinCamera class is needed, which Madison is already doing, since it seems to me that the responsibility of detecting and generating alerts for faulty camera data should really be with the class responsible for accessing it.