The smartphone sensing blocks are the most numerous in Robobo. All of them are related to information that Robobo can capture through the sensors located in the smartphone, and therefore, are those that provide the robot with greater potential. It is important to use the monitoring window to check the values returned by these sensors in real time in each specific environment:

  • camera:

  • microphone:

  • screen:

 

  • Gyroscope and compass:

  • battery:

read tap on _

  • function: it returns the x, y or zone in which a short tap is detected. This block only detects simple pulsations, that is, if we briefly press the screen twice, it will return two values.
    • warning: This sensor maintains the last measured value.
  • fields:
    • axis selection:
      • X o Y: values to be selected, x and y, which correspond to the Cartesian coordinates. 
        • range: From 0 to 100 in both axes, as shown in the following image:

      • ZONE: Returns the area of the smartphone screen on which a brief press has been made (tap).
        • RANGE: Returns one of the following five values: forehead, eye, right, left, mouth or chin, depending on the area of the screen on which the pulsation is made. The following diagram shows, approximately, the zones corresponding to the values returned.

  • EXAMPLE:

The following program makes Robobo say “I don’t have a moustache” by briefly clicking on the area of the screen between the mouth and the eye. It is necessary to reset the value of the tap sensor in each iteration of the loop because this sensor maintains the last measured value.

Reset tap sensor

  • function: it resets the contact zone sensor on the screen to NONE.
  • fields:
    • No fields.
  • example:

The following program makes Robobo show “anger” if you put your finger in its eye. To do this, it checks if the tap zone block returns “eye”, in which case the facial expression is changed to angry, the wheels are moved from side to side and, finally, the expression returns to normal.

when A TAP is detected

  • function: It is activated when a tap gesture is detected on the screen. Its operation is that of any Scratch hat block, that is, if this block is activated, those that are connected to it are executed.
  • fields:
    • No field.
  • example:

The following program makes Robobo stop all motors when tapping on the screen (short press):

read Fling sensor

  • function: it returns the angle at which you slide your finger across the screen of the smartphone. This angle is given by the direction of the gesture on the screen.
    • warning: This sensor maintains the last measured value.
    • range: From 0 to 360 degrees, in polar coordinates. The following images show 3 possible fling gestures that could be made on the smartphone screen, and the angle returned by this sensor. In the left image, the angle would be the same in both gestures, 180 degrees. In the central image, the angle would be about 70 degrees and, finally, in the right image, the angle would be about 330 degrees.

  • fields:
    • No field.
  • example:

The following program moves the PAN and TILT motors of Robobo according to the fling angle that is made on the screen. For example, if a 30-degree fling is performed, Robobo will move the PAN angle to the left (move PAN to 100 at speed 50):

Reset fling sensor

  • Function: it resets the touch-scrolling angle sensor on the screen to 0.
  • Fields:
    • No field.
  • example:

The previous example (READ FLING SENSOR) shows a usage example of this block, resetting the sensor fling value in each loop iteration.

when A FLING is detected

 

  • function: It is activated when a fling gesture is detected on the screen. Its operation is that of any Scratch hat block, that is, if this block is activated, those that are connected to it are executed.
  • fields:
    • No field.
  • example:

The following program makes the robot say the battery level when a fling gesture on the screen is detected:

read Last note _

  • function: it returns the last musical note detected with the microphone of the smartphone. The note is continuously measured.
    • range: Returns the musical note in text format, according to the English nomenclature, that is:
DO DO# RE RE# MI FA FA# SOL SOL# LA LA# SI
C Cs D Ds E F Fs G Gs A As B
  • fields:
    • Note/duration: you can select to read the note or the duration of the note.
  • example:

The following program consists of two parallel execution threads, that is, when pressing on the icon of the flag both will be executed at the same time. The one on the left generates musical notes from MI to RE following the numeric notation shown in the block Play note _ for _ seconds and wait _. The one on the right detects emitted notes with the block last note and turns on the LEDs of the Robobo base based according to the detected note. When executing this program, it can be observed that for some notes (sharped), no LED lights up:

Reset last note

  • FUNCTION: it resets the last note reading sensor.
  • fields:
    • No field.
  • example:

The following program makes Robobo measure every second the musical note it detects for 10 seconds.

In case of detecting an “E”, it says so using the SAY block. The RESET LAST NOTE block is necessary to prevent it from continuously detecting the first “E”, since this block saves the last value read.

when a note is detected

  • function: It is activated when a note is detected. Its operation is that of any Scratch hat block, that is, if this block is activated, those that are connected to it are executed.
    • warning: This block is continuously running, capturing all the sounds detected by the smartphone. Its use can slow down other blocks that use sound.
  • fields:
    • No field.
  • example:

The following program makes that, when a “C” is detected, Robobo informs the user by voice. This type of block is usually used with others in parallel so that the robot is doing different things depending on the sensor:

read Clap Counter

  • function: it returns the number of claps detected by the smartphone’s microphone.
    • range: Any positive integer number, since it counts the claps that it detects in a cumulative way.
    • warning: The block is set for the detection of clap-type sounds, but it must be taken into account that the ambient noise greatly affects the detection, being able to confuse similar noises in this sensor. On the other hand, this sensor maintains the last detected value.
  • fields:
    • No field.
  • example:

The following program detects when two or more consecutive claps are made (in less than two seconds), which makes Robobo emit a sound of joy and put the surprise expression. To do this, a timer is used, which restarts every 2 seconds the clap counter block. If we emit a single slap, nothing happens. It is a simple example of the type of interaction that can be achieved with Robobo when using sound:

Reset clap counter

  • function: it resets the clap counter to 0.
  • fields:
    • No field.
  • example:

In the previous program (READ CLAP COUNTER) you can see the use of this block to get the clap counter to restart when capturing two.

when CLAP is detected

  • function: It is activated when a clap is detected. Its operation is that of any Scratch hat block, that is, if this block is activated, those that are connected to it are executed.
    • warning: This block is continuously running, capturing all the sounds detected by the smartphone. Its use can slow down other blocks that use sound. It is recommended to use it in spaces where there are no other sound sources similar to a clap, since these would make it activate continuously..
  • fields:
    • No field.
  • example:

The following program makes Robobo stop and say “You told me to stop” when it detects a clap:

 

read Brightness sensor

  • function: it returns the ambient light level detected by the built-in sensor on the smartphone screen. 
    • warning: Not all smartphone models include this sensor.
    • RANGE: Any positive integer value. The value is returned in LUX (lx), the international system unit for the lighting level.
  • fields:
    • No field.
  • example:

The following program causes Robobo to turn on itself while the level of illumination on the screen exceeds 1000 lx. Otherwise, it stops:

read face sensor _

  • function: it returns the distance the x, y, size or position at which the smartphone front camera detects a face. The returned point (x, y) corresponds to the midpoint between the two eyes of the detected face:
    • warning: The face detection depends a lot on the ambient light level and how it affects the face to be detected. It is recommended that the face be properly illuminated. On the other hand, the precision in the face detection depends on the quality of the smartphone front camera. This sensor stores the last detected value.
  • fields:
    • axis selection:
      • X o Y: here are 2 possible axes to be selected, x and y, which correspond to the Cartesian coordinates shown above.
        • range: From 0 to 100 in both axes, using the camera perspective, as shown in the following image, where the coordinates of the detected face would be (40, 60):

      • Size: Returns the distance at which the smartphone front camera detects a face.
        • RangE: from 0 (no detection) to inf (the greater the size the smaller the distance). The value is not returned in standard units. 
      • Distance: returns a discrete estimate of the distance at which the smartphone front camera detects a face.
        • range: returns only three text values: close, mid (medium) or far.
  • examples:

The following program makes Robobo say where it detects a face in a natural way for the user. So, when it detects a face to the right, left or centered, it says so. If it does not detect any face, it says “I can’t see you”. To do this, it uses the x coordinate of the detected face:

Reset face sensor

  • function: it resets the distance sensor to face to 0 and the position sensor (x,y) to (0,0).
  • fields:
    • No field.
  • example:

The following example makes Robobo look for a nearby face by moving the PAN motor. When it finds the face, it stops and says “I see you”. To do this, a counter variable is used to identify the state (1, 2 or 3) in which the PAN is located, and to turn it accordingly:

when FACE IS detected

  • function: It is activated when a face is detected. Its operation is that of any Scratch hat block, that is, if this block is activated, those that are connected to it are executed.
    • warning: This block is continuously running, continuously capturing the presence of a face. Its use can slow down other blocks that use face detection.
  • fields:
    • No field.
  • example:

