Final Project Library Reference

We've combined your problem set code into a set of libraries for the final project. To develop in RAM, you must first load the libraries into Flash with the command:

robot.program('com?','math2.py','velocity.py','pose.py','motion.py','leds.py','neighbors.py','quidditch.py')

You can then connect to the robot and use the 'run' command to load and run your program from RAM. Note that you can unplug the USB cable from the robot after the program is in RAM. It will continue to run, but if you reset the robot, it will be cleared. You can load your program and the libraries into flash with the command:

robot.program('com?','your_program.py','math2.py','velocity.py','pose.py','motion.py','leds.py','neighbors.py','quidditch.py')

Your program must be the first file in the list.

You are not allowed to edit these libraries! However, you are encouraged to read them for reference. If you find problems, or can't do something that should be supported, let us know. We will upgrade the library files for you, and release them to the class.

The math2 library

This library contains extra math functions.

The velocity library

This library contains functions to set and measure the velocity of the robot's motors. The update function runs the control loop, and must be called periodically to properly control the velocities.

The pose library

This library contains functions to estimate the pose (x, y, theta) of the center of the robot. The update function runs the estimator, and must be called periodically to accurately estimate the pose of the robot.

The leds library

This library contains functions to blink the LEDs with different patterns and animations. The update function runs the animations, and must be called periodically to produce smooth animations.

The motion library

This library contains functions to move the robot to a goal position. The move_to_goal() function controls the motion, and must be called periodically. Usually, the function would be wrapped in a behavior, as it only needs to be called when the robot is driving towards a goal position.

The neighbors library

This library contains functions to communicate with neighboring robots. The update function transmits and receives messages, and must be called periodically to accurately estimate the pose of the robot. The orientation system transmits an extra message for each neighbor, and should be enabled only if you need orientation information. You will not need orientation for robot rQuidditch.

The way to interact with the neighbor system is as follows: call neighbors.init() once, using the provided value for "nbr_period" and "False" for "orientation_enable". Get the full list of neighbors by using the get_neighbors(nbr_state) function. Then, you can access individual elements of each neighbor using the "get_nbr_?" getters.

The neighbors library: nbr getters

These functions are used to access the internal state of the nbr tuples returned by get_neighbors()

The quidditch library

This library contains helper functions make it easier to send messages to your neighboring robots. These three functions let you broadcast your robot type, and let you read the type from your neighbors. See "test_quaffle.py" for usage examples.