help to rookie teams

Posted by Stephen at 1/25/2001 1:57 PM EST

Other on team #122, NASA Knights, from Grafton High School (Robotics team is at NHGS) and NASA.

This post is meant as a programming tip for rookie teams. For the past few years (well, this is what I’ve been told, this is actually my first year at FIRST) my team has used a button on the robot to reverse the controls; in escence switching the motors you send the certain joystick controls to. This helps to stop the disorientation you get when the robot is turned around and you have to mentally swap everything around. Well, now to the point: as you now, you are only permited 26 varibles in pbasic, and most teams (even mine last year) use a temp variable to swap:

  • temp = a
  • a = b
  • b = temp
    but, this wastes a varible. Here is very simple way to swap the varible using bitwise operations:
  • a = a ^ b
  • b = a ^ b
  • a = a ^ b
    If you want help understanding the logic, or have problems implementing this code - send me an e-mail at [email protected]

Posted by Joe Johnson at 1/25/2001 8:50 PM EST

Engineer on team #47, Chief Delphi, from Pontiac Central High School and Delphi Automotive Systems.

In Reply to: help to rookie teams
Posted by Stephen on 1/25/2001 1:57 PM EST:

I am not a computer science guy but I play one on TV…

…in any case, I love the trick you posted. Is this
the kind of thing that they teach in all those CS
classes I never took but thought I could get by
without? If so I regret my not taking more Computer
Science class even more than I did before.

Ah well…

Joe J.

P.S. With “scratchpad” RAM on the STAMP2SX chip, the
need for such tricks is much reduced than it was prior
to Innovation First taking over the controller, but I
imagine that our code will grow over time to even use
up the 63 bytes available in the scratchpad. I will
keep your trick in my pocket to have it ready when that
day comes. JJ

Posted by Anton Abaya at 1/25/2001 10:39 PM EST

Coach on team #419, Rambots, from UMass Boston / BC High and NONE AT THE MOMENT! :(.

In Reply to: Cool trick
Posted by Joe Johnson on 1/25/2001 8:50 PM EST:

: I am not a computer science guy but I play one on TV…

: …in any case, I love the trick you posted. Is this
: the kind of thing that they teach in all those CS
: classes I never took but thought I could get by
: without? If so I regret my not taking more Computer
: Science class even more than I did before.

: Ah well…

: Joe J.

: P.S. With “scratchpad” RAM on the STAMP2SX chip, the
: need for such tricks is much reduced than it was prior
: to Innovation First taking over the controller, but I
: imagine that our code will grow over time to even use
: up the 63 bytes available in the scratchpad. I will
: keep your trick in my pocket to have it ready when that
: day comes. JJ

while we CS people learn to do these tricks… ur cooking some brand new scheme of using drill motors to do wonderful things…

:slight_smile:

-anton

Posted by Stephen at 1/26/2001 10:59 AM EST

Other on team #122, NASA Knights, from Grafton High School (Robotics team is at NHGS) and NASA.

In Reply to: Cool trick
Posted by Joe Johnson on 1/25/2001 8:50 PM EST:

Thank you, I greatly appreciate your comments. If anyone is interested, I will have this posted in the white papers section in a few days with the complete logic of how it works.

: I am not a computer science guy but I play one on TV…

: …in any case, I love the trick you posted. Is this
: the kind of thing that they teach in all those CS
: classes I never took but thought I could get by
: without? If so I regret my not taking more Computer
: Science class even more than I did before.

: Ah well…

: Joe J.

: P.S. With “scratchpad” RAM on the STAMP2SX chip, the
: need for such tricks is much reduced than it was prior
: to Innovation First taking over the controller, but I
: imagine that our code will grow over time to even use
: up the 63 bytes available in the scratchpad. I will
: keep your trick in my pocket to have it ready when that
: day comes. JJ

Posted by Patrick Dingle at 1/27/2001 8:15 PM EST

Other on team #639, Red B^2, from Ithaca High School and Cornell University.

In Reply to: help to rookie teams
Posted by Stephen on 1/25/2001 1:57 PM EST:

maybe next year innovation FIRST will enable us to download COMPILED code? It would be much faster and we could use programming languages that don’t assign the universal AND symbol (^) to mean exclusive or (XOR)! Anyway, thanks for the post. I had seen the trick before but forgot all about it.

Patrick

: This post is meant as a programming tip for rookie teams. For the past few years (well, this is what I’ve been told, this is actually my first year at FIRST) my team has used a button on the robot to reverse the controls; in escence switching the motors you send the certain joystick controls to. This helps to stop the disorientation you get when the robot is turned around and you have to mentally swap everything around. Well, now to the point: as you now, you are only permited 26 varibles in pbasic, and most teams (even mine last year) use a temp variable to swap:
: - temp = a
: - a = b
: - b = temp
: but, this wastes a varible. Here is very simple way to swap the varible using bitwise operations:
: - a = a ^ b
: - b = a ^ b
: - a = a ^ b
: If you want help understanding the logic, or have problems implementing this code - send me an e-mail at [email protected]

Posted by Matt Leese at 1/29/2001 3:45 PM EST

Other on team #73, Tigerbolt, from Edison Technical HS and Alstom & Rochester Institute of Technology.

In Reply to: Re: help to rookie teams
Posted by Patrick Dingle on 1/27/2001 8:15 PM EST:

^ as the universal and? The only thing remotely close to that that I know of is the upside down U used as the union of operator. PBasic gets its usage of ^ from the C programming language which is more or less the most used programming language (this includes C++ which is just a superset of C). The universal AND usually happens to be &, not ^.

Matt