Note: This tutorial assumes that you have completed the previous tutorials: ROS tutorials.

How to Configure and Use Speakers with sound_play

Description: This tutorial is an introduction to setting up and using USB speakers connected to a desktop computer. After reading it, you should be able to bring up the speakers, configure the speakers, and play sounds.

Keywords: sound, speakers, driver

Tutorial Level: BEGINNER

Compiling

$ rosdep install sound_play
$ rosmake sound_play

Powered On and Plugged In

Make sure that your USB speakers are connected to your desktop and powered on.

You can check that the speaker/sound card is recognized by the unix kernel by using:

$ cat /proc/asound/cards

You will see something similar to:

  •  0 [Intel          ]: HDA-Intel - HDA Intel
                          HDA Intel at 0xfdff8000 irq 16
     1 [Speaker        ]: USB-Audio - Logitech USB Speaker
                          Logitech Logitech USB Speaker at usb-0000:00:1d.7-6.1.3, full speed

Configuring the Sound Driver to Use Your Speaker

To designate which sound card the driver uses, run:

$ asoundconf set-default-card [device #]

(i.e. In the above example, asoundconf set-default-card 0 would configure the driver to use the Intel card .)

This will create .asoundrc.asoundconf in your home directory. To make the driver use these settings, add the following line to ~/.asoundrc by using the command:

$ echo 'include ".asoundrc.asoundconf"' >> ~/.asoundrc

(Optional) To set this default to all users, copy this to the system-wide driver configuration file:

$ sudo cp ~/.asoundrc.asoundconf /etc/asound.conf

Starting a roscore

For sound_play to work properly, a ros core must be running. In a new terminal:

$ roscore

Starting the sound_play node

In another new terminal, start the sound_play node. This node will play sounds when it receives sound messages:

$ rosrun sound_play soundplay_node.py

You will see:

  • sound_play node is ready to play sound

Playing Sound

In a new terminal, test that your speaker is configured properly and playing sound. Try saying "hello world":

$ rosrun sound_play say.py "hello world"

You will see:

  • Saying: hello world

And you should hear "Hello world"

Troubleshooting

If you encounter problems in this Tutorial, have a look at the Troubleshooting page, it may have a solution for you.


Wiki: sound_play/Tutorials/ConfiguringAndUsingSpeakers (last edited 2009-10-22 16:35:09 by NateKoenig)