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
       

 
class Robot(robots_common.RobotHollow)
    Robot(platform)
 
Instances of the Robot class represent a robot platform that implements
the interface RobotHollow.
 
 
Method resolution order:
Robot
robots_common.RobotHollow
builtins.object

Methods defined here:
__init__(self, platform)
Create a robot based on the platform provided. The platforms
currently supported are:
 
Robot("blupants_car")
Robot("edumip")
Robot("beagleboneblack")
Robot("raspberrypi")
Robot("gripper")
Robot("ev3")
camera_toggle(self)
camera_toggle()
 
Move camera to the next preset position.
 
The preset position sequence is:
[-89.0, 0], [89.0, 0], [89.0, 30.0], [0, 30.0], [-89.0, 30.0],
[-89.0, 0], [-89.0, -30.0], [0, -30.0], [89.0, -30.0], [89.0, 0], [0, 0]
 
The tuple [X,Y] represents the camera position.
X: angle for the horizontal servo (pan)
Y: angle for the vertical servo (tilt).
claw_close(self)
claw_close()
 
Close the robot claw.
claw_open(self)
claw_open()
 
Open the robot claw.
claw_toggle(self)
claw_toggle()
 
If the claw is closed, it calls claw_open().
If the claw is open, it call claw_close().
look_angle(self, angle=90)
look_angle(angle)
 
Set the camera horizontal position (pan) to the angle provided as input and
reset the vertical position (tilt) to zero.
Camera pos: [angle, 0].
move(self, period=1, duty=1)
move(period, duty)
 
Set all motors to the duty provided as input. All motors stop after the period
of seconds provided as input.
move_backwards(self, blocks=1, speed=-1)
move_backwards(blocks, speed)
 
Move the robot backwards using the number of the blocks and the speed provided.
Speed ranges from 0 (stopped) to 1 (maximum speed).
move_forward(self, blocks=1, speed=-1)
move_forward(blocks, speed)
 
Move the robot forward using the number of the blocks and the speed provided.
Speed ranges from 0 (stopped) to 1 (maximum speed).
print(self, message)
print(message)
 
Print the input message to the standard output.
read_distance(self)
read_distance()
 
Return the distance in centimeters of the closest obstacle in front of the robot.
reload(self)
reload()
 
Reload robot configuration.
say(self, message)
say(message)
 
Print the message provided as input and say it using the TTS (Text-To-Speech) module.
say_no(self)
say_no()
 
Robot shakes camera servos and say "No!" using the TTS (Text-To-Speech) module.
say_welcome(self)
say_welcome()
 
Robot introduces itself telling its name and invites us to learn Computer Science.
say_yes(self)
say_yes()
 
Robot nods camera servos and say "Yes!" using the TTS (Text-To-Speech) module.
set_motor(self, i=1, duty=0.5)
set_motor(i, duty)
 
Set motor with index i to the duty cycle provided as input.
Duty cycle ranges from 0.0 to 1.0.
set_servo(self, i=1, angle=0.0)
set_servo(i, angle)
 
Set servo with index i to the angle provided as input.
Angle ranges from -90.0 to 90.0 degrees.
shutdown(self, quiet=False)
shutdown(quiet)
 
Safely shutdown robot peripherals after code execution is finished.
sleep(self, seconds=1.0)
sleep(seconds)
 
Pause the robot execution for the number of seconds provided.
If no value is provided as inputs, the robot sleeps for 1 second.
turn_left(self, angle=90)
turn_left(angle)
 
Turn the robot left using the angle provided as input.
If no angle is provided, the robot turns 90 degrees (default value).
turn_right(self, angle=90)
turn_right(angle)
 
Turn the robot right using the angle provided as input.
If no angle is provided, the robot turns 90 degrees (default value).

 
Author
        BluPants <blupants.robot@gmail.com>