Code Explanation
Overall Explanation
With our follow along examples, we were able to move our robot arm with precision as well as produce music with our integrated speaker within the zetabot.
The instructional codes have been compile into a jupyter notebook for the ease of use.
This section will explain the libraries used for the follow along section.
Sound
For our dancing robot demonstration, we published an array of integer to ROS Topic called
/play_specific.
os.system('rostopic pub -1 /play_specific std_msgs/String "data: \'/root/scripts/sensor/arm_sounds/music_1.mp3\'"')
The
play_specifictopic publishes messages to the play_sound node. You can play a sound file by entering the absolute path of the sound file.
os.system('rostopic pub -1 /play_specific std_msgs/String "data: \'stop\'"')
Or you can stop the currently playing music with the stop command.
!ls /root/scripts/sensor/arm_sounds
The list of music files that can be played can be checked with the following command.