Go to Post Don't fix mechanical problems with software, ever. - Chris is me [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 03-03-2006, 22:56
Keith Watson Keith Watson is offline
Registered User
FRC #0957 (WATSON)
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2006
Location: Wilsonville, OR
Posts: 112
Keith Watson is just really niceKeith Watson is just really niceKeith Watson is just really niceKeith Watson is just really nice
Camera does not search in autonomous mode after reset

We encountered a problem for the first time today at the regional. It only happens in autonomous mode. Take the robot to the playing field, plug in the backup battery, power on the main battery, press reset on the controller, the camera does not initialize.

I've read other people have encountered the same problem but have not seen anyone have an actual fix.

The camera code is correctly called from autonomous mode and works if the robot is put into user mode then back into autonomous mode (which you obvisously cannot do on the field). We even did this in the pits and left the robot powered on till it was put on the playing field. It worked that time.

We have since found a spot in the code which is called in autonomous mode right before the inner while loop. We are going to try to reset the camera intialization variable there and test it during the finals.

The behavior is the same as if a controller reset does not call the program's static initializers in autonomous mode!
__________________
Keith Watson - Professional Software Engineer
No relation to "Kevin" Watson, who created the camera tracking code.
  #2   Spotlight this post!  
Unread 04-03-2006, 21:00
Bharat Nain's Avatar
Bharat Nain Bharat Nain is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Jan 2004
Rookie Year: 2003
Location: New York
Posts: 2,000
Bharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond repute
Send a message via AIM to Bharat Nain Send a message via MSN to Bharat Nain
Re: Camera does not search in autonomous mode after reset

Quote:
Originally Posted by Keith Watson
We encountered a problem for the first time today at the regional. It only happens in autonomous mode. Take the robot to the playing field, plug in the backup battery, power on the main battery, press reset on the controller, the camera does not initialize.

I've read other people have encountered the same problem but have not seen anyone have an actual fix.

The camera code is correctly called from autonomous mode and works if the robot is put into user mode then back into autonomous mode (which you obvisously cannot do on the field). We even did this in the pits and left the robot powered on till it was put on the playing field. It worked that time.

We have since found a spot in the code which is called in autonomous mode right before the inner while loop. We are going to try to reset the camera intialization variable there and test it during the finals.

The behavior is the same as if a controller reset does not call the program's static initializers in autonomous mode!
We have had some weird problems on the field all day too but we COMPLETELY unplug all our batteries and then check all our electrical connections and put it back in. It seemed to have worked fine after that.
__________________
-= Bharat Nain =-

Whatever you do, you need courage. Whatever course you decide upon, there is always someone to tell you that you are wrong. There are always difficulties arising that tempt you to believe your critics are right. To map out a course of action and follow it to an end requires some of the same courage that a soldier needs. Peace has its victories, but it takes brave men and women to win them. - Ralph Waldo Emerson
  #3   Spotlight this post!  
Unread 04-03-2006, 21:49
Keith Watson Keith Watson is offline
Registered User
FRC #0957 (WATSON)
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2006
Location: Wilsonville, OR
Posts: 112
Keith Watson is just really niceKeith Watson is just really niceKeith Watson is just really niceKeith Watson is just really nice
Re: Camera does not search in autonomous mode after reset

We would completely unplug our batteries also. We could reproduce the problems in the pits by setting our OI to autonomous. During the matches today the camera did initialize so resetting the variable I mentioned does work.
__________________
Keith Watson - Professional Software Engineer
No relation to "Kevin" Watson, who created the camera tracking code.
  #4   Spotlight this post!  
Unread 05-03-2006, 01:08
Uberbots's Avatar
Uberbots Uberbots is offline
Mad Programmer
AKA: Billy Sisson
FRC #1124 (ÜberBots)
Team Role: College Student
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Avon
Posts: 739
Uberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond repute
Re: Camera does not search in autonomous mode after reset

Quote:
Originally Posted by Keith Watson
We would completely unplug our batteries also. We could reproduce the problems in the pits by setting our OI to autonomous. During the matches today the camera did initialize so resetting the variable I mentioned does work.
Hmm...
You know that section in the User_Autonomous_Code function, right before the "while (autonomous_mode)" loop (and right after all of the PWM values are reset)?
Our team had been experiencing problems with that, and so (in my hacking nature...) I had put the Initialize_Camera function in that section. I don't know why, but it helped, and now the camera always initializes when Autonomous mode starts (or is invoked).

also, while you are executing the Autonomous loop, are you sure you are calling the function "Camera_Handler()"?
__________________
A few of my favorite numbers:
175 176 177 195 230 558 716 1024 1071 1592 1784 1816
RPI 2012
BREAKAWAY

