Dancing With Music 1!

Follow along: Robot Arm Dancing with music

The program launching process along with parameter settings are all simplified and set up on the Jupyter Notebook Environment.
  • Open the 05_09_carri_dance.ipynb Jupyter Notebook
  • Load Arm_Lib module and register the robot arm as an object
  • Initialize the sound file
  • Initialize the starting position of the robot arm
  • Play the music and the dance at the same time
(The Jetson Board used for these examples are => Jetson Nano)

  • 05_09_carri_dance.ipynb

  • Running the cell code
    Ctrl + Enter
  • Robot arm dance example with an exciting music - 1

  • Load Arm_Lib module and register the robot arm as an object

from pygame import mixer
import time
from Arm_Lib import Arm_Device

# register the robot arm as an object
Arm = Arm_Device()
time.sleep(.1)
  • Initialize the sound file

# Register ogg file
mixer.init(48000, 16, 2, 2048)
my_sound = mixer.Sound('music.ogg')
my_sound.set_volume(0.01)
  • Initialize the starting position of the robot arm

# Initialization
Arm.Arm_serial_servo_write6(90, 90, 90, 90, 90, 90, 1000)
  • Play the music and the dance at the same time

Arm.Arm_serial_servo_write6(90, 90, 90, 90, 90, 90, 1000)

while(1):
    my_sound.play()
    # 1번 동작
    Arm.Arm_serial_servo_write(3, 0, 1500)
    time.sleep(.001)
    Arm.Arm_serial_servo_write(4, 180, 1500)
    time.sleep(.001)
    Arm.Arm_serial_servo_write(1, 0, 1500)
    time.sleep(5.5)
    # 2번 동작
    Arm.Arm_serial_servo_write(1, 90, 500)
    time.sleep(1.5)
    # 3번 동작
    Arm.Arm_serial_servo_write(1, 180, 500)
    time.sleep(1.5)
    # 4번 동작
    Arm.Arm_serial_servo_write(3, 90, 500)
    time.sleep(.001)
    Arm.Arm_serial_servo_write(4, 90, 500)
    time.sleep(1.5)
    # 5번 동작
    Arm.Arm_serial_servo_write(3, 0, 500)
    time.sleep(.001)
    Arm.Arm_serial_servo_write(4, 180, 500)
    time.sleep(1.5)
    # 6번 동작
    Arm.Arm_serial_servo_write(1, 90, 1000)
    time.sleep(1.5)
    # 7번 동작
    Arm.Arm_serial_servo_write(1, 0, 1000)
    time.sleep(1.5)
    my_sound.stop()
    break

Arm.Arm_serial_servo_write6(90, 90, 90, 90, 90, 90, 1000)
  • Arm Movements

Arm.Arm_serial_servo_write(3, 0, 500)
time.sleep(.001)
Arm.Arm_serial_servo_write(4, 180, 500)
Arm.Arm_serial_servo_write(1, 0, 1000)
Arm.Arm_serial_servo_write6_array(joints_4, 1500)
Arm.Arm_serial_servo_write(3, 90, 500)
time.sleep(.001)
Arm.Arm_serial_servo_write(4, 90, 500)
Arm.Arm_serial_servo_write(3, 0, 500)
time.sleep(.001)
Arm.Arm_serial_servo_write(4, 180, 500)
  • Movement complete