Introduction

This project was canceled in favor of the C compiler
In this project you will build a high-level robot control language compiler that compiles down to byte codes for the Lego Mindstorm robot. There is an assembler and loader for the byte codes and we will use:
Those willing to use Windows might try Microsoft's robot studio to avoid having to mess with the physical device until you think your compiler is sort of working.
To give you an idea of what the byte codes look like and how to control a robot, here is an example that turns on both the left and right motor (outputs B and C), waits a little bit allowing the robot to move forward, and then reverses the motors for the same time. Finally it turns the robot motors off.
#include "NXTDefs.h" #define SPEED 25 #define MOVE_TIME 4000 thread main OnFwd(OUT_B,SPEED) OnFwd(OUT_C,SPEED) wait MOVE_TIME OnRev(OUT_B,SPEED) OnRev(OUT_C,SPEED) wait MOVE_TIME Off(OUT_BC) exit endt
nbc is the byte code assembler that translates NBC to .rxe files. These .rxe files can then be transmitted to the robot via USB/Bluetooth by the nxtcom program:
nbc t.nbc -O=t.rxe nxtcom t.rxe
Once on the robot, you can look in the program directory and tell the robot to execute t.rxe.
The high level language you build has the following instructions/capabilities:
move forward|backward Just turn both motors on move <direction> until event Set up task that turns off motors upon event turn left|right slow down one side by 50% for short time sensor read as var for ultrasonic(int) and touch(boolean) simple bytecode to read port and provide value x = <expr>; store expression value into global variable x open/close gripper simply bytecode instruction to operate gripper motors on <expr> do <stat> Create separate thread that loops until <expr> then do <stat>