def stopSIPServer(self):
        try:
            self.processSiprtmp.send_signal(signal.SIGINT)
        except Exception as e:
            print "ERROR when killing a siprtmp. "+str(e)

        try:
            self.processLinphone.send_signal(signal.SIGINT)
        except Exception as e:
            print "ERROR when killing a linphone. "+str(e)

        try:
            self.processSipd.send_signal(signal.SIGINT)
        except Exception as e:
            print "ERROR when killing a sipd. "+str(e)

	# We go back to the default audio control
        cmd = "roslaunch qbo_audio_control audio_control_listener.launch"
        try:
            subprocess.Popen(cmd.split(),env=self.envi)
        except:
            print "ERROR when launching audio_control_listener.launch"+str(e)            

        # ECO cancelation off
        if self.ecoCancelationId != "notDefined":
            print "ECO Cancelation off "+str(self.ecoCancelationId)
            cmd = "pactl unload-module "+self.ecoCancelationId
            out = runCmd(cmd)
            #print "salida "+str(out)
            print "Done"
Пример #2
0
    def stopSIPServer(self):
        try:
            self.processSiprtmp.send_signal(signal.SIGINT)
        except Exception as e:
            print "ERROR when killing a siprtmp. " + str(e)

        try:
            self.processLinphone.send_signal(signal.SIGINT)
        except Exception as e:
            print "ERROR when killing a linphone. " + str(e)

        try:
            self.processSipd.send_signal(signal.SIGINT)
        except Exception as e:
            print "ERROR when killing a sipd. " + str(e)

# We go back to the default audio control
        cmd = "roslaunch qbo_audio_control audio_control_listener.launch"
        try:
            subprocess.Popen(cmd.split(), env=self.envi)
        except:
            print "ERROR when launching audio_control_listener.launch" + str(e)

        # ECO cancelation off
        if self.ecoCancelationId != "notDefined":
            print "ECO Cancelation off " + str(self.ecoCancelationId)
            cmd = "pactl unload-module " + self.ecoCancelationId
            out = runCmd(cmd)
            #print "salida "+str(out)
            print "Done"
Пример #3
0
def main():
    
    global client_speak
    global language
    
    rospy.init_node("music_master")
    print "Starting Master Listener Node"
    
    rospy.Subscriber("/hand_gesture_node/hand_gesture", String, hand_gesture_callback)  
    client_speak = rospy.ServiceProxy("/qbo_talk/festival_say_no_wait", Text2Speach)
    
    runCmd("xmms2-launcher")


    lang = rospy.get_param("/system_lang", "en")

    loadDictionary(lang)

    speak_this(language["I AM READY TO PLAY MUSIC"])
   
    rospy.Subscriber("/system_lang", String, change_lang_callback)
 
    rospy.spin()
    runCmd("nyxmms2 stop")
Пример #4
0
def get_song_info_2():
    (ph_out, ph_err, ph_ret) = runCmd("nyxmms2 list")
    out_str = str(ph_out)
    
    song_info = out_str.split("->")
    song_info = song_info[1]
    song_info = song_info.split("]")
    song_info = song_info[1]
    song_info = song_info.split("(")
    song_info = song_info[0]
    
    song_info = song_info.strip()
    
    song_info = song_info.split(" - ")
    
    print "Artist: "+song_info[0]+ ", Song: "+song_info[1]
    
    return song_info
Пример #5
0
    def startSIPServer(self, data):
        print "Start sip server"
        path2webi = roslib.packages.get_pkg_dir("qbo_webi")

        chars = string.ascii_letters + string.digits

        self.envi = environ.copy()
        path = self.envi["PYTHONPATH"]
        self.envi[
            "PYTHONPATH"] = "/opt/ros/hydro/stacks/qbo_webi/src/teleoperation/sip2rtmp/p2p-sip:/opt/ros/hydro/stacks/qbo_webi/src/teleoperation/sip2rtmp/p2p-sip/src:/opt/ros/hydro/stacks/qbo_webi/src/teleoperation/sip2rtmp/p2p-sip/src/app:/opt/ros/hydro/stacks/qbo_webi/src/teleoperation/sip2rtmp/p2p-sip/src/external:/opt/ros/hydro/stacks/qbo_webi/src/teleoperation/sip2rtmp/rtmplite:" + path

        self.auth = "notDefined"
        self.authBot = "notDefined"

        self.auth = "".join(choice(chars) for x in range(randint(4, 4)))
        self.authBot = "".join(choice(chars) for x in range(randint(4, 4)))

        # We check if sipd is already active, if so, we close it
        cmd = "ps -aux | grep sipd"
        out = runCmd(cmd)
        out = out[0]

        if "sipd.py" in out:
            pid = out.split(" ")[2]
            os.kill(int(pid), signal.SIGTERM)

        # The same with siprtmp
        cmd = "ps -aux | grep siprtmp"
        out = runCmd(cmd)
        out = out[0]

        if "siprtmp.py" in out:
            pid = out.split(" ")[2]
            os.kill(int(pid), signal.SIGTERM)

        # Launch audio control with sip profile
        cmd = "roslaunch qbo_audio_control audio_control_sip.launch"
        self.processAudioControl = subprocess.Popen(cmd.split(), env=self.envi)

        # Launch sipd.py
        cmd = "python " + path2webi + "/src/teleoperation/sip2rtmp/p2p-sip/src/app/sipd.py -u " + self.auth + " -b " + self.authBot
        self.processSipd = subprocess.Popen(cmd.split(), env=self.envi)

        # Launch siprtmp.py
        cmd = "python " + path2webi + "/src/teleoperation/sip2rtmp/rtmplite/siprtmp.py"
        self.processSiprtmp = subprocess.Popen(cmd.split(), env=self.envi)

        # We give them sometime to finish the job
        time.sleep(0.5)

        # Data ready for the node qbo_linphone, but we still need to know the host
        rospy.set_param("linphone_botName", self.authBot)
        rospy.set_param("linphone_host",
                        "waiting for the mobile to know the IP")

        # ECO cancelation on
        if data['ecoCancelation']:
            cmd = "pactl load-module module-echo-cancel"
            out = runCmd(cmd)
            self.ecoCancelationId = out[0].replace("\n", "")
            print "ECO cancelation ON " + str(self.ecoCancelationId)
    def startSIPServer(self,data):
        print "Start sip server"
        path2webi = roslib.packages.get_pkg_dir("qbo_webi")

        chars = string.ascii_letters + string.digits

        self.envi = environ.copy()
        path = self.envi["PYTHONPATH"]
        self.envi["PYTHONPATH"] = "/opt/ros/electric/stacks/qbo_stack/qbo_webi/src/teleoperation/sip2rtmp/p2p-sip:/opt/ros/electric/stacks/qbo_stack/qbo_webi/src/teleoperation/sip2rtmp/p2p-sip/src:/opt/ros/electric/stacks/qbo_stack/qbo_webi/src/teleoperation/sip2rtmp/p2p-sip/src/app:/opt/ros/electric/stacks/qbo_stack/qbo_webi/src/teleoperation/sip2rtmp/p2p-sip/src/external:/opt/ros/electric/stacks/qbo_stack/qbo_webi/src/teleoperation/sip2rtmp/rtmplite:"+path


        self.auth = "notDefined"
        self.authBot = "notDefined"

        self.auth = "".join(choice(chars) for x in range(randint(4, 4)))
        self.authBot = "".join(choice(chars) for x in range(randint(4, 4)))


        # We check if sipd is already active, if so, we close it        
        cmd = "ps -aux | grep sipd"
        out = runCmd(cmd)
        out = out[0]

        if "sipd.py" in out:
            pid = out.split(" ")[2]
            os.kill(int(pid), signal.SIGTERM)

        # The same with siprtmp
        cmd = "ps -aux | grep siprtmp"
        out = runCmd(cmd)
        out = out[0]

        if "siprtmp.py" in out:
            pid = out.split(" ")[2]
            os.kill(int(pid), signal.SIGTERM)  

        # Launch audio control with sip profile
        cmd = "roslaunch qbo_audio_control audio_control_sip.launch"
        self.processAudioControl = subprocess.Popen(cmd.split(),env=self.envi)

        # Launch sipd.py
        cmd = "python "+path2webi+"/src/teleoperation/sip2rtmp/p2p-sip/src/app/sipd.py -u "+self.auth+" -b "+self.authBot
        self.processSipd = subprocess.Popen(cmd.split(),env=self.envi)

        # Launch siprtmp.py
        cmd = "python "+path2webi+"/src/teleoperation/sip2rtmp/rtmplite/siprtmp.py"
        self.processSiprtmp = subprocess.Popen(cmd.split(),env=self.envi)

        # We give them sometime to finish the job
        time.sleep(0.5)

        # Data ready for the node qbo_linphone, but we still need to know the host
        rospy.set_param("linphone_botName",self.authBot)
        rospy.set_param("linphone_host","waiting for the mobile to know the IP")

        # ECO cancelation on
        if data['ecoCancelation']:
            cmd = "pactl load-module module-echo-cancel"
            out = runCmd(cmd);
            self.ecoCancelationId = out[0].replace("\n","")
            print "ECO cancelation ON "+str(self.ecoCancelationId)
Пример #7
0
def hand_gesture_callback(data):
    
    global language
    command = str(data.data)
    

    rospy.loginfo(rospy.get_name()+": I heard %s",command)
    
    global playing_music
    global music_volume
    
     
    if command == "play":
        
        runCmd("nyxmms2 toggle")
        
        if playing_music :
            speak_this(language["MUSIC PAUSE"])
            playing_music = False
        else:
            runCmd("nyxmms2 play")
            song_info = get_song_info_2()
            speak_this(language["PLAYING"]+" "+song_info[1]+" "+language["BY"]+" "+song_info[0])
            playing_music = True
        
    
    elif command == "stop":
        runCmd("nyxmms2 "+command)  
        speak_this(language["MUSIC STOPPED"])
        playing_music = False
    
    elif command == "next" or command == "prev":
        runCmd("nyxmms2 "+command)        
        if playing_music:
            time.sleep(1)
            song_info = get_song_info_2()
            speak_this(language["PLAYING"]+" "+song_info[1]+" "+language["BY"]+" "+song_info[0])
        else:
            time.sleep(1)
            song_info = get_song_info_2()
            speak_this(language["SONG SELECTED"])
	    speak_this(song_info[1]+" "+language["BY"]+" "+song_info[0])
         
    elif command=="volume_up":
        if music_volume<=80:
            music_volume+=20
        runCmd("nyxmms2 server volume "+str(music_volume))
        speak_this(language["VOLUME UP"])
    
    elif command=="volume_down":
        if music_volume>20:
            music_volume-=20
        runCmd("nyxmms2 server volume "+str(music_volume)) 
        speak_this(language["VOLUME DOWN"])