Subject:
|
Re: Competitive MINDSTORMS: Now in a store near you!
|
Newsgroups:
|
lugnet.robotics
|
Date:
|
Mon, 23 Aug 2004 17:13:25 GMT
|
Viewed:
|
1302 times
|
| |
| |
In lugnet.robotics, Brian Davis wrote:
> In lugnet.robotics, David Perdue wrote:
>
> > Yes, from what you say, both logical and bitwise AND would
> > work.
>
> Given what you say in the boxed text, do you ever use logical AND in a
> program?
Truthfully, I rarely use any type of AND, so I can't really say! :)
> > > I don't understand is why ever time through the while(true)
> > > loop here, it starts by starting the counter-rotating wheels
> > > and starting up the task Spin... but I must have missed the
> > > code that stops the task Spin...
> >
> > there isn't code that stops the counter-rotating wheels or
> > task Spin! They are turned on just once, and then are never
> > turned off again. This also means that the program goes through
> > the while(true) loop in task Crash only once.
>
> Well, here's the code in question. I've removed blank lines, but the spacing
> & punctuation is preserved:
>
> task Crash()
> {
> SetPriority(1);
> while(true)
> {
> OnFwd(Front);
> start Spin;
> until(Timer(1)>TOUCH);
> acquire(ACQUIRE_USER_1)
> {
> Win();
> PlaySound(SOUND_CLICK);
> }
> }
> }
>
> It seems to me that upon starting the task it falls into an infinite loop
> (while(true)). That (A) starts up the front wheels and monitoring task, (B)
> waits until the watchdog timer is exceeded, (C) grabs control, reverses briefly
> & "rams" forward (for those without the listing, that's what the in-line
> function Win() is suppossed to do), (D) releases control, and then restarts the
> loop, which begins with (A).
> Again, this would certainly work, but it seems a strange way to code it. Why
> not just put the OnFwd and start Spin commands just ahead (& outside) of the
> while(true) loop? Or for even cleaner code, have Spin do it's own housecleaning
> (i.e.- make the first line of Spin an OnFwd command).
Excellent observation! I guess, when I was creating the code, I just decided to
put that code in with the Crash task. You can however, place it elsewhere where
it won't get repeated many times.
> Also, is there a reason that the acquire statement is indented (it is in the
> original code as well)? It would seem that it follows, not is controled by, the
> until statement, yes? I just fear some of this could be slightly confusing.
There's not really a highly important reason that I indented the acquire
statement - and it is true that it is not controlled by the until statement.
Thanks,
David J. Perdue
www.davidjperdue.com
www.davidjperdue.com/competitivemindstorms
|
|
Message is in Reply To:
| | Re: Competitive MINDSTORMS: Now in a store near you!
|
| (...) Given what you say in the boxed text, do you ever use logical AND in a program? (...) Well, here's the code in question. I've removed blank lines, but the spacing & punctuation is preserved: task Crash() { SetPriority(1); while(true) { (...) (20 years ago, 23-Aug-04, to lugnet.robotics)
|
29 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|