Moving Instrumentbot

Interactive Kinetic Robot

Moving Instrumentbot

v1.0 Arduino / v2.0 Pure Data Project

Date

10/2019

Tools

ESP32 • Bela Board • Pure Data • Wekinator • L293D • DC Motors • Servo Motors • WiFi

[slideshow:1]

[toc]

Project Information

  • v1.0 Electronics for Artists course project: Arduino / ESP32 / DC motors / servos.
  • v2.0 Physical Interaction Design course project: Pure Data / Bela board / Wekinator / WiFi dongle / speaker / DC motors / servos.
  • Size: 25(H)*25(W)*25(D) cm.

Overview

The instrumentbot is built based on the EFA robot as a starting point, and then replaces the original Arduino UNO with two controller versions: ESP32 and Bela board. The programming languages are Arduino and Pure Data, respectively.

Three additional features were added to the instrumentbot: remote control via WiFi (TCP/IP), a moving eyeball controlled by two servo motors, and a speaker playing sine waves with several frequencies generated by Pure Data. These features make the robot more engaging for audiences and easier to control intuitively.

Idea

The concept is a mobile instrumentbot that moves with wheels, inspired by the uncanny creature feeling of a toy head attached to a spider-like body in the “​Toy Story” animation, creating an unusual artificial monster. It plays electronic sounds while detecting changing smartphone axes by receiving OSC data from an OSC app via WiFi. This gives it a live-creature quality while enabling remote control.

Wekinator is used as a machine learning toolkit to classify smartphone axis data, then send class results to Pure Data to control a speaker, two servos, and two DC motors on the Bela board.

Moving Instrumentbot demo

Moving Instrumentbot Christmas demo Moving Instrumentbot view 2 Moving Instrumentbot view 3 Moving Instrumentbot view 4 Moving Instrumentbot view 5 Moving Instrumentbot view 1

Figure 1. Images above show both inside and outside of the moving instrumentbot.

Mechanism and Construction

Construction 5 Construction 4 Construction 3 Construction 2 Construction 1 ESP32 inside instrumentbot

Theory of Motor Control

v1.0 Arduino (ESP32) Version

Components and Supplies

What Does It Do?

This instrumentbot is controlled remotely via a webpage running on a portable device under the same network.

The project combines these topics:

  • Uploading a customized webpage with multiple control buttons to the robot server.
  • Controlling DC motors with the L293D H-Bridge IC by outputting PWM to ENABLE pins and digital high/low values to INPUT pins.

The instrumentbot is curious about everything around it and wants to start its adventurous trip. However, it doesn’t know the correct direction to adventure and thus rely heavily on audience’s instructions to help it find out a suitable way to move.

The interaction flow:

  • A control webpage is served from the robot IP and accessed by smartphones on the same SSID.
  • The robot moves forward, backward, left, or right according to mobile browser commands.
  • The robot rotates its eyeball (two servos) once it stops moving.

ESP32 Pin Connection

ESP32 pin map reference: ESP32 Diagram

ESP32 pin connection

Simple Webpage Controller

The webpage is built and uploaded to the robot server via Arduino code.

Implementation: Arduino Code

v2.0 Bela Board Version

Components and Supplies

What Does It Do?

This instrumentbot is controlled remotely by smartphone accelerometer orientation on the same network. Audience can control the robot by turning the phone up, down, left, or right.

The project combines these topics:

  • Setting up the WiFi function on Linux operating system, which is run by Bela board, by editing its network interface after plugging the USB WiFi dongle into the Bela board.
  • Training the axis data received from the smartphone’s OSC application by Wekinator.
  • Controlling DC Motors with the L293D H-Bridge IC by generating PWM with a specific duty cycle by Pure Data to its ENABLE pins and digital high or low value to its INPUT pins.

There are three Pd patches in the interaction pipeline: getOSC.pd, sendOSCToWek.pd (local), and _main.pd (on Bela).

Interaction logic:

  • OSCHook App sends the axis data of the smartphone’s accelerator in OSC format to getOSC.pd.

  • getOSC.pd unpacks the axis data and only sends the number value to sendOSCToWek.pd.

  • sendOSCToWek.pd then sends pure number data receiving from getOSC.pd to Wekinator and listens to the same port(6448) as Wekinator’s.

  • Wekinator outputs the trained data in the format of class(1 to 5) to _main.pd run by Bela board installed on the instrumentbot.

  • The robot moves when it receives commands from the _main.pd which value of the class data is received from Wekinator.

  • Robot behaviors based on different class values:

    • Phone flat: robot stays still and looks around.
    • Phone upside down: robot moves forward and stops looking around.
    • Phone vertical against table: robot moves backward.
    • Phone tilted right: robot turns right.
    • Phone tilted left: robot turns left.

Bela Board Pin Connection

Bela reference: Bela Cape Diagram

Bela board pin connection

Implementation: Pd OSC Communication and Machine Learning Toolkit (Wekinator)

Pure Data, Wekinator, USB WiFi flow

Step 0. Connecting Bela to WiFi

Tutorial: Connecting Bela to WiFi

Edit Bela’s network interface following the tutorial after plugging the USB WiFi dongle into the Bela board.

Step 1. Initialize Bela pin mode

Pd part 1

Step 2. Generate PWM for two servos

Generate PWM and output it to control the angle of two servos.

Pd part 7

Step 3. Generate PWM for L293D ENABLE pins

Generate PWM and output it to L293D’s ENABLE pins to control the speed of DC motors.

Pd part 6

Step 4. Send smartphone OSC data to getOSC Pd patch

Send accelerator data in OSC format from smartphone’s OSC App to PC which runs getOSC.pd.

OSC app 1 OSC app 2 OSC app 3

Step 5. Reorganize axis data as pure floats

PC receives axes’ data from the smartphone and reorganizes it into pure floating-point values.

Pd getOSC

Step 6. Send pure axis data to Wekinator

Wekinator gets pure axis data from sendOSCToWek.pd running on the same port.

Pd send OSC to Wekinator

Step 7. Use classes to drive motors and speaker frequency

The values of L293D’s four INPUT pins are set high or low according to the type of output classes trained by Wekinator. The frequency played by the speaker is also controlled by it.

Pd part 5