Home » Blog » Dancing and object avoiding bPED Robot

Dancing and object avoiding bPED Robot

For our Mobile Robotics projects, we chose to construct a bPED robot with laser-cut wood, and implemented a simple object avoidance algorithm, an audio feedback for the ultrasonic sensor and a remote control app which can make the robot move, dance, and show different emotions.

For hardware, we ordered the “DYOR bPED Básico con LEDs Corte Láser Madera” from roboticafacil.es and assembled the robot following the given instructions. The robot includes a buzzer, an ultrasonic sensor, LEDs and a bluetooth module. To demonstrate the full functionality of this robot, we implemented three different programs which we explain in the following paragraphs.

Object avoidance

The object avoidance algorithm is fairly straightforward and shows the basic functionality of the robot. Once activated, the robot walks forward, until it comes to close to an object, at which point it stops, turns left for a bit, and then continues walking. This is a simple state machine, where the robot regularly measures the distance, then decides by comparing the measurement to a given safety distance to enter either state 1 for forward walking straight or state 2 for turning left. All different states are accompanied by LED expressions (neutral for measuring, happy for walking straight, sad for turning left). The code can be easily implemented using facilino, as can be seen in the following screenshot:

Audio feedback for distance sensor
The idea of this program is for the robot to act as the audio sensor a car might possess for parking. That means the robot should emit a beeping sound which gets faster the closer the robot is to an obstacle, giving audio feedback for its distance measurements. While this might seem very straightforward, contrary to the first program this can not simply be accomplished by using facilino building blocks. This is because the actions of walking and distance measurement/beeping need to be performed simultaneously and continuously for the idea to work. As two things need to happen at once, using the delay() function is not a valid option to implement the intervals between different beeps. Instead a timer must be used and continuously updated and compared. Furthermore, the walking action takes long and so if we perform the distance measurement/beep only after each walking cycle, the interval between subsequent tones never becomes sufficiently short to produce the desired effect. We solved these problems by editing the code directly in the Arduino IDE: We implemented a function which performs both the distance measurement/beeping and then call this function inside the movement cycle (bPED_moveServos(…) and bPED_oscillateServos(…)):

//measures distance, and checks if beep is necessary
unsigned long beepboop(unsigned long prev_ms){
  int dist=distance((D9),(D8));
  unsigned long interval_ms=100 * dist;
  if ((unsigned long) (millis() - prev_ms) >= interval_ms) {
    prev_ms=millis();
    _tone(D3,440,50,0);
    }
  return prev_ms;
}

Finally, this program too has a safety distance implemented at which the audio feedback stops, a decending tone sequence is played and the robot walks backwards for a few steps before continuing. Again, the states are accompanied by LED expressions.

 

Bluetooh Module

As already mentioned, the robot is equipped with a bluetooth module that it can use to receive instructions remotely.

Taking advantage of the MIT APP INVENTOR programme, we developed an app that would act as an interface between the operator and the robot to allow it to perform a series of simple tasks. All the tasks where implemented by using Facilino.

Once the Bluetooth connection between the devices is ensured, the user can choose between three categories of actions: “Move”, “Dance” and “Emoji”.

 

 

The “Move” screen is equipped with five cross-shaped buttons that allow the operator to choose the robot’s direction of movement. Each direction is associated with a colour that will be shown by the LED module.

The “Dance” screen provides a list of songs to choose from to play. Each song will be played by the buzzer; in addition, the robot will perform a series of dance steps and will show on the led module choreographies of colours in line with the selected song.

The “Emoji” screen shows six expressions/emotions that the robot can display. Each emotion is associated with a ‘facial expression’ (shown by the LED module) and simple steps.

 

 

 

Video of the robot: