Dancing With Music!
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_music_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_music_dance.ipynb
- Running the cell codeCtrl + Enter
To control the robot arm from code, don’t forget to shut down the docker container. See here.
Robot arm dance example with an exciting music.
Load Arm_Lib module and register the robot arm as an object.
import os
import time
from Arm_Lib import Arm_Device
# Register robot arm object
Arm = Arm_Device()
time.sleep(.1)
Move servo to initial position.
# Move servo to initial position.
Arm.Arm_serial_servo_write6(0, 90, 0, 180, 90, 90, 2000)
Play the music and the dance at the same time.
os.system('rostopic pub -1 /play_specific std_msgs/String "data: \'/root/scripts/sensor/arm_sounds/music_cari.mp3\'"')
# Servo range : 0~180
Arm.Arm_serial_servo_write6(90, 90, 90, 90, 90, 90, 1600)
time.sleep(1.61)
Arm.Arm_serial_servo_write6(180, 90, 0, 180, 90, 90, 1600)
time.sleep(1.61)
Arm.Arm_serial_servo_write6(90, 90, 90, 90, 90, 90, 1600)
time.sleep(1.61)
Arm.Arm_serial_servo_write6(0, 90, 0, 180, 90, 90, 1600)
time.sleep(1.61)
Arm.Arm_serial_servo_write6(90, 90, 90, 90, 90, 90, 1600)
time.sleep(1.61)
Arm.Arm_serial_servo_write6(180, 90, 0, 180, 90, 90, 1600)
time.sleep(1.61)
Arm.Arm_serial_servo_write6(90, 90, 90, 90, 90, 90, 1600)
time.sleep(1.61)
Arm.Arm_serial_servo_write6(90, 90, 0, 90, 90, 90, 600)
time.sleep(0.82)
Arm.Arm_serial_servo_write6(90, 90, 0, 180, 90, 90, 600)
time.sleep(0.82)
Arm.Arm_serial_servo_write6(0, 90, 0, 180, 0, 180, 600)
time.sleep(0.82)
Arm.Arm_serial_servo_write6(90, 90, 0, 180, 90, 90, 600)
time.sleep(0.82)
Arm.Arm_serial_servo_write6(180, 90, 0, 180, 180, 180, 600)
time.sleep(0.82)
Arm.Arm_serial_servo_write6(90, 90, 0, 180, 90, 90, 600)
time.sleep(0.82)
Arm.Arm_serial_servo_write6(90, 90, 90, 90, 90, 90, 600)
time.sleep(0.82)
Arm.Arm_serial_servo_write6(90, 90, 0, 180, 90, 90, 600)
time.sleep(0.82)
Arm.Arm_serial_servo_write6(0, 90, 0, 180, 0, 180, 600)
time.sleep(0.82)
Arm.Arm_serial_servo_write6(90, 90, 0, 180, 90, 90, 600)
time.sleep(0.82)
Arm.Arm_serial_servo_write6(180, 90, 0, 180, 180, 180, 600)
time.sleep(0.82)
Arm.Arm_serial_servo_write6(90, 90, 0, 180, 90, 90, 600)
time.sleep(0.82)
Arm.Arm_serial_servo_write6(180, 90, 0, 180, 180, 180, 600)
time.sleep(0.82)
Arm.Arm_serial_servo_write6(90, 90, 0, 180, 90, 90, 600)
time.sleep(0.82)
Arm.Arm_serial_servo_write6(0, 90, 0, 180, 0, 180, 600)
time.sleep(0.82)
Arm.Arm_serial_servo_write6(90, 90, 0, 180, 90, 90, 600)
time.sleep(0.82)
Arm.Arm_serial_servo_write6(90, 90, 0, 90, 90, 90, 1500)
time.sleep(1.5)
Arm.Arm_serial_servo_write6(90, 90, 0, 90, 90, 180, 500)
time.sleep(1)
os.system('rostopic pub -1 /play_specific std_msgs/String "data: \'stop\'"')