Software Design

Initially the code for RoboPele was divided into three sections, the input, the output and the control. More specfically the task of the input half of the code was to measure the speed of the ball. The output half used this timing to determin the delay and speed of collision. Later in the testing phase a compromise was introduced in the code which added control and output functionality into the middle of the input sensing half of the code. As mentioned in the Strategy Guide this provided an extended range of ball speeds it could handle. Additionally, due to the limited functionality of the programming control structures in the Lego Mindstorms programming language the output portion of the code was actually placed at the beginning of the program, not at the end where it would be expected.

The input portion of the code is located halfway through the program. The flow of the input sensing follows a fairly simple path. Essentially RoboPele waits for the first sensor to be triggered. After the inital triggering, the timer is reset and RoboPele waits for the second sensor to be triggered.

In order to introduce the inital cart movement before the ball speed is known there was a code segment placed in the middle of the loop which waited for the second sensor. This little segment would activate the cart and stop it after a certain distance was covered. Although it was unneccessary, this initial speed could be set incrementally over time and distance to provide a smoother acceleration. If the outer loop, waiting for the second sensor, exited then RoboPele's cart would continue without stopping.

In addition to the small code segment during the input phase, the main bulk of the control portion of RoboPele's code was a series of check and chose code blocks. Each check and chose would compare the timer to a preset value and set the power levels for the cart's motors. Some of these code segments would also set a delay, in the form of a tone that would prevent the cart from going too early and missing the ball.

Finally, the output code, which is located at the begining of the program, would activate the motors. After a total distance away from the intial position was reached. the motors would stop, change deterection and power up again to return the cart back to where it started from.

The placement of the output code first caused an interesting behaviour to be exhibited. When RoboPele's program is first activated, it initally "sweeps" the arena by advancing to the collision point and returning to its starting point. This behaviour proved most useful when setting up the position of the trough, as it would show exactly where collision was expected to happen.

 

[prev|up]
[guide|hardware|software]