Go to Post You know those gravitational waves you keep hearing about recently? Those weren't created by colliding black holes, they were created by our boulders colliding with the opposing alliance's tower. - JohnFogarty [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 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
  #2   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.
  #3   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.
  #4   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.
  #5   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
  #6   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...
  #7   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!
  #8   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.
  #9   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?
  #10   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.
  #11   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
  #12   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.
  #13   Spotlight this post!  
Unread 06-03-2006, 23:12
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

For the record, I was talking specifically about the camera communications state machine - when I inserted a default to catch the improper 'zero' state, it printed out errors galore.
__________________
Shift to the left, shift to the right!
Pop up, push down, byte, byte, byte!
  #14   Spotlight this post!  
Unread 07-03-2006, 00:42
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
For the record, I was talking specifically about the camera communications state machine - when I inserted a default to catch the improper 'zero' state, it printed out errors galore.
Thank you for the clarification. I have now added that instrumentation to my code.

Congratulations on 2nd place. Your alliance buddy Corvalis is one of our neighbors.
__________________
Keith Watson - Professional Software Engineer
No relation to "Kevin" Watson, who created the camera tracking code.
  #15   Spotlight this post!  
Unread 07-03-2006, 00:33
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 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.
After working with many experienced software engineers over the years I can confirm that many experienced software engineers have that same opinion. Yet just the camera.c and tracking.c files have 11 debug statements. One of those is implemented in a state machine and is called 18 times.

For all the high school programmers watching out there, creating robust software systems is an important consideration in software design, even in a resource limited machine. I have programmed on much smaller systems than the IFI. Just because you think certain conditions should not happen does not mean that they never will.

Quote:
Originally Posted by Kevin Watson
If the static state variable isn't getting initialized at boot time, a wonky state machine is the least of your worries .
I know. I will persue it until I can track down the error we observed.
__________________
Keith Watson - Professional Software Engineer
No relation to "Kevin" Watson, who created the camera tracking code.
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 11:18.

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