sound play repeat and first subscribe error

asked 2014-06-03 22:26:53 -0600

pwong gravatar image

I'm using the sound play package to pause/play/repeat/stop sounds.

http://wiki.ros.org/sound_play

Its being written in python and there's a couple issues I'm having using this package.

  1. I need to first play a sound and receive an error, before it'll work. This is the error

    [ERROR] [WallTime: 1401851197.944862] Sound command issued, but no node is subscribed to the topic. Perhaps you forgot to run soundplay_node.py

  2. Secondly, the .startWave doesn't work for me. It plays once and stops.

Here's the code I've written to get this going.

rospy.init_node('audio')
ready = rospy.Subscriber("robotsound", SoundRequest, sound_ready)

r = rospy.Rate(1) 

#I've tried to do a sleep here, but it didn't fix the issue
sound_client = SoundClient()

#This checks for when soundplay_node.py is subscribed
while(ready.get_num_connections() < 1):
    sound_client.playWave("/absolute/path/to/wav/file")
    rospy.sleep(1)

sound_client.startWave("/absolute/path/to/wav/file")
while not rospy.is_shutdown():
    r.sleep()

I ran into the same problems on c++ as well. The only difference is a warning is produced instead of an error. This leads me to believe I'm just not using it correctly... If anyone can offer help, I'd appreciate it!

edit retag flag offensive close merge delete

Comments

Did you first of all launch the soundplay_node with roslaunch sound_play soundplay_node.launch?

BennyRe gravatar imageBennyRe ( 2014-06-04 01:51:38 -0600 )edit

I ran it with "rosrun audio_signature ros_play_audio.py " which would be the same thing? I just tried with the launch file instead, and I got the same results/errors I did before.

pwong gravatar imagepwong ( 2014-06-04 11:56:01 -0600 )edit

Don't known if it's the same, I can't find the audio_signature package. Does the test test.py in the sound_play package work?

BennyRe gravatar imageBennyRe ( 2014-06-05 01:57:06 -0600 )edit