Session T2F Using an IR Network in a Robotic Competition Class

John T. Tester and Jerry Hatfield College of Engineering and Natural Sciences, Northern Arizona University Flagstaff, AZ [email protected], [email protected]

Abstract - The interdisciplinary sophomore design course – communication design and active interaction during the EGR 286 – utilizes design teams as part of an engineering project demonstrations: design learning process. This course constrains a robotic project to using only ® devices and the Robotic • Students understand the process of technical design. Command eXplorer (RCX). The instructors have • Students know how to develop complex system designs observed that students greatly improve their interest in the through experience. design process if a main component is robotic competition • Students understand how to work together in teams. events. Therefore, we have developed an infra-red (IR) • Students actively engage throughout the design network which enables inter-robot communications experience. independent of position and orientation and allows the student teams to partially control the robots during multi- Some characteristics of the course included: team competitions. A “satellite” RCX is established over the demonstration arena; its purpose is to receive and send • Exclusive use of parts for robot construction signals from the competing teams’ RCX systems and • Use of the Legos RCX control unit control network synchronization. The controlling software • Use of both RoboLab© [1] and NQC© [2] as the was developed using the public domain programming programming environment. language, “NQC©.” We present the advantages and • Team sizes limitations of this network environment, in the context of o 2–3 students per team in weeks 1–7 one design competition, entitled “capture the flag.” o 9–12 per team in weeks 8–15.

Use of competitive, team-against-team projects wherever Index Terms – Design Education, Engineering Education, • possible. Robotics, Legos, IR Network, NQC.

INTRODUCTION Legos are used in the course for a very simple reason: These literal building blocks allow for physical prototyping This paper documents the development of an innovative, without the student needing to have great mechanical skills. Infra-red (IR) communications network which supports Another equally important reason: The educational institution competitive projects using Legos-based robots. These types of does not need extensive manufacturing facilities dedicated to projects are prominent in the sophomore engineering design constructing classroom prototypes if Legos are the primary course at Northern Arizona University. The sophomore mechanical prototyping media. Use of the RCX allows a engineering design course is part of the “Design4Practice,” or compact, portable control unit to be used directly on small “D4P,” curriculum. D4P is a series of innovative robotic devices. undergraduate engineering classes which involve active Using Legos for physical prototyping is very prominent in learning laboratories for the students in each of their freshman, undergraduate engineering education. [3, 4, 5, 6]. The use of sophomore, junior and senior years. This program received Legos allows for a design process to culminate in a physical the 1999 Boeing Outstanding Educator Award in recognition product for even the earliest of undergraduate classes. Many of its quality and effectiveness in providing a well-rounded freshman engineering courses use Legos in this manner. [7, 8] engineering design education. The courses are team-taught However, Legos are not considered by many to be simply by faculty and local engineering practitioners who are “toys;” they can be used at higher levels with the use of a experienced in engineering design. robotic control unit, the Mindstorms® RCX. [9, 10, 11] Yet The ‘flagship’ D4P course may be considered the the RCX has the drawback of not allowing for (easy) network sophomore design course, EGR 286. In this course, students communication and control amongst multiple RCX modules participate in robotics-styled team projects over the entire on the same playing field. This paper documents our efforts to semester. The use of an extended team project is considered develop that control environment. by the faculty to be a primary means by which to immerse the students in an early, engineering practice-oriented design COURSE STRUCTURE process. The IR network was developed to accommodate the EGR 286 The following are learning outcomes for the course. The course structure. Towards the last five to seven weeks of the IR network supports these outcomes for the purpose of semester, this course requires teams of 9 to 12 students to 1-4244-0257-3/06/$20.00 © 2006 IEEE October 28 – 31, 2006, San Diego, CA 36th ASEE/IEEE Frontiers in Education Conference T2F-11 Session T2F work together to design a robotic system. The systems are University. Currently, Bricx is maintained and is freely demonstrated at the end of the semester in a scenario which is available on the internet [15]. as interactive and dynamic as possible. The instructors have observed that the students become CAPTURE THE FLAG REQUIREMENTS more actively engaged in this design process if the final The team project, “Capture the Flag,” requires that each team demonstration involves a competition between the teams. build two, semi-autonomous robots. These robots will be Also, if the students have some ability to interact with their arrayed against two other teams’ pairs of robots on an arena as robots, the students’ design process will involve them more schematically shown in Figure 1. Black electrician’s tape is deeply in the operational design of the systems. Though all of laid down onto “white board” material (identical to dry- our final project scenarios involve the interaction aspect, to marker wallboard). This high-contrast environment aids date only one has involved a direct competition aspect as well. robots to follow these lines with photosensors. Gold lines are This project is a version of the game, “Capture the Flag.” also placed on the board for line-following activities; the gold In order to accomplish these interactive, multi-robotic consists of shiny gold ribbon, attached via clear packaging demonstrations, the authors developed an IR network based tape. The “flag” can be any vertical contrivance; preferred is upon the RCX IR communications system. It was desired to an arrangement shown in Figure 2, where the flag is pulled out have both autonomous robotic behavior as well as direct of its holder by a robot. student interaction with the robots. Therefore, a communications protocol was necessary for communication between RCX units. Our IR network was developed to accommodate all the different final project demonstrations, but the Capture the Flag project will be used as an illustration of the innovative IR network.

