robots |
BluPants Robot class.
This module provides a factory so you can instantiate robots from
any hardware supported by BluPants. Currently supported platforms are:
* Beaglebone Blue: "blupants_car" or "edumip" - Ex:
robot = robots.Robot("blupants_car")
* Beaglebone Black: "beagleboneblack" - Ex:
robot = robots.Robot("beagleboneblack")
* RaspberryPi: "raspberrypi" - Ex:
robot = robots.Robot("raspberrypi")
* Lego Ev3: "gripper" or "ev3" - Ex:
robot = robots.Robot("gripper")
After instantiating your robot, you can call all the functions available at
the BluPants IDE <http://blupants.org>. For instance, you can call methods
such as: move_forward(), turn_right(), read_distance(), claw_close(). See
usage bellow for examples.
Typical usage:
>>> import blupants.robots_common as robots_common
>>> import blupants.robots as robots
# instantiate a Beaglebone Blue gripper/claw robot
>>> robot = robots.Robot("blupants_car")
# instantiate a RaspberryPi gripper/claw robot
>>> robot = robots.Robot("raspberrypi")
# instantiate a Lego Ev3 Gripp3r robot
>>> robot = robots.Robot("gripper")
# move robot one block forward
>>> robot.move_forward()
# move robot two blocks forward
>>> robot.move_forward(2)
# turn robot left 90 degrees
>>> robot.turn_left()
# turn robot right 30 degrees
>>> robot.turn_right(30)
# read the distance from the nearest obstacle in front of the robot
>>> d = robot.read_distance()
Distance: [25] cm.
# close the robot claw
>>> robot.claw_close()
# robot text-to-speech
>>> robot.say("Hello from BluPants.")
Hello from BluPants.
Classes | ||||||||||||||||
|