In tutorial #3, we saw a first example of tactile interaction with Robobo, that is, how the robot can react if we touch its face.
In this tutorial we will continue working on this aspect with Robobo, and you will now learn how to provoke a predefined response when we touch the face in a certain way.
The challenge is to create a Spinning Robobo!
Before starting this challenge, we recommend you to read the following sections of the Robobo programming manual:
CHALLENGE: SPINNING ROBOBO
Creating a program that makes Robobo react to touches and gestures on its face (Smartphone screen). If you move your finger on the screen (fling) to the right or left, Robobo must turn its head to the right or left respectively and turn on the leds (one color to the right and a different color to the left).
A possible solution to this challenge is the following, although there are many others. Which one is yours?
from Robobo import Robobo from utils.LED import LED from utils.Color import Color from utils.Emotions import Emotions from utils.Sounds import Sounds robobo = Robobo('10.113.36.163') robobo.connect() robobo.resetFlingSensor() robobo.setEmotionTo(Emotions.NORMAL) robobo.setLedColorTo(LED.All, Color.OFF) robobo.movePanTo(0, 15) while True: robobo.wait(0.01) angle = robobo.readFlingAngle() if angle > 0: if (angle < 90)or(angle > 270): robobo.setEmotionTo(Emotions.SURPRISED) robobo.setLedColorTo(LED.All, Color.BLUE) robobo.movePanTo(-50, 30) else: robobo.setEmotionTo(Emotions.SURPRISED) robobo.setLedColorTo(LED.All, Color.MAGENTA) robobo.movePanTo(50, 30) robobo.movePanTo(0, 15) robobo.setEmotionTo(Emotions.LAUGHING) robobo.playSound(Sounds.LAUGH) robobo.resetFlingSensor() robobo.wait(1) robobo.setLedColorTo(LED.All, Color.OFF) robobo.setEmotionTo(Emotions.NORMAL)
When you have completed the “Spinning Robobo” challenge we propose you a new one where we complicate a little the reaction of Robobo, are you prepared? The goal is to create a program in which Robobo moves its head forward/backward (TILT) or turns its body (moves the wheels) right/left (PAN) depending on the angle of the fling gesture you make on the screen of the Smartphone.