To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 22699
22698  |  22700
Subject: 
Re: Competitive MINDSTORMS: Now in a store near you!
Newsgroups: 
lugnet.robotics
Date: 
Sun, 22 Aug 2004 03:18:24 GMT
Viewed: 
1237 times
  
In lugnet.robotics, Steve Hassenplug wrote:

I was looking over the robots & code listed in your
"bonus chapters"

   I finally downloaded and read the bonus chapters as well, and (of course) got
confused. I've only been using NQC for a little over a year, so it could be my
inexperience, but I knew C for several years prior to using NQC, so I'm not a
complete novice.
   On pg37 of bonus chapter 2, you have some code including the line of code and
a highlighted box below it:

   until(LBump<100&RBump==1);

   "Notice the ampersand (&) in this task. This is the AND operator
    in NQC. Here is another example... There are two types of AND:
    & and &&. The former, the one we use in this program, is called
    bitwise AND and has no restraints on the types of arguments that
    can be used with it. The latter example is called logical AND
    and is constrained to constants only (such as 5, 27, OUT_A)."

First, while the above code seems to work, it would seem this is only due to the
order of precedence (relational operators being slightly higher in precedence
than the various flavors of ANDs and ORs). Second, using a logical AND here
works just fine, as (a) it is comparing two constants (both experssions
'LBump<100' and 'RBump==1' are evaluated to either the constant 'true' or
'false', and this will be done before any AND comparision), and (b) at least as
of NQC 2.5a4, any AND or OR operators have no restraints on argument types.
   So, why use a bitwise AND here? You seem to do this throughout, even though
I've never had a problem using logical AND within control commands (or in lots
of other places, like variable assignments).

   Another thing that confused me was in bonus chapter 1. On pg36, you give the
listing of the task 'crash'. What 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, or stops the counter-rotating wheels. Where is this - what have I missed?

   I do like the trick of using ACQUIRE_USER_1 instead of ACQUIRE_OUT_A (or
similar) which would stop the wheels. That's a technique I may "borrow" for Sumo
6 in Ann Arbor.

--
Brian Davis



Message has 1 Reply:
  Re: Competitive MINDSTORMS: Now in a store near you!
 
(...) Yes, from what you say, both logical and bitwise AND would work. My book is only a guide, so although I use bitwise, you can feel free to use logical. (...) The trick is, there isn't code that stops the counter-rotating wheels or task Spin! (...) (20 years ago, 23-Aug-04, to lugnet.robotics)

Message is in Reply To:
  Re: Competitive MINDSTORMS: Now in a store near you!
 
(...) David, I was looking over the robots & code listed in your "bonus chapters", and I must confess, I'm a bit disappointed. Maybe I'm missing something, but I'd be interested to know how these robots have actually done in competition. Maybe you (...) (20 years ago, 19-Aug-04, to lugnet.robotics)

29 Messages in This Thread:






Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR