Cant play a sound on the turtlebot and i am getting the error "sound command issued, but no node is subsribed to the topic. Perhaps you forgot to run soundplay_node.py"

asked 2019-12-11 03:05:57 -0500

hamzaay gravatar image

I am trying to get a sound on the turtlebot and after seeing various post and tutorials I have come up with this code:

#include <ros/ros.h>
#include <std_msgs/String.h>
#include "sound_play/sound_play.h"
#include <actionlib/client/simple_action_client.h>
#include <sound_play/SoundRequestAction.h>
#include <kobuki_msgs/Sound.h>


std::string path_to_sounds;


int main(int argc, char ** argv) {
    ros::init(argc, argv, "example");

ros::NodeHandle n;    



ros::Publisher sound_pub= n.advertise<kobuki_msgs::Sound>("commands/sound", 4);

sound_play::SoundClient sc;


sound_play::SoundRequestGoal goal;

path_to_sounds = "/home/ros/jukebot/src/sound_play/sounds/";


sc.playWave(path_to_sounds+"Megalovania.wav");

sc.playWaveFromPkg("sound_play", "Megalovania.wav");   // did this twice to make sure that either one of them works

    ros::spin();



    ros::spin();
}

In the package.xml i have included

<build_depend>sound_play</build_depend>
<exec_depend>sound_play</exec_depend>

It builds but when i try to run the code it doesnt publish to kobuki/commands/sound as i wanted to (can see that from the RQT). Also my terminal says:

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

I dont know what I am doing wrong and the knowlegde I have gathered so far was what i got from looking at previous questions. So this is a dead end for me.

Is the reason it doesnt play the sound because turtlebot cant take sounds in of the form Wav? I have read that the turtlebot have programable sounds, so if my approach is wrong how can I make programable sounds?

edit retag flag offensive close merge delete