Robobo.py

class Robobo.Robobo(ip)[source]

Bases: object

Robobo.py is the library used to create programs for the Robobo educational robot in the Python language.

To create a Robobo instance:

from Robobo import Robobo

rob = Robobo ('10.113.36.150')

Parameters:

  • ip: (string) The IP address of the Robobo robot

changeStatusFrequency(frequency)[source]

Changes the frequency of the status messages coming from the robot. Status messages are filtered by default in order to reduce network bandwidth, a higher frequency reduces the filters.

Parameters

frequency (StatusFrequency) – One value of the StatusFrequency enumeration

changeTagSize(size)[source]

Commands the robot to change the length of the side of the tag

:param size Size of the side of the aruco tag in milimiters

connect()[source]

Establishes a remote connection with the Robobo indicated by the IP address associated to this instance.

disconnect()[source]

Disconnects the library from the Robobo robot.

movePanTo(degrees, speed, wait=True)[source]

Moves the PAN of the base to the specified position at the specified speed

Parameters
  • degrees (int) – Position in degress of the PAN [-160..160]

  • speed (int) – Speed factor [0..100]

  • wait (bool) – True: blocking mode, False: non-blocking mode

moveTiltTo(degrees, speed, wait=True)[source]

Moves the TILT of the base to the specified position at the specified speed

Parameters
  • degrees (int) – Position in degrees of the TILT [5..105]

  • speed (int) – Speed factor [0..100]

  • wait (bool) – True: blocking mode, False: non-blocking mode

moveWheels(rSpeed, lSpeed)[source]

Starts moving the wheels of the robot at the specified speed.

Parameters
  • rSpeed (int) – (int) Speed factor for the right wheel [-100 - 100]

  • lSpeed (int) – (int) Speed factor for the left wheel [-100 - 100]

moveWheelsByDegrees(wheel, degrees, speed)[source]

Moves the wheels of the robot by some degress at the specified speed.

Parameters
  • wheel (Wheels) – Wheels to move, one value of the Wheels enumeration.

  • degrees (int) – Degrees to move the wheel

  • speed (int) – Speed factor for the right wheel [-100..100]

moveWheelsByTime(rSpeed, lSpeed, duration, wait=True)[source]

Moves the wheels of the robot at the specified speeds during the specified time.

Parameters
  • rSpeed (int) – Speed factor for the right wheel [-100..100]

  • lSpeed (int) – Speed factor for the left wheel [-100..100]

  • duration (int) – Time duration of the movement in seconds

  • wait (bool) –

    • If wait = True: (default value) it waits until the movement finishes.

    • If wait = False: the movement starts and the execution of the following command is immediately launched. This implies that the robot can execute the movement of another motor while the wheels are running.

playNote(note, duration, wait=True)[source]

Commands the robot to play a musical note

Parameters
  • note (int) – Musical note index [48..72]. Anglo-Saxon notation is used and there are 25 possible notes with the following basic correspondence. Any integer between 48 and 72.

  • duration (int) – Duration of the note in seconds (decimals can be used to used, like 0.2 or 0.5)

  • wait (bool) – True: blocking mode, False: non-blocking mode

playSound(sound)[source]

Commands the robot to play the specified emotion sound

Parameters

sound (Sounds) – One value of the Sound enumeration.

readAccelerationSensor()[source]

Reads the acceleration sensor

Returns

An Acceleration object.

Return type

Acceleration

readAllColorBlobs()[source]

Reads all the color blob data.

Example of use:

blobs = rob.readAllColorBlobs()
for key in blobs:
    blob = blobs[key]
    print(blob.color)
    print(blob.posx)
    print(blob.posy)
    print(blob.size)
Returns

A dictionary returning the individual blob information. Dictionary keys: ‘red’, ‘green’, ‘blue’, ‘custom’. Dictionary Values: Blob object (see Blob)

Return type

dict

readAllIRSensor()[source]

Returns the values of all the IR sensors.

Example of use:

irs = rob.readAllIRSensor()
if irs != []:
    print (irs[IR.FrontR.value])
    print (irs[IR.FrontRR.value])
Returns

A dictionary returning the values of all the IR sensors of the base. Dictionary keys: (string) IR ids (see IR). Dictionary values: (float) The value of the IR.

Return type

dict

readBatteryLevel(device)[source]

Returns the battery level of the base or the smartphone.

Parameters

device (string) – One of ‘base’ or ‘phone’

