ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org
Ask Your Question
0

audio_common "Perhaps you forgot to run soundplay_node.py"

asked 2020-04-17 09:13:02 -0600

eliza gravatar image

Hi Everyone

I am new to ROS and cpp so please be patient ;)

I work with Ubuntu 18.04.4 LTS and ROS Melodic. I installed audio_commen with command sudo apt-get install ros-melodic-audio-common according the side link

After some hours of trying I created completely new package just for this function to eliminate other factors and at the moment it looks pretty simple.

node code:

   #include "ros/ros.h"
   #include <sound_play/sound_play.h>

   int main(int argc, char **argv)  {

   ros::init(argc,argv,"audio_common_tutorial");
   ros::NodeHandle n;

   sound_play::SoundClient sc;
   sc.playWaveFromPkg("sound_play", "sounds/BACKINGUP.ogg");
   sc.playWave( "/home/ntuser/catkin_ws/src/audio_common_tutorial/doc/file.wav");

   ros::spin();
   return 0;
   }

I am starting the nodes with launch file:

   <launch>
   <include file="$(find sound_play)/soundplay_node.launch">  </include>

  <node pkg="order_receiver" type="order_receiver" name="order_receiver" output="screen">
   <rosparam command="load" file="$(find order_receiver)/config/default.yaml" />
   </node>
   </launch>

both sounds command failed

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

even thouth the node is listed by launching and after command rosnode list

The package WORKS good from command line e.g rosrun sound_play play.py "path" or roslaunch sound_play test.launch

Any ideas and recommendation?

regards

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-04-20 02:12:20 -0600

eliza gravatar image

Hi everyone

I solve it. It looks like I need a give a some time to initialize SoundClient. After I implemented a delay before issuing a sound ,everything works.

The code look as follow:

#include "ros/ros.h"
#include <sound_play/sound_play.h>

int main(int argc, char **argv)  {

ros::init(argc,argv,"audio_common_tutorial");
ros::NodeHandle n;

sound_play::SoundClient sc;
ros::Duration(1, 0).sleep();
sc.playWaveFromPkg("sound_play", "sounds/BACKINGUP.ogg");
sc.playWave( "/home/ntuser/catkin_ws/src/audio_common_tutorial/doc/file.wav");

ros::spin();
return 0;
}

If anyone has some smart comment why it is so I am happy to hear it ;)

regards

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2020-04-17 09:13:02 -0600

Seen: 299 times

Last updated: Apr 20 '20