Last edited by Uberbots : 05-03-2006 at 13:01.
  #5   Spotlight this post!  
Unread 05-03-2006, 15:47
Keith Watson Keith Watson is offline
Registered User
FRC #0957 (WATSON)
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2006
Location: Wilsonville, OR
Posts: 112
Keith Watson is just really niceKeith Watson is just really niceKeith Watson is just really niceKeith Watson is just really nice
Re: Camera does not search in autonomous mode after reset

Quote:
Originally Posted by Uberbots
Hmm...
You know that section in the User_Autonomous_Code function, right before the "while (autonomous_mode)" loop (and right after all of the PWM values are reset)?
Our team had been experiencing problems with that, and so (in my hacking nature...) I had put the Initialize_Camera function in that section. I don't know why, but it helped, and now the camera always initializes when Autonomous mode starts (or is invoked).
That is the same section of code where I added
Code:
tracking_initialized = 0;
Quote:
Originally Posted by Uberbots
also, while you are executing the Autonomous loop, are you sure you are calling the function "Camera_Handler()"?
Yes. Our programmer found camera searching was not working in autonomous and he and I tracked down why and added both "Camera_Handler()" and "Servo_Track()".

The behavior I described as if the static initializers are not being called under certain conditions is also happening in the recent thread The 8.2 (or 8.3) Battery Voltage Bug.
__________________
Keith Watson - Professional Software Engineer
No relation to "Kevin" Watson, who created the camera tracking code.
  #6   Spotlight this post!  
Unread 05-03-2006, 15:54
Keith Watson Keith Watson is offline
Registered User
FRC #0957 (WATSON)
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2006
Location: Wilsonville, OR
Posts: 112
Keith Watson is just really niceKeith Watson is just really niceKeith Watson is just really niceKeith Watson is just really nice
Re: Camera does not search in autonomous mode after reset

Come to think of it, we had "intermittent" camera initialization problems from day one. Most of the time we assumed it was from a low backup battery so we were constantly swapping those in and out. Camera initialization always failed for autonomous mode when the competition port was connected. We struggled a long time with assuming we were not starting up the robot the same way every time. It was not until Friday night at the regional when we were finally able to consistently reproduce the problem in the pits. That was when we decided to try a non-static initializer.

And I no longer have access to the robot to write a test to prove the static initialization conditions.

The static initializater for camera initialization is in Kevin's bells and whistles camera code.
__________________
Keith Watson - Professional Software Engineer
No relation to "Kevin" Watson, who created the camera tracking code.

Last edited by Keith Watson : 05-03-2006 at 16:08. Reason: added two more notes
  #7   Spotlight this post!  
Unread 05-03-2006, 16:52
kaszeta's Avatar
kaszeta kaszeta is offline
Registered User
FRC #0095 (Grasshoppers)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Lebanon, NH
Posts: 334
kaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of light
Re: Camera does not search in autonomous mode after reset

Quote:
Originally Posted by Keith Watson
Come to think of it, we had "intermittent" camera initialization problems from day one. Most of the time we assumed it was from a low backup battery so we were constantly swapping those in and out.
Same here...

