Class: Robobo

Robobo(ip)

Robobo.js is the library used to create programs for the Robobo educational robot (http://www.theroboboproject.com) in the Javascript language. For more information and documentation see https://github.com/mytechia/robobo.js

Constructor

new Robobo(ip)

Creates a new Robobo.js library instance.
Parameters:
Name Type Description
ip string The IP address of the Robobo robot
Source:

Methods

changeStatusFrequency(freq)

Changes the frequency of the status (LOW, NORMAL,HIGH, MAX)
Parameters:
Name Type Description
freq String
Source:

(async) connect()

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

(async) disconnect()

Disconnects the library from the Robobo robot
Source:

log(text)

Writes the specified text in the Robobo log (console by default)
Parameters:
Name Type Description
text string The text to log
Source:

movePanTo(position, speed)

Moves the PAN of the base to the specified position at the specified speed
Parameters:
Name Type Description
position integer Position in degress of the PAN [-160..160]
speed integer Speed factor [-40..40]
Source:

(async) movePanToBLK(position, speed)

Moves the PAN of the base to the specified position at the specified speed and waits until the movement has finished.
Parameters:
Name Type Description
position integer Position in degress of the PAN [-170..170]
speed integer Speed factor [-40..40]
Source:

moveTiltTo(position, speed)

Moves the TILT of the base to the specified position at the specified speed
Parameters:
Name Type Description
position integer Position in degress of the TILT [5..105]
speed integer Speed factor [-10..10]
Source:

(async) moveTiltToBLK(position, speed)

Moves the TILT of the base to the specified position at the specified speed and waits until the movement has finished.
Parameters:
Name Type Description
position integer Position in degress of the TILT [5..105]
speed integer Speed factor [-10..10]
Source:

moveWheels(speedR, speedL)

Starts moving the wheels of the robot at the specified speed.
Parameters:
Name Type Description
speedR integer Speed factor for the right wheel [-100 - 100]
speedL integer Speed factor for the right wheel [-100 - 100]
Source:

(async) moveWheelsByDegreesBLK(wheel, degrees, speed)

Moves the wheels of the robot by some degress at the specified speed.
Parameters:
Name Type Description
wheel string Wheels to move [left | right | both]
degrees integer Degress to move the wheel
speed integer Speed factor [-100..100]
Source:

(async) moveWheelsByTimeBLK(speedR, speedL, time)

Moves the wheels of the robot at the specified speeds during the specified time. This functions is blocking, it doesn't returns the control until the movement is finished.
Parameters:
Name Type Description
speedR integer Speed factor for the right wheel [-100..100]
speedL integer Speed factor for the right wheel [-100..100]
time integer Time duration of the movement in seconds
Source:

(async) pause(time)

Pauses the program for the specified time (in seconds) This functions requires 'await' to work properly
Parameters:
Name Type Description
time float Time in seconds (accepts decimals like 0.2)
Source:

playNote(note, time)

Commands the robot to play a musical note
Parameters:
Name Type Description
note integer 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.
time integer Duration of the note in seconds (decimals can be used to used, like 0.2 or 0.5)
Source:

(async) playNoteBLK(note, time)

Commands the robot to play a musical note and wait until finishes playing it
Parameters:
Name Type Description
note integer 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.
time float Duration of the note in seconds (decimals can be used to used, like 0.2 or 0.5)
Source:

playSound(sound)

Commands the robot to play the specified emotion sound
Parameters:
Name Type Description
sound string One of ['moan','purr',"angry","approve","disapprove","discomfort","doubtful","laugh","likes","mumble","ouch","thinking","various"]
Source:

print(message)

Prints a message in the console
Parameters:
Name Type Description
message String The text to output in the console
Source:

readAccelerationSensor()

Reads the acceleration sensor
Source:
Returns:
The current acceleration of the smartphone (x, y, z)

readAllColorBlobs()

Reads all the color blob data
Source:
Returns:
A map returning the individual blob information (red, green, blue, custom)

readAllIRSensor() → {integer}

Returns the values of all the IR sensors. Example of use: let irs = readAllIRSensor(); console.log(irs.BackR); console.log(irs.FrontRR);
Source:
Returns:
The values of all the IR sensors of the base
Type
integer

readBatteryLevel(device) → {integer}

Returns the battery level of the base or the smartphone
Parameters:
Name Type Description
device string One of 'base' or 'smartphone'
Source:
Returns:
the battery level of the base or the smartphone
Type
integer

readBrightnessSensor()

Reads the brightness detected by the smartphone light sensor
Source:
Returns:
The current brightness value

readClapCounter() → {Integer}

Returns the number of claps registered since the last reset
Source:
Returns:
Clap counter
Type
Integer

readColorBlob(color)

Reads the last detected blob of color of the indicated color
Parameters:
Name Type Description
color * Color of the blob
Source:
Returns:
The position of the blob (x,y) and the area (area)

readFaceSensor()

Returns the position and distance of the last face detected by the robot Example of use: let face = robobo.readFaceSensor(); console.log(face.distance); //the distance to the person console.log(face.x); //the position of the face in X axis console.log(fase.y); //the position of the face in Y axis
Source:
Returns:
the position and distance of the last face detected by the robot

readFlingSensor()

Reads the data of the fling sensor
Source:
Returns:
Lasta angle detected on the sensor

readIRSensor(sensor) → {integer}

Returns the current value sensed by the specified IR
Parameters:
Name Type Description
sensor string One of ['Front-C','Front-L','Front-LL','Front-R','Front-RR','Back-C','Back-L','Back-R']
Source:
Returns:
the current value of the IR
Type
integer

readLastNote()

Returns the last note detected by the note sensor
Source:
Returns:
Name (note) and duration (duration) of the last note

readOrientationSensor()

Reads the orientation sensor Warning: This sensor may not be available on all the devices
Source:
Returns:
The orientation of the smartphone (yaw, pitch and roll)

readPanPosition()

Returns the current position of the PAN
Source:
Returns:
the current position of the pan

readTapSensor()

Reads the data on the tap sensor
Source:
Returns:
Coordinates of the last registered tap (x, y) and the zone of the face

readTiltPosition()

Returns the current position of the TILT
Source:
Returns:
the current position of the TILT

readWheelPosition(wheel)

Returns the position of the wheel in degrees
Parameters:
Name Type Description
wheel string One of [left, right]
Source:
Returns:
the position of the wheel in degress

readWheelSpeed(wheel)

Returns the current speed of the wheel
Parameters:
Name Type Description
wheel string One of [left, right]
Source:
Returns:
the current speed of the wheel in degress

resetClapCounter()

Resets the clap counter
Source:

resetColorBlobs()

Resets the color blob detector
Source:

resetFaceSensor()

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.
Source:

resetFlingSensor()

Resets the state of the Fling sensor
Source:

resetLastNote()

Resets the last note registered by the note sensor
Source:

resetTapSensor()

Resets the tap sensor value
Source:

sayText(text)

Commands the robot say the specified text
Parameters:
Name Type Description
text string The text to say
Source:

(async) sayTextBLK(text)

Commands the robot say the specified text and waits until the robots finishes reading the text
Parameters:
Name Type Description
text string The text to say
Source:

setColorBlobDetectionActive(red, green, blue, custom)

Activates the individual tracking of each color. Warning: Color tracking is a computionally intensive task, activating all the colors may impact performance
Parameters:
Name Type Description
red Boolean Enables red blob tracking
green Boolean Enables green blob tracking
blue Boolean Enables blue blob tracking
custom Boolean Enables custom blob tracking
Source:

setEmotionTo(emotion)

Changes the emotion of showed by the face of Robobo
Parameters:
Name Type Description
emotion string One of ['happy','laughing','surprised','sad','angry','normal','sleeping','tired','afraid']
Source:

setLedColorTo(led, color)

Changes the color of a LED of the base
Parameters:
Name Type Description
led string The ID of the led ['Front-C','Front-L','Front-LL','Front-R','Front-RR','Back-L','Back-R','all']
color string The new color ['off','white','red','blue','cyan','magenta','yellow','green','orange']
Source:

stopMotors()

Stops the movement of the wheels
Source:

(async) update()

Forces an update of the robot sensors. This functiona must be call any time the robot sensors are used in a conditional loop.
Source:

whenAFaceIsLost(fun)

Configures the callback that is called when a face is lost
Parameters:
Name Type Description
fun function The callback to be called
Source:

whenAFlingIsDetected(fun)

Configures the callback that is called when a new fling is detected
Parameters:
Name Type Description
fun function The callback to be called
Source:

whenANewColorBlobIsDetected(fun)

Configures the callback that is called when a new color blob is detected
Parameters:
Name Type Description
fun function The callback to be called
Source:

whenANewFaceIsDetected(fun)

Configures the callback that is called when a new face is detected
Parameters:
Name Type Description
fun function The callback to be called
Source:

whenANoteIsDetected(fun)

Configures the callback that is called when a new note is detected
Parameters:
Name Type Description
fun function The callback to be called
Source:

whenATapIsDetected(fun)

Configures the callback that is called when a new tap is detected
Parameters:
Name Type Description
fun function The callback to be called
Source: