View Single Post
  #1   Spotlight this post!  
Unread 02-04-2011, 22:11
Dacilndak's Avatar
Dacilndak Dacilndak is offline
Matt'); DROP TABLE Users; --
AKA: Matthew Haney
FRC #3729 (Red Knights)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Denver, Colorado
Posts: 12
Dacilndak is an unknown quantity at this point
C++ Camera Freeze/Crash Fix!

My team has been having issues with our Axis M1011 camera this year. Given the default FIRST-provided code:

Code:
Wait(8.0);
AxisCamera & cam = AxisCamera::GetInstance();
the camera image would appear on the DS for a few seconds, then freeze. The cRIO would crash, the RSL would either stop blinking or go off completely, and we would lose all communication to the robot UNTIL we unplugged the camera - then communications would be immediately restored.

If any of you other CD users have had this problem, today I found a solution.

I must give many, many thanks to Joe Hurler, who detected and patched a bug in the WPILib files concerning the AxisCamera and AxisCameraParams classes. Apparently, the two work together on two separate threads (or tasks), one reading MJPEG images from the camera and the other trying to update the camera settings. However, these two threads do not coordinate with each other to regulate access to the camera. As such, they often get in each other's way and both would crash. Full details can be found here.

Hurler successfully patched this problem (files downloadable here) with three files: AxisCamera.cpp, AxisCameraParams.cpp, and AxisCameraParams.h. To install these patches, simply add AxisCameraParams.cpp and AxisCamera.cpp to your WindRiver project, and in the same project open the Includes tab in the class browser. From there, expand the first (top) directory. Expand Vision. Open AxisCameraParams.h and copy all of the source from Hurler's AxisCameraParams.h into that file (overwriting the old code). Everything is now in place, but there is one important fix that must be made:

In AxisCamera.cpp and AxisCameraParams.cpp, some errors will be generated if you attempt to build your project; namely, the compiler won't be able to find some header files (I believe they're AxisCamera.h and PCVideoServer.h). Inside the quotes, add "Vision/" to the pathname (making it #include "Vision/AxisCamera.h"). Your project should now build flawlessly, and the camera image should show up on the dashboard!

Thanks again to Joe Hurler for finding this error in WPILib and coming up with a solution! I hope this helps other teams using C++ suffering from this problem!
__________________
Team 3729 - Raiders - Programming Team Co-Captain
2011 Colorado Regional Semifinalist
2011 Colorado Regional Rookie All-Star Award
2011 Colorado Regional Highest Rookie Seed Award
Reply With Quote