Quote:
And I no longer have access to the robot to write a test to prove the static initialization conditions.
I do, I have our teams 2006 RC sitting in front of me (since I'm going to send it to IFI this week). If I have a spare moment I'm going to write some test code to check on this, as well as read over the 8722 manual and errata (I had a similar issue to this with another 18F chip on a project at work, so I wouldn't be surprised).

Oy, amazing how repeated testing of a bot at home can show things to be surprising robust, but fail completely at competition like clockwork...
  #8   Spotlight this post!  
Unread 06-03-2006, 11:06
steven114 steven114 is offline
Programming Wizard and Team Captain
AKA: Steven Schlansker
FRC #0114 (Eaglestrike)
Team Role: Programmer
 
Join Date: Feb 2004
Location: Los Altos, CA
Posts: 335
steven114 is a jewel in the roughsteven114 is a jewel in the roughsteven114 is a jewel in the rough
Send a message via AIM to steven114
Re: Camera does not search in autonomous mode after reset

It seems that the problem can manifest itself as a messed up state machine - where there is the large switch() statement with CASE_ONE through CASE_WHATEVER, the state becomes set to zero accidentally so it falls through every time and does nothing.
__________________
Shift to the left, shift to the right!
Pop up, push down, byte, byte, byte!
  #9   Spotlight this post!  
Unread 06-03-2006, 13:20
Eldarion's Avatar
Eldarion Eldarion is offline
Electrical Engineer / Computer Geek
AKA: Eldarion Telcontar
no team (Teamless Orphan)
Team Role: Alumni
 
Join Date: Nov 2005
Rookie Year: 2005
Location: Númenor
Posts: 558
Eldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond repute
Send a message via AIM to Eldarion Send a message via Yahoo to Eldarion
Re: Camera does not search in autonomous mode after reset

Quote:
Originally Posted by Keith Watson
We encountered a problem for the first time today at the regional. It only happens in autonomous mode. Take the robot to the playing field, plug in the backup battery, power on the main battery, press reset on the controller, the camera does not initialize.

I've read other people have encountered the same problem but have not seen anyone have an actual fix.

The camera code is correctly called from autonomous mode and works if the robot is put into user mode then back into autonomous mode (which you obvisously cannot do on the field). We even did this in the pits and left the robot powered on till it was put on the playing field. It worked that time.

We have since found a spot in the code which is called in autonomous mode right before the inner while loop. We are going to try to reset the camera intialization variable there and test it during the finals.

The behavior is the same as if a controller reset does not call the program's static initializers in autonomous mode!
I got to thinking about this. Is this the reason IFI has the second "initialization" section directly before the autonomous while loop? Would it be a good idea just to bypass IFI's initialization calls altogether and make your own initialized / not initialized flag that, when zero, calls the init routine and sets the flag to 1?

I distinctly recall a similar problem in our custom code last year, with the robot acting completely bezerk on the field, yet in the pit with the dongle, it worked perfectly. I had heard a rumor about the Arena Controller forcing some king of sync with the OI and RC; is there anything to justify this rumor? It might explain a lot of the "it worked perfectly until I put it on the field" problems.

Would this issue be reproducable on a 2004/2005 RC, since it seems to be a problem with IFI's default code?

Just some ideas...
__________________
CMUCam not working? Tracks sporadically? Try this instead: http://www.falconir.com!
PM me for more information if you are interested (it's open source!).

Want the FIRST Email blasts? See here: http://www.chiefdelphi.com/forums/sh...ad.php?t=50809

"The harder the conflict, the more glorious the triumph. What we obtain too cheaply, we esteem too lightly; it is dearness only that gives everything its value."
-- Thomas Paine

If it's falling apart it's a mechanical problem. If it's spewing smoke it's a electrical problem.
If it's rampaging around destroying things it's a programming problem.

"All technology is run on 'Magic Smoke' contained within the device. As everyone knows, whenever the magic smoke is released, the device ceases to function."
-- Anonymous

I currently speak: English, some German, Verilog, x86 and 8051 Assembler, C, C++, VB, VB.NET, ASP, PHP, HTML, UNIX and SQL

Last edited by Eldarion : 06-03-2006 at 13:25.
  #10   Spotlight this post!  
Unread 06-03-2006, 21:22
Keith Watson Keith Watson is offline
Registered User
FRC #0957 (WATSON)
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2006
Location: Wilsonville, OR
Posts: 112
Keith Watson is just really niceKeith Watson is just really niceKeith Watson is just really niceKeith Watson is just really nice
Re: Camera does not search in autonomous mode after reset

Quote:
Originally Posted by steven114
It seems that the problem can manifest itself as a messed up state machine - where there is the large switch() statement with CASE_ONE through CASE_WHATEVER, the state becomes set to zero accidentally so it falls through every time and does nothing.
Neither our code nor tracking.c uses switch statements. Camera.c does though and does not have default cases. Bad idea. I never write switch statements without a default case even if it just prints an error message.
__________________
Keith Watson - Professional Software Engineer
No relation to "Kevin" Watson, who created the camera tracking code.
  #11   Spotlight this post!  
Unread 06-03-2006, 21:33
bear24rw's Avatar
bear24rw bear24rw is offline
Team 11 Programming Captain
AKA: Max T
FRC #0011 (MORT)
Team Role: Programmer
 
Join Date: Sep 2005
Rookie Year: 2005
Location: Flanders, NJ
Posts: 385
bear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to behold
Send a message via AIM to bear24rw
Re: Camera does not search in autonomous mode after reset

Quote:
Originally Posted by Keith Watson
I never write switch statements without a default case even if it just prints an error message.
What would happen if you didn't have a default case?
  #12   Spotlight this post!  
Unread 06-03-2006, 21:36
Keith Watson Keith Watson is offline
Registered User
FRC #0957 (WATSON)
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2006
Location: Wilsonville, OR
Posts: 112
Keith Watson is just really niceKeith Watson is just really niceKeith Watson is just really niceKeith Watson is just really nice
Re: Camera does not search in autonomous mode after reset

Quote:
Originally Posted by Eldarion
I got to thinking about this. Is this the reason IFI has the second "initialization" section directly before the autonomous while loop? Would it be a good idea just to bypass IFI's initialization calls altogether and make your own initialized / not initialized flag that, when zero, calls the init routine and sets the flag to 1?
The only initialization I see is giving all outputs a default value. Not only is there a comment explaining why, but the user code gets called once on startup even when in autonomous mode. So forcing outputs to off is a good idea.

Quote:
Originally Posted by Eldarion
I distinctly recall a similar problem in our custom code last year, with the robot acting completely bezerk on the field, yet in the pit with the dongle, it worked perfectly. I had heard a rumor about the Arena Controller forcing some king of sync with the OI and RC; is there anything to justify this rumor? It might explain a lot of the "it worked perfectly until I put it on the field" problems.

Would this issue be reproducable on a 2004/2005 RC, since it seems to be a problem with IFI's default code?

Just some ideas...
Thanks for the ideas. In the rush at the Regional we never had the time to sit down, develop a test plan, and methodically track down the problem. But we did find a sequence of events where we could reproduce the problem in the pits. Our code was just not instrumented to diagnose the problem.

Today I developed a test plan involving: using the default frc_camera_2 code, adding camera tracking to autonomous, and instrumenting the camera and tracking initialization variables to show their state on OI lights. My team contact is on the other coast for 2 weeks so I may not be able to arrange test time for a while.

Unfortunately our regional is over and we are done for the year. Our strategy was heavily weighted towards scoring during autonomous. All the pieces were in place but the camera never worked during autonomous.
__________________
Keith Watson - Professional Software Engineer
No relation to "Kevin" Watson, who created the camera tracking code.
  #13   Spotlight this post!  
Unread 06-03-2006, 21:41
Keith Watson Keith Watson is offline
Registered User
FRC #0957 (WATSON)
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2006
Location: Wilsonville, OR
Posts: 112
Keith Watson is just really niceKeith Watson is just really niceKeith Watson is just really niceKeith Watson is just really nice
Re: Camera does not search in autonomous mode after reset

Quote:
Originally Posted by bear24rw
What would happen if you didn't have a default case?
In general, if you end up with an invalid state you will have unpredictable results. Specifically with regards to camera.c, I have looked at the code but cannot predict what might happen. The first walk through looks like it should work. But I have not worked through the possibilities to see if it is possible to have an uninitialized state.
__________________
Keith Watson - Professional Software Engineer
No relation to "Kevin" Watson, who created the camera tracking code.
  #14   Spotlight this post!  
Unread 06-03-2006, 22:58
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Camera does not search in autonomous mode after reset

Quote:
Originally Posted by Keith Watson
Neither our code nor tracking.c uses switch statements. Camera.c does though and does not have default cases. Bad idea. I never write switch statements without a default case even if it just prints an error message.
Sure, on large, complex systems with lots of resources you'd instrument the code or HDL to catch such cases. Instrumenting a very simple state machine that cannot (by inspection) have an invalid state, in a resource constrained system where code readability is of paramount importance, doesn't make sense to me. If the static state variable isn't getting initialized at boot time, a wonky state machine is the least of your worries .
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #15   Spotlight this post!  
Unread 06-03-2006, 23:12
eugenebrooks eugenebrooks is offline
Team Role: Engineer
AKA: Dr. Brooks
no team (WRRF)
 
Join Date: Jan 2004
Rookie Year: 2001
Location: Livermore, CA
Posts: 601
eugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond repute
Re: Camera does not search in autonomous mode after reset

Quote:
Originally Posted by Kevin Watson
Sure, on large, complex systems with lots of resources you'd instrument the code or HDL to catch such cases. Instrumenting a very simple state machine that cannot (by inspection) have an invalid state, in a resource constrained system where code readability is of paramount importance, doesn't make sense to me. If the static state variable isn't getting initialized at boot time, a wonky state machine is the least of your worries .
Now I know what that third LED relay light is for, we found a use for
all of the other lights on the OI. We will label it the "totally
screwed" light. It is best to know this condition as early as possible.

Sounds like the default action for the switch statement to me...

Last edited by eugenebrooks : 06-03-2006 at 23:14.
Closed Thread


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
How should we call camera tracking functions during autonomous mode? SHerpich Programming 1 15-02-2006 18:33
camera auto mode pwm contention? AL_E Programming 4 24-01-2006 22:10
a simple autonomous mode question chippermonky Programming 3 18-02-2005 01:54
autonomous mode problem on field Chris_C Programming 17 26-03-2003 19:11


All times are GMT -5. The time now is 05:12.

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