RCX CAPABILITIES The Legos RCX programmable module uses the Hitachi H8/3292 microcontroller. It has three sensor ports utilizing analog to digital converters. Three actuator ports are also available, utilizing digital to analog converters. An infrared (IR) device allows bi-directonal communication with other RCX units or an IR “tower” (a PC IR interface). The IR tower is connected via either a DB9 RS232 port to the PC or (more recently) a USB port. The RCX is accessed physically through four buttons on its front panel; among their functions are power on/off, program run, and a program scroll. The last allows the operator to select up to five different, downloaded programs. A five-segment LCD display allows numbers to be illustrated FIGURE 1 as part of a program function. SCHEMATIC LAYOUT OF DEMONSTRATION ARENA (DIMENSIONS IN INCHES). PUBLIC DOMAIN “NQC” LANGUAGE The authors have used two programming languages in the class: Robolab and “NQC.” Robolab was originally developed from Labview; it has the advantage of being visually simple to learn, through icons. [12] However, we have increasingly turned to NQC for the more complex projects. This paper will address using NQC as the program for the IR network. NQC was developed by Dave Baum in the late 1990’s; it has the format and feel of the C programming language, but incorporates the necessary adaptations for controlling the RCX inputs and outputs [2]. Though NQC can be used by children, it also has the flexibility to be used for moderately complex FIGURE 2 THE “FLAG:” A LEGO TIRE ON AN AXLE, SUPPORTED IN A SIMPLE HOLDER. laboratory classroom experiments [13, 14]. NQC is open source, yet has some sophisticated support packages. The © The goal of the project is to have the teams defend their integrated development environment “Bricx Command flag inside their circular home ground and also attempt to Center” is used in EGR 286; it is an enhancement of Mark capture at least one opponent’s flag as well. Points are Overmar’s environment originally developed at Utrecht 1-4244-0257-3/06/$20.00 © 2006 IEEE October 28 – 31, 2006, San Diego, CA 36th ASEE/IEEE Frontiers in Education Conference T2F-12 Session T2F awarded and deducted for a team capturing a flag and loosing synchronization signal. All RCX IR transmissions follow a their own flag, respectively. There are many rules to this Time Division Multiplex protocol [19] in which each talker on competition; most of them are not covered here for sake of the network is assigned a specific time slot within each clock brevity. However, in general, all robots are required to stop cycle for transmission. All listeners on the network hear all upon the issuance of a “STOP” command from the instructor’s messages but respond only to those addressed to them; address RCX IR emitter. Similarly, the robots are allowed to begin information is combined with the message data. Error action upon reception of an IR “START” command. Lastly: detection is provided by the standard RCX IR message packet The students can have their robots perform custom behaviors structure [20]. by sending their own commands through RCX “Controllers.” Each “Robot” has assigned one dedicated RCX Controller The network implementation has the following basic from which it receives commands. The terms “Robot” and functions: “Controller” are used for discussion of specific entities in the Capture the Flag scenario. • Direct Control verses Sync (Network) Mode. Thus, in the demonstration, a minimum of six RCX are on • Synchronization of timing amongst all RCX units. Robots, six RCX are Controllers for these Robots, and one • Management of messages between Team Controllers RCX is controlled by the instructor. All of these thirteen RCX RCX and RCX robots. are operating in the IR network, coordinated by a fourteenth • Coordination of Messages from Instructor RCX to RCX; this coordinating unit is designated the “Satellite,” for it team RCX units. is suspended above the arena, such that its IR emitter may point downward, allowing for reception and sending of signals The students design the Controllers physically, such that to all the RCX units (generally pointed upward) in the field. the operator can provide an input into the RCX through its sensor input ports; typically, through pushbuttons that can IR NETWORK toggle through a series of numbers. The Controller will store An RCX can be controlled through reception of an IR the selected number in its message buffer, waiting for its message, encoded as simple numbers from 0 (null) through appropriate timing slot to become available, so that it can send 255. However, when multiple RCXs are broadcasting as part a signal to the Satellite. These timing slots are explained later of a competition, the individual messages can overlap, in this paper, and are illustrated schematically in Figure 3. resulting in garbled communications. Lego networking issues were being addressed as early as 1999 by Dave Baum, Kekoa Two modes for the network software were developed: Proudfoot, and others [16], eventually leading to development The Sync Mode and the Direct Mode. of the Lego Network Protocol that has been implemented in the BrickOS firmware for the RCX [17]. There are four Sync or Satellite Mode critical issues in networking: The “Sync Mode,” is the network mode. It is set up as a • Addressing simple timing mode, whereby each RCX has an opportunity in • Error detection time to either send or receive messages, depending upon its • Synchronization role in the overall network. This mode is established in the • Signal Availability Controller and Robot programs by simply defining the The Lego Network Protocol provides both addressing and variable “mode” to “1” in a #define statement, before error detection, but not synchronization. Networks consist of compiling and downloading to the RCX’s. talkers and listeners, and the talkers must be coordinated so The primary function of the Satellite in this mode is to that only one talker is active at any given time. Another synchronize timing for all the RCX units in the arena, as well critical issue with RCX IR communications is that the units as relaying signals from the Controllers, via the Satellite, to must be pointed toward each other; otherwise communications their respective Robots. is interrupted, giving rise to an intermittent network [18]. The overhead Satellite RCX sends out a coordinating Our objective was to develop a simple networking scheme clock signal every 2 seconds. The Controller RCX’s reset that would have the following characteristics: their timing loops with this simultaneous synchronization • Provide addressing, error detection, broadcast from the Satellite. In the Sync mode for the synchronization, and continuous signal Controller, the timing loops subsequently control their IR availability emissions (messages) to the Satellite. Each Control RCX unit has a unique, assigned, time slot, established after the • Work with the standard RCX firmware synchronization clock signal, in which to send a message. • Allow implementation in either Robolab or NQC This timing insures that no two RCX units will send at the Consistent signal availability and network same time. The timing is illustrated in Figure 3. synchronization was achieved by placing a downward- In this figure, C# represents one of up to 12 Controllers in pointing RCX above the robot playing field and requiring that the competition; R# represents the corresponding Robot all other RCX units point upward. The overhead or “satellite” controlled by C#. “Sat” is the Satellite RCX, and “C: Instr” RCX serves as a signal repeater and coordinates network represents the Instructor’s RCX unit. A Satellite sync signal is communications by periodically transmitting a clock 1-4244-0257-3/06/$20.00 © 2006 IEEE October 28 – 31, 2006, San Diego, CA 36th ASEE/IEEE Frontiers in Education Conference T2F-13 Session T2F sent to all RCX units, setting their timing sequence. Satellite message is also “heard” by all Robots. However: Subsequently, each Controller in turn sends a signal in their Each team’s pairs of Controller/Robot units are issued only appropriate time slot. If a signal is sent from a Controller, the specific numbers that they may use as signals. No Satellite relays that signal to the appropriate Robot, in the Controller/Robot pair have the same numbers to process subsequent time slot. (except for the overall STOP and START command numbers). Therefore, the Robots ignore numbers in messages that are not assigned to them. This restriction also makes it fairly simple for the class instructors to check their programs prior to or during the competition.

Direct Mode The simpler mode is the “Direct Mode.” It is established in the Controller and Robot NQC programs by simply defining the variable “mode” as “0” in a #define statement, before compiling and downloading to the RCX’s. The overhead Satellite RCX is not required in this mode. This mode is intended for limited testing by one team and with one Controller/Robot system; multiple Controllers and Robots will interfere with each other if they are simultaneously operated in the direct mode. The Controller RCX unit transmits a signal that is directly processed by the Robot RCX control unit. The Controller functions essentially as a remote- control device in this case. The key here is that the Robot responds directly to the messages from the Controller and does not wait for a relayed signal from the Satellite. The Direct Mode is handy for trouble-shooting programs in both the Controller and Robot systems. It allows for direct and immediate communication from the Controller RCX to the Robot RCX, without the Satellite. Students can therefore FIGURE 3 test their systems in rooms that do not have a Satellite RCX, TIMING OF THE NETWORK COMMUNICATIONS. allowing for flexibility of the students as part of their study It should be noted that, in the Capture the Flag habits. competition, only three teams, and thus, six Controller/Robot pairs, are in the arena during the event. Therefore, half of the IMPLEMENTATION 12 timing slots are not used in a given completion round. However, this arrangement allows for any combination of The IR Network is implemented through three separate three teams to compete against each other in different rounds, programs: as they will always have their dedicated slots. There is also a • Satellite: satellite-repeater.nqc “final round,” where the best team from a particular three- • Robot: robot_module.nqh team competition bracket competes against another team. • Controller: controller_module.nqh Therefore, combinations of team Robots and Controllers cannot be anticipated ahead of time under this concept. As noted earlier, in the competition each team designs In general, during any particular competition event, there Robots with an RCX unit and Controllers with separate RCX are actually large stretches of time in which no signals are sent units. Each Controller is dedicated to controlling one of the from any Controller. The network, however, still allows the Robots. The NQC program for each of these RCX units must time slots to be reserved for each Controller/Robot incorporate an appropriate header (.nqh) module, according to combination; thus, the cycle time never changes. its function (Robot or Controller). The header module files The Satellite RCX unit processes signals from the are compiled from the Bricx active directory when the general Controller RCX units by NQC programs are compiled. The contents of this header 1) receiving the message according to the timing, module file thus incorporated into the NQC program during 2) modifying the message slightly to identify it as a the compilation process through an statement in relayed message, and #include 3) then sending the message out to the appropriate Robot. the main Robot or Controller NQC program. Note that the Controller of interest is also easily “heard” The header module files contain all the communications by other Robots on the field. That message is not processed coordinating code and are not changed in any way by the because these Robots anticipate a relayed signal to be sent students. The students are instructed to incorporate the from the Satellite; hence the action in item 2), above. The following into their Controller .NQC program: 1-4244-0257-3/06/$20.00 © 2006 IEEE October 28 – 31, 2006, San Diego, CA 36th ASEE/IEEE Frontiers in Education Conference T2F-14 Session T2F This inconsistency requires the students to have a series • #include “controller_module.nqh” of robot “behaviors” programmed into their RCX units. • #define mode M Nevertheless, they can select these behaviors interactively as • #define slot S the competition is underway. The teams usually develop a combination of complex behavior and simple behavior The Controller has two module interface variables defined programs. Complex behaviors may be considered as robot activities which combine sensor input with robot outputs, from the controller_module.nqh header file: including line-following, line-avoidance, obstacle detection, “ ” and “ .” The first stores the value command transmit picking up flags, and destructive actions (applied towards (numerical) of the message to be sent. The latter is set to enemy robots). Simple behaviors might be considered as either true or false; true if the Controller has a robot activity only requiring timed outputs; such behaviors command value to send, and false if it does not. could include moving in a particular direction for a few Two subroutines are available from the Controller header seconds, turning left, right, and simply sitting motionless until file: listen() and talk(). The listen subroutine is signaled to do otherwise. The students use combinations of started in the Controller .NQC program, so that it is ready to these types of programs to achieve their objectives of accept the sync signals from the Satellite. The talk capturing enemy flags and defending their own flag from subroutine is started in the program such that, whenever invaders. transmit is set to true, the Controller RCX will send the The issuance of immutable header files for the Robot and value stored in the command variable. Controller RCX program compilation process allows for a The Robot .NQC program is to have the following uniform standard of communication across the competing incorporated: teams. It also allows the instructors to monitor the signals during the competition, if desired. • #include “robot_module.nqh” Most importantly: By providing “canned” header files for • #define mode M the students’ use in communication programming, the sophomore course allows a lower skill level of programming The Robot module interface also uses the command expertise than would otherwise be required. This objective is variable to store the transmitted message from the critical in the makeup of the class, as it is composed of Controller/Satellite relay. Since the Robot never sends, it does students across four different discipline areas: Mechanical, Electrical, Civil and Environmental Engineering. Several of not need the transmit variable. The listen() subroutine is started in the Robot .NQC program, the same as these discipline areas do not require any programming courses for the Controller .NQC program, described above. prior to the EGR 286 offering. By standardizing the As noted earlier, student teams are assigned a range of communication protocols and headers, all students are able to numbers that they can use in transmitting information to their participate more easily in the design process. Robots. Though they have a timed slot authorized, by The use of essentially 12 predefined timing slots in the restricting the students to using only a certain set of unique network may be considered as reserving too much timing numbers, the students are assured that they do not process space, when in the Capture the Flag competition, only 6 other team signals if they are testing in Direct Mode in the Controller/Robot sets are active during the event. Response same room. As the RCX only communicates numbers 1 time could be faster if more creative programming allowed through 255, the total amount of numbers available to each any number of Controller/Robot pairs on the field, and team is based upon the total number of teams. For example, 12 reducing the cycle time accordingly. However, the instructors Controller/Robot pairs in a class results in around 20 numbers wanted the specified delay for all any of the Robots in the per team. At least two numbers are reserved for the arena, as specified earlier, to demonstrate necessary robotic instructors’ use alone, such that they use numbers for the delay issues. They often illustrate this problem with the universal “STOP” and “START” commands to all the Robots. NASA Mars Rovers’ communications delay problem, due to Note that all of the Robots and Controllers header files have the distance between Mars and Earth. The students readily “STOP” and “START” numbers hard-coded into their understand this discussion. programs, such that all will truly process these two commands An additional aspect of this network is its simplicity and upon their issuance from the instructors’ RCX. its flexibility. The Capture the Flag project requires only one- way communication between the RCX Controllers and the DISCUSSION Robots, but a slight modification to the Robot header module and assignment of timing slots would allow the robot units to The communications system discussed above has inherent communicate back to the Controllers or to other Robots, if delays ranging up to 2 seconds from the time of an operator such functions are needed for other project concepts. asking for a message to be sent to the time it is received at the The developers of this network protocol also wanted as destination robot. This uncertain delay has unique advantages simple a program structure as possible, not only for the in the education of robotic design. The students can have students, but for the instructors. The EGR 286 class is taught some near-direct control of the robots, yet still must anticipate by faculty of all disciplines in our Engineering Departments: some delay in reaction time. 1-4244-0257-3/06/$20.00 © 2006 IEEE October 28 – 31, 2006, San Diego, CA 36th ASEE/IEEE Frontiers in Education Conference T2F-15 Session T2F Mechanical, Electrical, Civil, and Environmental Engineering. [8] Shih, A. and Hudspeth, M. "Using the LEGO robotics kit as a teaching These faculty members have a wide range of programming tool in a project-based freshmen course," Proceedings of the ASEE Annual conference and exhibition, session 1353, 2001. expertise, from highly developed, to nearly non-existent. By keeping the programming simple, the authors hope to appeal [9] Campbell, M.I. "Teaching machine design through product emulation" Proceedings of the ASEE Annual conference and exhibition, session to the entire faculty in using this network program as required. 2366, 2002. Lastly: Capture the Flag is the project that has thus far provided the most excitement to the EGR 286 class, and it is [10] Moor, S.S., Piergivanni, P., and Keyser, D. "Design-build-test: flexible process control kits for the classroom," Proceedings of the ASEE Annual only possible with use of the IR network concept. However, conference and exhibition, session 1526, 2003. there are other projects which have used the network. These projects can have as few as two Controller/Robot [11] Klassner, F.; Anderson, S.D.; : not just for K-12 anymore, Robotics & Automation Magazine, IEEE v. 10, n. 2, June combinations, all the way up to 12 Controllers/Robots 2003 pp 12-18 simultaneously operating. By keeping the IR network fairly [12] Cyr, M., Miragila, V., Nocera, T., Rogers, C.; “A Low-Cost, Innovative standard, these different projects can be developed with Methodology for Teaching Engineering Through Experimentation,” engineering design as the main focus for the class, instead of Journal of Engineering Education, April 1997, pp 167-171. merely programming. [13] McComb, G.; “Using `' to Program LEGO Mindstorms,” Poptronics, v. 1, n. 4, Apr 2000, pp 52-56. FUTURE WORK [14] Heck, B.S.; Clements, N.S.; Ferri, A.A.; “A LEGO experiment for A new version of the Lego RCX, called the NXT, is available embedded control system design,” Control Systems Magazine, IEEE, v. in August 2006 [21]. This new product will be a major 24, n. 5, Oct 2004, pp. 61-64. revision to the Lego system and will provide wireless [15] http://bricxcc.sourceforge.net/; Current Author: John Hansen; Original networking capability and new types of sensors and actuators. Author: Mark Overmars; Accessed March 20, 2006. We look forward to exploring its capabilities. However, we [16] http://news.lugnet.com/robotics/rcx/legos/?n=180&t=f&v=a; Authors: have a large investment in RCX systems and will probably Dave Baum, Kekoa Proudfoot, et.al.; Accessed May 22, 2006. continue to use them in our classes. We will thus continue [17] http://lnphost.sourceforge.net/brickos.html; Author: Stephan Höhrmann, development of interactive projects that use our IR networking Accessed May 25, 2006. system. [18] Frisk, J.; Vesterlund, P.; Browall, A; Johansen,P.; “Implementation and evaluation of routing protocol for intermittently connected networks on CKNOWLEDGEMENTS A LEGO Mindstorms;” June 10, 2004; http://www.ludd.luth.se/~krossarn/ smd147/finalreport.pdf; Accessed May 22, 2006. This research was accomplished in part under a grant by the William and Flora Hewlett Foundation, as part of the [19] http://www.networkdictionary.com/telecom/tdm.php; Accessed: May Engineering Schools of the West Initiative. 24, 2006. If any reader would like the NQC and NQH program [20] http://graphics.stanford.edu/~kekoa/rcx/protocol.html; Authors: Kekoa files, they are freely available. Please contact the authors via Proudfoot and Dave Baum; Accessed April 7, 2005. email for these files. [21] http://www.lego.com/eng/info/default.asp?page=pressdetail&contentid= 17278&countrycode=2057&yearcode=&archive=false NXT info; REFERENCES Accessed May 25, 2006

