ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

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 image BennyRe  ( 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 image pwong  ( 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 image BennyRe  ( 2014-06-05 01:57:06 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-02-03 12:16:48 -0600

Idox gravatar image

updated 2021-02-03 12:23:59 -0600

Put rospy.sleep(1) after calling SoundClient()

You were right about the sleep but not about the location possibly.

With that there is no need for the while loop.

So Make sure you are sourced. Make sure roscore is up.

run:

rosrun sound_play soundplay_node.py

then run your program.

edit flag offensive delete link more

Question Tools

1 follower

Stats

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

Seen: 2,891 times

Last updated: Feb 03 '21