Recently I produced a post about playing with Vex Robotics VexCode VR blocks and the Maze Playground.
The post finished with me saying I would like to play with Python and do a Python version of it. Well it is actually very easy to do it.
You can do it in two stages from the block code. First click on the <> icon (lighted in the figure above and it gives a further view producing Python code that changes as you change the blocks. The last stage is to convert to a text project (button at the bottom right of the screen.
Example of the code.
myVariable = 0
def when_started1():
global myVariable
drivetrain.drive_for(FORWARD, 100, MM)
while not down_eye.detect(RED):
drivetrain.drive_for(FORWARD, 5, MM)
if right_bumper.pressed():
drivetrain.drive_for(REVERSE, 30, MM)
drivetrain.turn_for(LEFT, 20, DEGREES)
drivetrain.drive_for(FORWARD, 20, MM)
else:
if left_bumper.pressed():
drivetrain.drive_for(REVERSE, 30, MM)
drivetrain.turn_for(LEFT, 120, DEGREES)
drivetrain.drive_for(FORWARD, 10, MM)
else:
drivetrain.turn_for(RIGHT, 10, DEGREES)
drivetrain.drive_for(FORWARD, 10, MM)
wait(5, MSEC)
vr_thread(when_started1())
The code in action
This is possibly a nice transition tool going from block-based programming to text-based.
Related posts
Augmented reality itself is amazing enough. But ever imagine what could happen when it is combined with artificial intelligence?
ReplyDeleteInteractive Virtual Reality