Returns

The battery level of the base or the smartphone

Return type

int

readBrightnessSensor()[source]

Reads the brightness detected by the smartphone light sensor

Returns

The current brightness value

Return type

int

readClapCounter()[source]

Returns the number of claps registered since the last reset

Returns

Clap counter

Return type

int

readColorBlob(color)[source]

Reads the last detected blob of color of the indicated color

Parameters

color (string) – Color of the blob, one of the following: ‘red’,’green’,’blue’,’custom’

Returns

A Blob object

Return type

Blob

readDetectedObject()[source]

Returns the last object detected by the robot.

Returns

A DetectedObject object

Return type

DetectedObject

readFaceSensor()[source]

Returns the position and distance of the last face detected by the robot.

Example of use:

face = robobo.readFaceSensor()
print(face.distance)  #the distance to the person
print(face.posX) # the position of the face in X axis
print(fase.posY) # the position of the face in Y axis
Returns

A Face object

Return type

Face

readFlingAngle()[source]

Returns the angle detected on the fling sensor

Returns

The last angle detected on the sensor.

Return type

int

readFlingDistance()[source]
readFlingTime()[source]
readIRSensor(id)[source]

Returns the current value sensed by the specified IR

Parameters

id (IR) – One value of the IR enumeration

Returns

the current value of the IR

Return type

int

readLaneBasic()[source]

Reads the last detected basic lane (straight lines)

Returns

(LaneBasic) A LaneBasic object (see LaneBasic)

readLanePro()[source]

Reads the last detected pro lane (2nd degree polynomials)

Returns

(LanePro) A LanePro object (see LanePro)

readLastNote()[source]

Returns the last note detected by the note sensor

Returns

A Note object

Return type

Note

readLine()[source]

Reads the last detected lines

Returns

(Lines) A Lines object (see Lines)

readNoiseLevel()[source]
readOrientationSensor()[source]

Reads the orientation sensor.

Warning: This sensor may not be available on all the devices

Returns

An orientation object.

Return type

Orientation

readPanPosition()[source]

Returns the current position of the PAN

Returns

The current position of the pan

Return type

int

readQR()[source]

Reads the last detected QR code

Returns

(QRCode) A QRCode object (see QRCode)

readTag()[source]

Returns the last ArUco Tag detected by the robot.

Returns

A Tag object

Return type

Tag

readTapSensor()[source]

Reads the data on the tap sensor

Returns

A Tap object.

Return type

Tap

readTiltPosition()[source]

Returns the current position of the TILT

Returns

The current position of the TILT

Return type

int

readWheelPosition(wheel)[source]

Returns the position of the wheel in degrees

Parameters

wheel (Wheels) – One of Wheels.L or Wheels.R

Returns

The position of the wheel in degrees

Return type

int

readWheelSpeed(wheel)[source]

Returns the current speed of the wheel

Parameters

wheel (Wheels) – One of Wheels.L or Wheels.R

Returns

The current speed of the wheel

Return type

int

resetClapCounter()[source]

Resets the clap counter

resetColorBlobs()[source]

Resets the color blob detector

resetFaceSensor()[source]

Resets the face sensor. After this function, and until a new face is detected, the face sensor will return 0 as values for distance, x and y position.

resetFlingSensor()[source]

Resets the state of the Fling sensor

resetTapSensor()[source]

Resets the tap sensor value

resetWheelEncoders()[source]

Resets the encoders of the wheels

sayText(speech, wait=True)[source]

Commands the robot to say the specified text

Parameters
  • speech (String) – The text to say

  • wait (bool) – True: blocking mode, False: non-blocking mode

setActiveBlobs(red, green, blue, custom)[source]

Activates the individual tracking of each color.

Warning: Color tracking is a computationally intensive task, activating all the colors may impact performance

Parameters
  • red (bool) – Enables red blob tracking

  • green (bool) – Enables green blob tracking

  • blue (bool) – Enables blue blob tracking

  • custom (bool) – Enables custom blob tracking

setBackCamera()[source]

Commands the robot to use the back camera

setCameraFps(fps)[source]

Commands the robot to change the camera fps

Parameters

fps (int) – Upper limit of the camera’s fps

setEmotionTo(emotion)[source]

Changes the emotion of showed by the face of Robobo

Parameters

emotion (Emotions) – One value of the Emotion enumeration

setFrontCamera()[source]

Commands the robot to use the frontal camera

