IntroducTION

A basic feature of future autonomous robots will be their ability to communicate with us in a natural way, through gestures, expressions, speaking… In this tutorial you will learn how to work on this aspect with Robobo, through the expressions, sounds and speech production of the robot. The challenge is the creation of an Expressive Robobo!

pre-requisitEs

Before starting this challenge, we recommend you to read the following sections of the Robobo programming manual:

CHALLENGE: EXPRESSIVE ROBOBO

Creating a program that makes Robobo advance forward until it detects a nearby obstacle (just like in tutorial #1), and when this happens, it gets frightened. Therefore, once the obstacle is detected, you have to make Robobo look scared. To do this, you can make him move back, put its head back (tilt), show a face with surprise, emit a small scream, and say some phrase.

SOLUTION

One possible solution to this challenge is the following, although there are many others. Which one is yours?

async function main(){
    var Robobo = require('./lib/robobo');

    robobo = new Robobo('10.113.36.163');
    await robobo.connect();

     var closeIRValue = 30,
         speed = 30;

    robobo.moveWheels(speed,speed);   
    while ((robobo.readIRSensor('Front-C') < closeIRValue)and(robobo.readIRSensor('Front-RR') < closeIRValue)and(robobo.readIRSensor('Front-LL') < closeIRValue)) {
        await robobo.update()
    }
    await robobo.stopMotors(); 

    robobo.setLedColorTo('all','red');    
    robobo.setEmotionTo('surprised');
    robobo.playSound('disconform');    
    await robobo.moveTiltToBLK(50,15);    
    speed *= -1; 
    await robobo.moveWheelsByTimeBLK(speed,speed,2);
    robobo.sayText("Ups, I almost crash!");
    robobo.setEmotionTo('normal');
    robobo.moveTiltTo(75,15); 
}
main()

ADITIONAL CHALLENGE

When you have completed the “Robobo expressive” challenge, we propose you a new one with a little rhythm, do you like? Try to make Robobo move its head forwards and backwards as it moves in a straight line forward, as if it was rapping. At the same time it should show an expression on its face. When it encounters an obstacle, Robobo will stop, turn 90º using the wheel motors, look happy and say “This is fun, we repeat …” and finally emit a sound of joy.