Constructor
new Robobo(ip)
Creates a new Robobo.js library instance.
Parameters:
Name | Type | Description |
---|---|---|
ip |
string | The IP address of the Robobo robot |
Methods
changeStatusFrequency(freq)
Changes the frequency of the status (LOW, NORMAL,HIGH, MAX)
Parameters:
Name | Type | Description |
---|---|---|
freq |
String |
(async) connect()
Establishes a remote connection with the Robobo indicated by
the IP address associated to this instance.
(async) disconnect()
Disconnects the library from the Robobo robot
log(text)
Writes the specified text in the Robobo log (console by default)
Parameters:
Name | Type | Description |
---|---|---|
text |
string | The text to log |
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] |
(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] |
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] |
(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] |
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] |
(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] |
(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 |
(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) |
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) |
(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) |
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"] |
print(message)
Prints a message in the console
Parameters:
Name | Type | Description |
---|---|---|
message |
String | The text to output in the console |
readAccelerationSensor()
Reads the acceleration sensor
Returns:
The current acceleration of the smartphone (x, y, z)
readAllColorBlobs()
Reads all the color blob data
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);
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' |
Returns:
the battery level of the base or the smartphone
- Type
- integer
readBrightnessSensor()
Reads the brightness detected by the smartphone light sensor
Returns:
The current brightness value
readClapCounter() → {Integer}
Returns the number of claps registered since the last reset
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 |
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
Returns:
the position and distance of the last face detected by the robot
readFlingSensor()
Reads the data of the fling sensor
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'] |
Returns:
the current value of the IR
- Type
- integer
readLastNote()
Returns the last note detected by the note sensor
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
Returns:
The orientation of the smartphone (yaw, pitch and roll)
readPanPosition()
Returns the current position of the PAN
Returns:
the current position of the pan
readTapSensor()
Reads the data on the tap sensor
Returns:
Coordinates of the last registered tap (x, y) and the zone of the face
readTiltPosition()
Returns the current position of the TILT
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] |
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] |
Returns:
the current speed of the wheel in degress
resetClapCounter()
Resets the clap counter
resetColorBlobs()
Resets the color blob detector
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.
resetFlingSensor()
Resets the state of the Fling sensor
resetLastNote()
Resets the last note registered by the note sensor
resetTapSensor()
Resets the tap sensor value
sayText(text)
Commands the robot say the specified text
Parameters:
Name | Type | Description |
---|---|---|
text |
string | The text to say |
(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 |
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 |
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'] |
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'] |
stopMotors()
Stops the movement of the wheels
(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.
whenAFaceIsLost(fun)
Configures the callback that is called when a face is lost
Parameters:
Name | Type | Description |
---|---|---|
fun |
function | The callback to be called |
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 |
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 |
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 |
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 |
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 |