[1] Cyr, M., Mindstorms for Schools, Using Robolab. Tufts University, Boston, MA: Education Division. 2002. [2] Baum, D., Dave Baum's Definitive Guide to Lego Mindstorms, Apress, 2000. [3] Pomalaza-Raez, C., Groff, B. H., “Retention 101: Where Robots Go…Students Follow,” Journal of Engineering Education, January 2003, pp 85-90. [4] Jolley, W., Rencis, J., Cobb, E. and Hagglund, R. "Incorporating a LEGO fourbar mechanism project in undergraduate dynamics" Proceedings, 32nd ASEE/IEEE Frontiers in Education Conference, Boston, MA, November 2002.. [5] Flikkema, P. "Learning Embedded and Real-time systems via low-cost mobile robots," Proceedings, ASEE Annual conference and exhibition, session 1332, 2001. [6] Wang, E. L., LaCombe, J., and Rogers, C., “Using LEGO® Bricks to Conduct Engineering Experiments,” Proceedings of the ASEE Annual conference and exhibition, session 2756, 2004. [7] Goff, M. and Vernon, M. "Using LEGO RCX bricks as the platform for interdisciplinary design projects," Proceedings of the ASEE Annual conference and exhibition, session 3425, 2001.

1-4244-0257-3/06/$20.00 © 2006 IEEE October 28 – 31, 2006, San Diego, CA 36th ASEE/IEEE Frontiers in Education Conference T2F-16