Chapter 2: The Scripter |
Iris.4 Mobile Robot Manual |
The Scripter is a computer program that allows you to create wheel motion scripts to control Iris's wheels, and arm behaviors to control Iris's arms. The Scripter can be run from within the Virtual Robot Lab by clicking the Scripter icon at the Computer Desk. To write scripts for the real, physical Iris, a different, but in many ways functionally equivalent, computer program is used. This virtual chapter will teach you the foundational concepts associated with the Scripter. Later in the lab, as you need to make use of the Scripter's various features, you will be directed to sections within the Scripter Instruction Manual that provide details for operating the program.
A script, or more specifically, a robot control script, is an ordered list of instructions that another computer component (either hardware or software) follows to perform a task. Iris's scripts contain instructions that can be interpreted as, for instance, "turn your left drive motor on for 10 milliseconds, then rotate servo 2 and servo 3 85 degrees, then turn on your right drive motor for 8 milliseconds...", and so on.
Thus, the Scripter is used to write scripts, which the Servo Controller Interface reads and translates. Next, the Servo Controller Interface sends the translated step-by-step instructions over the USB port to the Servo Controller. Finally, the Servo Controller physically carries out the script's instructions. A sample script that controls Iris's wheels and arms looks like this:
    01. AUX 1, 2 ON
    02. WAIT 50
    03. AUX 1, 2 OFF
    04. AUX 1 ON
    05. WAIT 45
    06. AUX 1 OFF
    07. AUX 1, 2 ON
    08. WAIT 100
    09. AUX 1, 2 OFF
    10. AUX 2 ON
    11. WAIT 45
    12. AUX 2 OFF
    13. AUX 1, 2 ON
    14. WAIT 50
    15. AUX 1, 2 OFF
    16. MOVE 1 to 0, 2 to 0, 3 to 0, 4 to 0, 5 to 0
    17. MOVE 4 to 1400
    18. MOVE 1 to -700, 2 to 1325
    19. MOVE 5 to -1400
    20. MOVE 4 to -1400
    21. MOVE 5 to 1204
    22. MOVE 4 to 950
    23. MOVE 1 to 1000, 2 to 0
    24. MOVE 4 to -1400, 5 to -1400
    25. MOVE 1 to 0, 4 to 0, 5 to 0
Each line of the script contains a text instruction that will eventually be converted into a digital instruction for the Servo Controller to carry out. On line 01, the code AUX 1, 2 ON tells the Servo Controller to turn on power to auxiliary outputs 1 and 2. Each of these auxiliary outputs controls one of Iris's drive motors via a relay, thus this command means: "Turn on both drive motors." Line 02, WAIT 50, tells the Servo Controller to do nothing for 50 tenths of a second (which is equivalent to 5 whole seconds). During this time, the drive motors will run, driving Iris forward for 5 seconds. Line 03 tells the Servo Controller to turn both motors off. Lines 4 - 15 give more instructions to the drive motors.
Line 16 makes use of the MOVE command. The MOVE command is used to rotate the individual servos that comprise Iris's arms. For instance, line 16, MOVE 1 to 0, 2 to 0, 3 to 0, 4 to 0, 5 to 0, tells the Servo Controller to send electrical impulses to servos 1, 2, 3, 4, and 5, such that they all move to position 0. When executed, this instruction results in all of the servos of Iris's left arm moving to the neutral position, which means Iris's arm will be sticking straight out. Line 17 instructs the Servo Controller to tell servo 4 to move to position 1400, which means that servo 4 should rotate to 90 degrees clockwise from the neutral position. Likewise, a MOVE 4 to -1400 command would mean that servo 4 should rotate 90 degrees counter-clockwise from the neutral position. A command such as MOVE 4 to 700 would mean that servo 4 should rotate 45 degrees clockwise from the neutral position. As you might have figured out, the text of the script uses the range -1400 to +1400 when referring to servo rotations, whereas a person usually measures servo rotations in degrees (-90 to +90). A simple calculation will convert an instruction using the -1400 to +1400 method into a command using the -90 degree to +90 degree method.
Ultimately, the Scripter let's programmers use a Graphical User Interface to produce scripts, like the sample above. These scripts can be saved to the computer's hard drive, just like a word document or an MP3 file. When given the order, the Servo Controller Interface will read in a script from a file, translate it into special computer code (1's and 0's), and send it over the USB cord to the Servo Controller, which then carries out the instructions.
The Scripter operates in one of four modes, depending on the task you want to accomplish:
Create/Edit Wheel Motion Mode
Lets you create and edit wheel motion scripts that control how Iris drives around the lab.
Screenshot of Create/Edit Wheel Motion Mode:Create/Edit Arm Behaviors Mode
Lets you generate arm behavior scripts that make Iris's arms move.
Screenshot of Create/Edit Arm Behaviors Mode:Combine Arms & Wheels Mode
Wheel Motion Scripts and Arm Behavior Scripts are combined in the Combine Arms & Wheels mode create a single, unified script file that controls both wheel motion and arm movement.
Screenshot of Combine Arms & Wheels Mode:Preview Scripts
Lets you preview your scripts within a virtual version of the virtual lab. (That's two degrees of virtual reality, for those keeping track! Thus, you can test your scripts in a virtual, virtual lab without damaging Iris in the real virtual lab ;-)
Suppose you wanted to create a script that made Iris drive up to a table and draw an X on a Tic Tac Toe board. How would you go about creating the script?
To begin, you could start by using the Scripter's Create/Edit Wheel Motion mode to create a script that drives Iris up to the table. You would then give this script a name and save it. Next, you could enter the Scripter's Create/Edit Arm Behaviors mode and generate the arm motions to draw the X on the game board; this script would also be saved. Then, using the Combine Arms & Wheels mode, you could combine the wheel motion script with your arm behavior to create a new, unified script. Finally, you could test the new script using the Scripter's Preview Scripts mode to ensure that Iris drives to the correct position and draws an X in the right spot on the board.