Dancing Robot (WIP)

by lbjiang in Circuits > Robots

7 Views, 0 Favorites, 0 Comments

Dancing Robot (WIP)

tumbller "dancing" (WIP)

The following page will explain the work done on programming the Elegoo Tumbller to respond to different volumes and frequencies to "dance" to music. This is a work in progress, so possible future steps to improve this project will be explained.

Supplies

elegoo_tumbller.jpg

HARDWARE

  1. Elegoo Tumbller
  2. Computer with a built-in microphone
  3. OPTIONAL (but recommended): pair of disposable chopsticks, zipties

SOFTWARE

  1. Arduino IDE
  2. Python (and a compatible code editor)

Assemble the Robot

elegoo_tumbller_circled.jpg
training_wheels.png

Follow the instructions to assemble the Elegoo Tumbller. However, skip installing the ultrasonic sensor (circled in yellow) and the plastic plate (circled in red).

OPTIONAL (but recommended): Install "training wheels" by attaching chopsticks to the robot with zipties, as pictured above.

Set Up Your Arduino Environment

Extract the contents of the linked zip file (final_project_arduino.zip) into your Arduino folder. There should be four folders: libraries, final_project, imu_zeros, calibrate_encoders3.

Open final_project.ino. You will need to use a new board package to use the second core on the Arduino RP2040 on the Elegoo Tumbller. Follow the directions here to install it.

Note that while there is code started for the robot to balance via dynamic control, this has been overridden by setting a constant "command" input to the motors. As a result, the robot will respond while dragging on its "training wheels" rather than standing.

(The custom library files and much of the code base is attributed to Prof. Chris Atkeson from the course 16299 at CMU.)

Upload the Arduino Code to Your Robot

Upload final_project.ino to your Elegoo Tumbller via tethered cord. Note the port name (mine was "COM11", for Linux based systems, the port name typically starts with "tty").

Feel free to test that your code is working by manually typing commands into the Serial Monitor ('f' for forward, 'b' for backward', 'l' for turn left, and 'r' for turn right). Make sure your battery is turned on so that the motors are receiving full power.

Close Arduino IDE so that access to the port isn't blocked.

Open Your Python Code Editor and Copy the Code.

Download the code from "final_project.py". Make sure that sounddevice, numpy, pyserial, and scipy are installed via pip.

Downloads

Watch the Robot Dance!

Run the Python code. Now, you can play music or sing to the robot and watch it respond!

The robot should stay still when there is no sound playing. You may need to adjust your VOLUME_THRESHOLD accordingly.

Improve the Robot's Dancing Abilities

Many possible steps can be taken to improve the robot's dancing abilities. I've described a few of them here.

  1. Debug the current final_project.ino code so that the robot balances upright while moving:
  2. There is code for the robot to calculate the command needed to send to the motors under the function "getCommand(...)", with global variables declared outside. Currently, it's calculating much lower commands than are actually needed to balance the robot, though it does seem to be responding to changes in angle.
  3. Gains may need to be re-tuned, either manually or by developing a better model of the system.
  4. Make sure to calibrate the imu (code supplied in imu_zeros) and the encoders (coded supplied in calibrate_encoders3).
  5. Refine the robot movement:
  6. Code for the robot response is in final_project.py. Currently, certain movements are hard-coded to frequency ranges, with some toggle between forward/backward and turning left/right.
  7. An idea for robot movement is to keep track of changes in frequency to trigger movement instead (logging the prev freq, and if the current frequency is different by some degree, changing the movement)
  8. Untether the robot:
  9. Program the robot to communicate wirelessly.