The following program makes Robobo say “I can see you” continuously every 2 seconds whenever its detects a face:

when FACE IS LOST

  • function: It is activated when a face is no longer detected. Its operation is that of any Scratch hat block, that is, if this block is activated, those that are connected to it are executed.
    • warning: This block is continuously running, continuously capturing the non-presence of a face. Its use can slow down other blocks that use face detection.
  • fields:
    • No field.
  • example:

The following program makes Robobo say “I can see you” and “I can’t see you” continuously every 2 seconds whenever it detects a face and then loses it:

reAD QR _

  • function: it returns the identifier (id), x, y or size of a QR code detected by the smartphone front camera.
    • warning: the QR code detected with this block is of the standard type (https://en.wikipedia.org/wiki/QR_code), and it must be previously printed in order to be detected. Depending on the size of the tag, its detection will be more or less robust.
  • fields:
    • value selection:
      • id: returns the content of the existing text in the QR (up to 4296 characters)
      • X o Y: coordinate of the center of the QR, measured in pixels from the left side of the screen. It takes positive values 
      • Size: it returns the distance from the camera to the QR code.
        • range: from 0 (not detected) to inf (the higher the value, the closer). The measured value is not in international units. It is recommended to check the values in the monitoring window because they depend on the specific illumination.
    • example:

The following program makes Robobo notify when it detects a centered QR code (X coordinate between 200 and 250), saying the identifier it contains:

when A QR CODE IS detected

  • function: It is activated when a QR code is detected. Its operation is that of any Scratch hat block, that is, if this block is activated, those that are connected to it are executed.
    • warning: This block is continuously running, continuously capturing the presence of a QR. Its use can slow down other blocks that use QR detection.
  • fields:
    • No field.
  • example:

The following program makes Robobo stop the motors and say the code of the detected QR.

when A QR CODE APPEARS

  • function: It is activated when a different QR code than the previous one is detected. Its operation is that of any Scratch hat block, that is, if this block is activated, those that are connected to it are executed.
    • warning: This block is continuously running, continuously capturing the presence of a QR. Its use can slow down other blocks that use QR detection.
  • fields:
    • No field.
  • example:

The following program makes Robobo stop all the motors and say the code of a new QR that detects.

when A QR CODE DISAPPEARS

  • function: It is activated when the last seen QR is no longer detected. Its operation is that of any Scratch hat block, that is, if this block is activated, those that are connected to it are executed.
    • warning: This block is continuously running, continuously capturing the presence of a QR. Its use can slow down other blocks that use QR detection.
  • fields:
    • No fields.
  • example:

The following program makes Robobo say the id of the QR when it stops detecting it:

Reset QR

  • function: it resets the QR sensor by resetting the values of x, y, size to zero and assigning an empty text to the id value.
  • fields:
    • No field.

read_ Blob _

  • function: it returns the x-coordinate, y-coordinate or area of the chosen color zone in the color selection field detected in the smartphone’s front camera image. The x, y coordinates correspond to the center of the largest color area detected.
    • warning: The detection of the area of a certain color depends very much on the ambient light level and how it affects the object to be detected. It is recommended that the object be properly illuminated. On the other hand, the accuracy in color detection depends on the quality of the front camera of the smartphone.
    • calibrating: For optimal operation of this block, it is recommended to perform the calibration process of the camera described in app user guide. During calibration, you can also select what is the custom color.
  • field:
    • color selection:
      • The value returned by this sensor corresponds to the area of the color selected in this field. If there is more than one area of the same color in the image, the values of the largest one will be returned.
      • Range: The possible colors to detect are red, green, blue and custom. By default, the only color detected is green. To detect other colors, they must be previously activated in the configure blob detection colors block.
    • axis selection:
      • X o Y: The possible values are x or y, according to the Cartesian coordinates shown in the previous image.
        • RangE: The output values go from 0 to 100 for both x and y, as shown in the following figure (the example value shown would be the coordinates of the center of the blue area, of values (30,30)):

      • Area:
        • range: The returned area can have any positive integer value and it is measured in pixels.
  • examples:

The following program makes Robobo say where he detects a green object, in a natural way for the user. So, when it is detected on the right, left or middle, it says so. If it does not detect any green object, it says I can’t see green. For this, the x coordinate of the largest green area detected in the image is used:

The following program associates the detected area of a certain color object (green in this case) with the distance to that object. Thus, if the area is less than 2000, Robobo accelerates to approach. If it is between 2000 and 8000, it moves more slowly and, finally, if it is greater than 8000 it stops. To test example, it is recommended to use a green object that is placed in front of the robot:

Reset color blobs

  • function:  it resets the color sensor to zero values of x, y, and area
  • fields:
    • No fields

set active blobs R _ G _ B _ C _

  • function: It allows you to select which colors will be detected in the read _ blob  _ block, using the red (R), green (G), blue (B) or custom color (C) activation selection fields. The color detection consumes a lot of smartphone resources, because it is analyzing the camera image continuously, which requires an important use of the processor that can slow down Robobo operation.
    • warning: This block affects the program in which it is used, and only while it is running. By default, the only color detected is green.
    • calibrating: For optimal operation of the blocks that use color detection with the camera, it is recommended to perform the calibration process from the smartphone app, described in the app user guide. During calibration, you can also select the custom color.
  • fields:
    • RED ACTIVATION:
      • Range: There are two possible values, true or false, which indicate respectively if the program in which this block is used should detect the red color or not.
    • green activation:
      • Range: There are two possible values, true or false, which indicate respectively if the program in which this block is used should detect the green color or not.
    • blue activation:
      • Range: There are two possible values, true or false, which indicate respectively if the program in which this block is used should detect the blue color or not.
    • custom color activation:
      • Range: There are two possible values, true or false, which indicate respectively if the program in which this block is used should detect the custom color or not.
  • example:

The following program configures the red and blue colors for detection. Next, by placing an object of each color in front of the camera, Robobo says if it detects red or blue, and turns on the LEDs of the base in each case. By default, the LEDs on the base are green:

when A COLOR BLOB IS DETECTED

  • function: It is activated when a color is detected with the smartphone camera. Its operation is that of any Scratch hat block, that is, if this block is activated, those that are connected to it are executed.
    • warning: This block is continuously running, continuously capturing the non-presence of a color. Its use can slow down other blocks that use color detection. In addition, it will detect any blob that is activated with the SET ACTIVE BLOBS block.
  • fields:
    • No field.
  • example:

The following program makes Robobo continuously say the color it detects, assuming green, red and blue are activated:

read Orientation on _ AXIS

  • FUNCTION:  it returns the smartphone orientation according to the navigation angle chosen in the drop-down selection field. As the smartphone is fixed to the base through the holder, this orientation is that of Robobo itself.
    • WARNING: Not all smartphones have an orientation sensor (gyroscope).
    • RANK: From -180 to 180 degrees on all axes, according to the navigation angle scheme of the figure below. It is important to note that the yaw angle turn is achieved by turning the base with the wheel motors and the PAN motor. The turn in the roll angle cannot be achieved by Robobo, but if the surface on which it moves has a lateral inclination, it will change. Finally, you can rotate the pitch angle when using the TILT motor or move the robot through a frontally inclined plane:

  • FIELDS:
    • ANGLE SELECTION: 
      • Range: There are 3 possible navigation angles: yaw, pitch and roll.
  • EXAMPLE:

The following program makes Robobo move in a straight line indefinitely, and say if it goes up or if it goes down in case of finding an incline in its path. For this, it is analyzed if the pitch angle is above a negative or positive threshold:

Smartphone battery level

  • function: it returns the battery level of the Smartphone.
    • Range: From 0 to 100, so the higher the value, the higher the battery level.
  • fields:
    • Phone/battery.
  • EXAMPLE:

Below is a typical program that could be in permanent execution controlling the battery level of the smartphone every 5 minutes (300 seconds), and that emits a warning when such level falls below a certain threshold. In this case, the warning consists on saying the phrase “Very low battery, save your program” every 30 seconds:

read acceleration on _ axis

  • FUNCTION: it returns the acceleration suffered by the smartphone on the axis chosen in the axis selection drop-down field. As the smartphone is fixed to the base through the holder, this acceleration is that of Robobo itself.
    • RANGE: Any integer value, positive or negative, measured in m/s2. The axes that are used as a reference are the following:

  • FIELDS:
    • AXIS SELECTION:
      • Range: You can select the 3 axes x, y, z of the Cartesian system.