ROS and sounds or how to make your droid to say the Dalek Exterminate!!!

Audio feedback from your robot

Intro

After our previous post where Bence explained that roboticists should be careful doing scary stuff with their robot, I thought I need to do some with mine to troll ourselves. So why shouldn’t my robot sound like this when it is moving:

 

 

Uncanny valley

Before I jump to the technical details, I would like to ask why do we get scared when a humanoid robot says it will destroy the world?
My opinion is we over-estimate the capabilities of humanoid robots because they look like us. The short explanation to the uncanny valley[1] is, anything that is close to look like human, will make us to believe it is really a human. If it says/do/look good we will think it is cute, if it is says/do/look bad, then it will be creepy.

I would like to recommend two articles in this topic, which explains more of this matter .
Why Are People Afraid of Robots?
We’re Scared of Robots Because We’re Scared of Humans

What can we do to not creep out? Learn more about it! It makes us more comfortable when we don’t have to face with the unknown.
Otherwise in case of robot apocalypse:

Know your paradoxes! Thanks One Girl Geek for the picture
Know your paradoxes! Thanks One Girl Geek for the picture![2]

Exterminate!!!

Background

I wanted to get sound feedback from my robot (and of course to hear some cool effects while doing different jobs), I have decided to buy USB powered speakers and a USB soundcard to easily attach them to my embedded systems.

Sound play

Bence told me I could use the sound play[3] ROS library for playing sounds on my robot.
So I did a

sudo apt-get install ros-indigo-sound-play 

and tried out

odroid@odroid:~$ rosrun sound_play say.py 'Hello world'
Unable to register with master node [http://localhost:11311]: master may not be running yet. Will keep trying.

My bad, in a different terminal I have started the rosmaster

roscore

and tried once more

odroid@odroid:~$ rosrun sound_play say.py 'Hello world'
Saying: Hello world
Voice: voice_kal_diphone
Traceback (most recent call last):
  File "/opt/ros/indigo/lib/sound_play/say.py", line 79, in 
    print 'Volume: %s' % volume
NameError: name 'volume' is not defined

Hmm this looks like an issue, lets google on it. Result was http://answers.ros.org/question/225722/volume-error-using-sound_play/
This is a bug[4] so I have to clone out the latest repo where it was fixed.

git clone https://github.com/ros-drivers/audio_common.git

After I did a

catkin_make 

on my workspace to build the newly cloned out sound play

odroid@odroid:~/hot_wheels/hotwheels_ws$ rosrun sound_play say.py 'Hello world'
Saying: Hello world
Voice: voice_kal_diphone
Volume: 1.0
[WARN] [WallTime: 1460879661.468217] Sound command issued, but no node is subscribed to the topic. Perhaps you forgot to run soundplay_node.py?

Hmm I see, it is time to read the manuals. “The following utilities can be used to play sound when soundplay_node.py is running. For help on getting soundplay_node.py running refer to the tutorial.”
Ok lets see the tutorial . I have followed it:

$ rosdep install sound_play
$ rosmake sound_play  
odroid@odroid:~$ cat /proc/asound/cards
 0 [odroidaudio    ]: odroid-audio - odroid-audio
                      odroid-audio
 1 [CameraB409241  ]: USB-Audio - USB Camera-B4.09.24.1
                      OmniVision Technologies, Inc. USB Camera-B4.09.24.1 at usb-xhci-hcd.2.auto-1.1.
 2 [Device         ]: USB-Audio - PrimeSense Device
                      PrimeSense PrimeSense Device at usb-xhci-hcd.2.auto-1.1.3, high speed
 3 [Device_1       ]: USB-Audio - USB PnP Sound Device
                      USB PnP Sound Device at usb-xhci-hcd.2.auto-1.1.1.4, full speed

My usb device is the 3rd one. This will be very easy.

odroid@odroid:~/hot_wheels/hotwheels_ws$ asoundconf set-default-card 3
-bash: asoundconf: command not found

Or maybe not… hello google my old friend. I’ve figured out I should not use the Alsa commands, but instead the Pulse audio[5].

odroid@odroid:~/hot_wheels/hotwheels_ws$  pacmd list-sources | grep -e device.string -e 'name:'
        name: 
                device.string = "0"
        name: 
                device.string = "3"
        name: 
                device.string = "hw:3"
        name: 
                device.string = "hw:1"
        name: 
                device.string = "front:2"
odroid@odroid:~/hot_wheels/hotwheels_ws$ pacmd set-default-source alsa_input.usb-OmniVision_Technologies__Inc._USB_Camera-B4.09.24.1-01-CameraB409241.analog-4-channel-input
Welcome to PulseAudio! Use "help" for usage information.
>>> >>> odroid@odroid:~/hot_wheels/hotwheels_ws$
odroid@odroid:~/hot_wheels/hotwheels_ws$ pacmd list-sinks | grep -e 'name:' -e 'index'
  * index: 0
        name: 
    index: 1
        name: 
odroid@odroid:~/hot_wheels/hotwheels_ws$ pacmd set-default-sink alsa_output.usb-0d8c_USB_PnP_Sound_Device-00-Device_1.analog-stereo
Welcome to PulseAudio! Use "help" for usage information.

I have also started a this in a different terminal:

rosrun sound_play soundplay_node.py

I hope everything is in place now, let’s see it:

odroid@odroid:~/hot_wheels/hotwheels_ws$ rosrun sound_play say.py "hello world"
Saying: hello world
Voice: voice_kal_diphone
Volume: 1.0

I can hear it, it worked!

Let it be Dalek

Finally at the point where I can play sounds on the robot, I have searched and found the Dalek exterminate audio . I have downloaded and converted to wav format.

rosrun sound_play play.py /home/odroid/Downloads/s1_06_aud_03.wav

Muhahaha one step closer to be evil genius and to take over the world.

Powerup a Madcat

After my short burst of joy caused by the success, I have decided to play one of my childhood memory sound at the startup. Back in my young days I have played with the Mechwarrior 2, this is what I’ve heard a lot of time:

Let it be Madcat!

Whenever the rover starts up ROS I would like to hear the power up sound from the video above . There are at least two ways to achieving it. One is I have to create a ROS node which checks if any other node started to subscribe to the topic for the soundplay (in my case /robotsound). If yes, then plays the sound. Another way (which is the shortest and dirtiest to do it) is to create a script that publish the correct information to the /robotsound topic.

I have choosen the script way to do it, but later I will do a proper solution.

#!/bin/bash
sleep 3
rostopic pub /robotsound sound_play/SoundRequest "{sound: -2,command: 2, volume: 1.0, arg: '/home/odroid/Downloads/mechwstartup.ogg', arg2: ''}"

Also addition to my launch file:

<include file="$(find sound_play)/soundplay_node.launch"/>
<node name="foo" pkg="hotwheels_start" type="mechwstart.sh"/>

The next step will be to use the microphones on the robot to hear it’s surrounding.

References:
[1] https://en.wikipedia.org/wiki/Uncanny_valley
[2] http://www.onegirlgeek.com/2011/07/13/wallpapers-doctor-who-portal-totoro-and-more/
[3] http://wiki.ros.org/sound_play
[4] http://answers.ros.org/question/225722/volume-error-using-sound_play/
[5] https://wiki.archlinux.org/index.php/PulseAudio/Examples.

Advertisements

One thought on “ROS and sounds or how to make your droid to say the Dalek Exterminate!!!

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s