NXT Programming


Lesson 8, sumo wrestling LEGO robot

In this lab session we will construct and program a sumo wrestling LEGO robot and at the end of the lab session the sumo wrestling LEGO robots will fight against each other in a sumo arena as described in Figure 1.

Figure 1 Two LEGO robots are ready to start a wrestling fight.
The fight ends when the loosing robot is pushed out of the arena
or is overturned. If this does not happend in 2 minutes the fight
ends as a draw.
Based on the ideas in Express bot, a fotobased building instructions for a base car with extensions, a simple LEGO sumo wrestler can be build (click on the image to see details):
The LEGO sumo wrestler consist of the four modules: a base car, a rear castor wheel, a light sensor and a pusher (click on the images to see details):
The four modules can be build after the Lego Digital Designer (LDD) building instructions: SumoBase.lxf, Rear.lxf, LightSensor.lxf, and Pusher.lxf. The four modules are assembled as follows with a motor and sensor wiring that prevent wires to stick out (click on the images to see details):

LEGO robot that exhibits several behaviors

Try out the program SumoBot.java on the sumo wrestler LEGO robot in the sumo arena. The classes needed to run this program are in Classes.zip. Observe the robot and try to identify the different observed behaviors that the robot exibits and the circumstances that triggers the different behaviors. Look at the LCD and try to interpret the output.

Behaviors as concurrent threads

Fred Martin describes how a control program for a robot can be structured according to the reactive strategy, [2]. He give en example of such a program with three different behaviors as shown in Figure 2. Each behavior is described with two components: a condition that triggers the behavior and actions that are performed when the triggering condition is true.

Figure 2 A reactive control strategy with three behaviors, [2].

The SumoBot program is also structured according to the reactive strategy. In the program there are three behaviors that are very similar to the behaviors in Figure 2. They are: AvoidEdge, Turn and Drive. If you look into the SumoBot.java program you will see three objects corresponding to the three behavors:

Drive d; Turn t; AvoidEdge ae; Each of these objects are threads created and started by the main program. Thereafter the threads run concurrently with the main thread. Each of these threads represent a single behavior: Drive makes the robot drive forward, Turn turns the robot a random angle on the spot every 5 seconds, and AvoideEdge try to avoid the edge of the sumo arena.

Look into the three classes and try to identify how the triggering condition is implemented in each of the classes and how the actions for each behavior is implemented.

Class Behavior

Each behavior thread is an extension of Behavior.java which is an extension of Thread. What is the purpose of making these threads daemon threads as done in the constructor of the Behavior class?

Figure 3 Behaviors have prioritized access to the motors by means of a suppress mechanism, [1].

In the Behavior class a suppression mechanism has been implemented so that only one behavior at a time can have access to the driving motors. When a behavior wants to have access the suppress method is called to suppress access from lower priority behaviors to the driving motors. The method release is called when the behavior no longer needs access. The suppression mechanism were inspired by Rodney Brooks subsumption architecture, [1]. An instance of the class SuppressNode is used by other behavior threads to suppress motor commands from this behavior. How is this instance variable used to implement a suppression mechanism in Behavior.java to obtain controlled access to the motors ? Compare this with the arbiter of Fred Martin, [2, page 214-218].

Add a behavior OverturnOpponent

Mount an ultrasonic sensor in front to detect the opponent and a motor to drive a mechanism that can overturn the opponent when the robot is close enough to the opponent. Look into base car with extensions for building inspiration.

Add a behavior OverturnOpponent to the SumoBot program.

References


Last update: 4-04-13