Go to Post A world where lawyers and police don't get much work -- there's a goal to work toward. - Richard Wallace [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #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
  #2   Spotlight this post!  
Unread 06-04-2011, 16:45
BotnEyedJoe BotnEyedJoe is offline
Mentor
AKA: Joe Hurler
no team
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Rosemont, PA
Posts: 29
BotnEyedJoe is an unknown quantity at this point
Re: C++ Camera Freeze/Crash Fix!

Thanks for the kind words. Glad the patch was useful to you. I've been using it myself with great success [e.g. changing parameters on the fly, starting and stopping the video feed, etc].

For anyone interested in a little more detail about the history of this, and how to build a library containing the fix, see the thread http://www.chiefdelphi.com/forums/sh...ad.php?t=90687.
Reply With Quote
  #3   Spotlight this post!  
Unread 07-04-2011, 20:29
demosthenes2k8's Avatar
demosthenes2k8 demosthenes2k8 is offline
Graduated but not gone
AKA: Matt Soucy
FRC #0166 (Chop Shop 166)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Merrimack, NH
Posts: 589
demosthenes2k8 is a splendid one to beholddemosthenes2k8 is a splendid one to beholddemosthenes2k8 is a splendid one to beholddemosthenes2k8 is a splendid one to beholddemosthenes2k8 is a splendid one to beholddemosthenes2k8 is a splendid one to beholddemosthenes2k8 is a splendid one to beholddemosthenes2k8 is a splendid one to behold
Send a message via AIM to demosthenes2k8 Send a message via Yahoo to demosthenes2k8
Re: C++ Camera Freeze/Crash Fix!

Thanks for making a thread about it!
We had this problem a little while ago, and ended up building the library and storing it in our repository, so that once a team member loads the repository, they get it and can put it in the right folder to link to it.
__________________


GSR Dean's List Finalist 2011
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 17:42.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi