wait_for_light - help request, documentation?

6 replies [Last post]
RiverValley_Joe
Title: NooBot
Joined: 10/13/2012
Posts:
BotPoints: 19
User offline. Last seen 9 years 24 weeks ago.

I see the function wait_for_light in the 2012 Workshop Example Programs, and it compiles.

What I am requesting is: "where is documentation for this function?"

Now I suspect there are more such functions, somewhere!

Thanks,
Joe

Jeremy Rand
Jeremy Rand's picture
Title: Botball Youth Advisory Council
Joined: 04/03/2009
Posts:
BotPoints: 1168
User offline. Last seen 7 years 19 weeks ago.

I think the workshop slides are the only documentation for wait_for_light, unless there's something in the KISS-IDE manual.

However, a warning. I discovered a bug (presented at GCER 2012, in the Bug Hunting 101 talk) in wait_for_light, which can crash the CBC while the CBC is waiting for the light to turn on. The bug occurs because repeatedly beeping (which the wait_for_light function does) has a risk of crashing. My team in 2011 barely noticed this in time to fix it the night before the tournament; I know of 2 other teams who lost a match due to this. My assumption is that this will be fixed in the Kovan, but if you happen to be using the CBC for anything mission-critical, I strongly discourage use of wait_for_light. Writing your own light start function is a useful programming exercise -- just avoid beeping in your own function.

-Jeremy Rand
Senior Programmer, Team SNARC (2012-2013), Norman Advanced (2010-2011), Norman HS (2008-2009), Norman North (2005-2007), Whittier MS (2003-2004)
2012-2013 VP of Tech, 2011 President, Botball YAC (2009-2013)
Mentor, Alcott and Whittier MS

RiverValley_Joe
Title: NooBot
Joined: 10/13/2012
Posts:
BotPoints: 19
User offline. Last seen 9 years 24 weeks ago.

Ah, thanks again.

I am concerned that there may be other undocumented things!

When you say "...repeatedly beeping", do you mean actually calling beep()?

Jeremy Rand
Jeremy Rand's picture
Title: Botball Youth Advisory Council
Joined: 04/03/2009
Posts:
BotPoints: 1168
User offline. Last seen 7 years 19 weeks ago.

Yes. wait_for_light calls beep repeatedly, and doing so seems to incur a risk of crashing. I was able to reproduce the bug by just putting beep() in a while(1) loop; a significant fraction of the times I tried this, the CBC would crash after a few minutes.

I have no idea why this happens, and apparently KIPR was unaware of the bug until I told them.

-Jeremy Rand
Senior Programmer, Team SNARC (2012-2013), Norman Advanced (2010-2011), Norman HS (2008-2009), Norman North (2005-2007), Whittier MS (2003-2004)
2012-2013 VP of Tech, 2011 President, Botball YAC (2009-2013)
Mentor, Alcott and Whittier MS

dwculp
Title: NooBot
Joined: 03/06/2011
Posts:
BotPoints: 9
User offline. Last seen 9 years 31 weeks ago.

Interesting, I wonder if the XBC had the same bug? I know my teams lost at least a few matches because the XBC would crash while waiting for the starting light and it seemed the longer the wait the higher the likelihood of crashing. I saw it happen to other teams but have never had it happen on a CBC,even though the CBC seems to be a LESS reliable platform than the XBC,

Jeremy Rand
Jeremy Rand's picture
Title: Botball Youth Advisory Council
Joined: 04/03/2009
Posts:
BotPoints: 1168
User offline. Last seen 7 years 19 weeks ago.

Ah, hey Mr. Culp! Good to see you here! (I hope you'll continue to visit the Community site?)

I never saw an XBC do it, but it occurs to me that shortly after the XBC was introduced to Botball, I did a firmware hack which replaced the beeping with a voice saying "Ready!" (I realize that's not useful, it was just for the fun of hacking). The voice effect never crashed the XBC, but on the GBA, the voice is done through separate code than the beep/tone commands, so any bug involving beep would have gone unnoticed by me.

What I can tell you is that when Matt, Braden, and I were first doing the CBC hacking, I tried to play .wav and .mp3 files on the CBCv1 via SSH (following the examples on the Chumby wiki), and occasionally I managed to crash the CBC by doing so. I therefore gather that this is either a Chumby bug relating to playing audio files, or perhaps a difference between the stock Chumby and CBC audio hardware which the Chumby firmware isn't expecting.

I wish I had more empirical data on this... as my paper notes, the entire process of noticing a crash to finding the source took about 2 hours, and was the night before the Oklahoma 2011 regional, so I didn't really have time to deal with it carefully.

-Jeremy Rand
Senior Programmer, Team SNARC (2012-2013), Norman Advanced (2010-2011), Norman HS (2008-2009), Norman North (2005-2007), Whittier MS (2003-2004)
2012-2013 VP of Tech, 2011 President, Botball YAC (2009-2013)
Mentor, Alcott and Whittier MS

dwculp
Title: NooBot
Joined: 03/06/2011
Posts:
BotPoints: 9
User offline. Last seen 9 years 31 weeks ago.

I will see how long I can hang around and answer questions. I am in a robot building mood right now (the fall always does that to me for some reason). I am alone (no wife and child) for a few days coming up soon and I got myself a Raspberry Pi some SN754410 motor drivers and some other components and I am going to see if I can hack it into a robot.

I may dig out our old XBC's and do some experimenting to see if I can reproduce the crash on a reliable basis. I know it happened to us in at least 3-4 actual games and a bit in practice. I also saw it happen to other teams, your experience leads me to believe that it may have been a sound issue.