setLaneColorInversion(set_on)[source]

Commands the robot to toggle the color inversion for the advanced lane module. NOTE: this does not affects the yellow detection.

:param set_on Boolean to choose if turn it on or off. :type set_on bool

setLedColorTo(led, color)[source]

Changes the color of a LED of the base

Parameters
  • led (LED) – One value of the LED enumeration.

  • color (Color) – One value of the Color enumeration.

setStreamFps(fps)[source]

Commands the robot to change the stream fps

Parameters

fps (int) – Upper limit of the stream’s fps

startArUcoTagDetection()[source]

Commands the robot to start the ArUcoTag detection

startCamera()[source]

Commands the robot to start the camera

startColorDetection()[source]

Commands the robot to start the color detection

startColorMeasurement()[source]

Commands the robot to start the color measurement

startFaceDetection()[source]

Commands the robot to start the face detection

startLaneDetection()[source]

Commands the robot to start the lane detection

startLineDetection()[source]

Commands the robot to start the line detection

startLineStats()[source]

Commands the robot to start the line detection STATUS report

startObjectRecognition()[source]

Commands the robot to start the object recognition

startQrTracking()[source]

Commands the robot to start the QR tracking

startStream()[source]

Commands the robot to start the camera streaming

stopArUcoTagDetection()[source]

Commands the robot to stop the ArucoTag detection

stopCamera()[source]

Commands the robot to stop the camera

stopColorDetection()[source]

Commands the robot to stop the color detection

stopColorMeasurement()[source]

Commands the robot to stop the color measurement

stopFaceDetection()[source]

Commands the robot to stop the face detection

stopLaneDetection()[source]

Commands the robot to stop the lane detection

stopLineDetection()[source]

Commands the robot to stop the line detection

stopLineStats()[source]

Commands the robot to stop the line detection STATUS report

stopMotors()[source]

Stops the movement of the wheels

stopObjectRecognition()[source]

Commands the robot to stop the object recognition

stopQrTracking()[source]

Commands the robot to stop the QR tracking

stopStream()[source]

Commands the robot to stop the camera streaming

wait(seconds)[source]

Pauses the program for the specified time (in seconds)

Parameters

seconds (float) – Time in seconds (accepts decimals like 0.2)

whenAFaceIsLost(callback)[source]

Configures the callback that is called when a face is lost

Parameters

callback (fun) – The callback function to be called

whenAFlingIsDetected(callback)[source]

Configures the callback that is called when a new fling is detected

Parameters

callback (fun) – The callback function to be called

whenALaneBasicDetected(callback)[source]

Configures the callback that is called when a basic lane is detected

Parameters

callback (fun) – The callback function to be called

whenALaneProDetected(callback)[source]

Configures the callback that is called when a pro lane is detected

Parameters

callback (fun) – The callback function to be called

whenALineIsDetected(callback)[source]

Configures the callback that is called when a line is detected

Parameters

callback (fun) – The callback function to be called

whenANewColorBlobIsDetected(callback)[source]

Configures the callback that is called when a new color blob is detected

Parameters

callback – The callback function to be called

Rtype callback

fun

whenANewFaceIsDetected(callback)[source]

Configures the callback that is called when a new face is detected

Parameters

callback (fun) – The callback function to be called

whenANewQRCodeIsDetected(callback)[source]

Configures the callback that is called when a new QR is detected

Parameters

callback (fun) – The callback function to be called

whenANoteIsDetected(callback)[source]

Configures the callback that is called when a new note is detected

Parameters

callback (fun) – (fun) The callback function to be called

whenAQRCodeIsDetected(callback)[source]

Configures the callback that is called when a QR is detected

Parameters

callback (fun) – The callback function to be called

whenAQRCodeIsLost(callback)[source]

Configures the callback that is called when a QR is lost

Parameters

callback (fun) – The callback function to be called

whenATagIsDetected(callback)[source]

Configures the callback that is called when a Tag is detected

Parameters

callback (fun) – The callback function to be called

whenATapIsDetected(callback)[source]

Configures the callback that is called when a new tap is detected

Parameters

callback (fun) – The callback function to be called

whenAnObjectIsDetected(callback)[source]

Configures the callback that is called when an object is detected

Parameters

callback (fun) – The callback function to be called

whenClapIsDetected(callback)[source]

Configures the callback that is called when a new clap is detected

Parameters

callback (fun) – The callback function to be called