Robot class


Although the Robot class is not formally a part of the simulator API, it should provide a public interface whose components are those relied upon by the rest of the program. For example, in order for this class to obtain references to the Motor and Sensor objects, it needs to accept a CurrentRobotState reference in its contstructor's argument list. Likewise, a reference to the MessagePasser object needs to be accepted as well (as the second, and final argument to the constructor). These references will be passed to the Robot class constructor, so if you do not define the constructor appropriately there will be exeptions thrown at runtime. It is also important that the public boolean active field, and the killControl() method be present; these allow the program to cleanly terminate the Robot thread. The Robot constructor and the killControl() method mentioned above are crucial to the successful creation and termination of the Robot thread. If you see errors generated when you run your controller, or if it does not halt (in the case the entire program may freeze), double check these methods in your code.

Because this class extends the Thread class, it is important that you implement a run() method: public void run() {your code here}. If you are unfamiliar with Java threads, you may want read some reference material to gain a better understanding of how the Robot.class functions at an abstract level within the simulator program.

NOTE: See the Controller section off the main help window for specific Robot.class implemenation details.


Back Home