Hello all,
What my question to the group is, has anyone used multiple tasks to get a job done? I would like to hear about your experiences.
While I am not too fond of the RIS 2.0 graphic programming metaphor (I program in "syntax based" languages like C for a living ;-) I still find myself using it. Mainly I use RIS 2.0 when I wait too long to program a robot for a contest and end up having to whip something together quickly. The syntax based languages like RobotC, while faster and more precise, require more debugging than RIS programs in general.
I have one usage to share with you all. At our last Chibotica I had an Advanced Table Top entry named Anyway III (Anyway was disassembled for parts after an earlier contest and Anyway II launched off the end of a table ;-) which was programmed in RIS 2.0 for the above mentioned reasons. This is the robot I demonstrated at our first meeting.
In the ATT contest a banquet table is has three zones made using white electrical tape. Each zone is about 11" long with Zone A at one end, Zone B at the other and Zone C somewhere in the middle. The robot must travel from Zone A to Zone B, then back to Zone A, then to Zone C and finally back to Zone A. Sounds confusing, but it is pretty simple (see http://www.chibots.org/drupal/?q=node/26 for details) once you draw it on paper.
The technique I chose to use was to count lines as I went across the table and use this information to determine when I entered a Zone and when to reverse direction or stop. In past contests I wrote a MyBlock that would detect a line and then just inserted as many of these blocks as I needed to "count" lines. Unfortunately this technique would run out of storage under RIS 2.0 so I had to make some concessions to get it to fit. I won't bore you with the details, but suffice it to say I ended up with a robot that would briefly brake every time it went over a line. It didn't stop, it just pulsed which you could hear and also slowed it down.
For this contest I used a second task attached to the light sensor that incremented a global variable every time the light sensor passed over a line. In my main task I would reset the global variable to 0 and then wait for it to hit the value I was looking for (i.e. the number of lines that should be crossed) before performing any action like stopping or reversing. This made for a very simple two part program that was very easy to debug and fit nicely into the RCX memory.
Anyone else found a clever use for multiple tasks? They seem like a pretty powerful tool.
Take care,
KJohn