def __init__(self):
     smach.State.__init__(self,
                          outcomes=['hide_done'],
                          input_keys=['hiding_places'],
                          output_keys=['hiding_places'])
     self.client = actionlib.SimpleActionClient('move_base', MoveBaseAction)
     self.soundhandle = SoundClient(blocking=True)
Beispiel #2
0
 def __init__(self):
     rospy.init_node('beep_engine')
     self.soundhandle = SoundClient()
     rospy.Subscriber("~beep", Beep, self.callback)
     self.beep_dir = rospy.get_param("~beep_dir")
     rospy.on_shutdown(self.shutdown)
     rospy.spin()
Beispiel #3
0
    def callback(self, signs):
                
        soundhandle = SoundClient()

        soundhandle.play(2)

        rospy.sleep(1)
Beispiel #4
0
    def __init__(self):

        # navigation dictonary
        raw_edges = rospy.get_param('~map/edges')
        raw_nodes = rospy.get_param('~map/nodes')
        self.graph = SupportBehaviorGraph(raw_edges, raw_nodes)
        self.current_node_id = rospy.get_param('~initial_node_id')
        self.pre_edge = None
        self.anchor_pose = None

        # silent mode
        self.silent_mode = rospy.get_param('~silent_mode', False)

        #
        self.tf_buffer = tf2_ros.Buffer()
        self.tf_listener = tf2_ros.TransformListener(self.tf_buffer)

        # get target action name list for synchronizer
        self.list_action_name_synchronizer = rospy.get_param(
            '~action_names_synchronizer', [])

        # action clients
        self.spot_client = SpotRosClient()
        self.sound_client = SoundClient(blocking=False,
                                        sound_action='/robotsound_jp',
                                        sound_topic='/robotsound_jp')

        # publisher
        self.pub_current_node_id = rospy.Publisher('~current_node_id',
                                                   String,
                                                   queue_size=1)

        # reset service
        self.service_reset_current_node_id = rospy.Service(
            '~reset_current_node_id', ResetCurrentNode,
            self.handler_reset_current_node_id)

        #
        self.set_anchor_pose()

        #
        roslaunch.pmon._init_signal_handlers()

        # subscribers
        self.list_behaviors_execution_actions = []
        for action_name in self.list_action_name_synchronizer:
            self.list_behaviors_execution_actions.append(
                rospy.Subscriber('{}/feedback'.format(action_name),
                                 LeadPersonActionFeedback,
                                 self.callback_synchronizer))

        # action server
        self.server_execute_behaviors = actionlib.SimpleActionServer(
            '~execute_behaviors',
            LeadPersonAction,
            execute_cb=self.handler_execute_behaviors,
            auto_start=False)
        self.server_execute_behaviors.start()

        rospy.loginfo('Initialized!')
    def __init__(self):

        msg = whereisthis()
        self.now_state = msg.GetPoint
        self.next_state = msg.DoorOpening
        self.Return_time = 0
        self.need_help = False
        self.control_sub = rospy.Subscriber("/whereisthis_control", whereisthis, self.controlCallback)
        self.control_pub = rospy.Publisher("/whereisthis_control", whereisthis, queue_size = 1)

        self.sh = SoundClient(blocking = True)
        self.voice = rospy.get_param("~voice", "voice_kal_diphone")

        msg.NowTask = msg.GetPoint
        msg.NextTask = msg.DoorOpening
        msg.NeedHelp = False
        msg.FinishState = False
        rospy.sleep(0.5)

        # self.sh.say('now please tell me where there information point is. If you are ready to response, please say jack to launch me first', self.voice)

        for i in range(5):
            self.control_pub.publish(msg)
        print("Start task Whereisthis...")
        print("----------GetPoint-----------")
Beispiel #6
0
    def __init__(self):
        rospy.on_shutdown(self.cleanup)

        self.voice = rospy.get_param(
            "~voice",
            "voice_kal_diphone")  #voice_don_diphone, voice_kal_diphone
        self.wavepath = rospy.get_param("~wavepath", "")
        self.command_to_phrase = COMMAND_TO_PHRASE  # this is deffined in wheelchairint/keywords_tocommand.py
        # Create the sound client object
        self.soundhandle = SoundClient()
        # Announce that we are ready for input
        rospy.sleep(2)
        self.soundhandle.stopAll()
        rospy.sleep(1)
        self.soundhandle.playWave(self.wavepath + "/R2D2.wav")
        rospy.sleep(2)
        self.soundhandle.say("I am ready", self.voice)
        rospy.sleep(1.5)
        self.soundhandle.say("Give me an order", self.voice)
        rospy.sleep(2)
        rospy.loginfo("Say one a commands...")

        # Subscribe to the recognizer output
        rospy.Subscriber('recognizer/output', String, self.rec_out_callback)
        r = rospy.Rate(0.5)
        while not rospy.is_shutdown():
            #            rospy.loginfo("wheelchair talk is running correctly.")
            r.sleep()
    def __init__(self):
        # State Flags
        self._turn = UNSTART
        self._search = UNSTART
        self._adjust = UNSTART
        self._reach = UNSTART
        self._target = ''

        # ROS Parameters
        self.sub_nav = None
        self.sub_bbox = None
        self.sub_odom = None
        self.sub_target = None

        self.pub_odom = None
        self.pub_result = None

        self.sub_master_target_topic_name = None
        self.sub_bbox_topic_name = None
        self.sub_navigation_result_topic_name = None

        self.pub_search_result_topic_name = None

        self._center_x = 320
        self._object_center_x = 0

        # Initialize sound client
        self.sh = SoundClient(blocking=True)
        rospy.sleep(1)
        self.sh.stopAll()
        rospy.sleep(1)

        # Odom parameters
        rate = 20
        # Set the equivalent ROS rate variable
        self.r = rospy.Rate(rate)
        self._target = None
        # Set the forward linear speed to 0.15 meters per second
        self.linear_speed = 0.15

        ############### Set the travel distance in meters
        self.goal_distance = 0
        # Set the rotation speed in radians per second
        self.angular_speed = 0.5
        # Set the angular tolerance in degrees converted to radians
        self.angular_tolerance = radians(1.0)

        # Initialize the tf listener
        self.tf_listener = tf.TransformListener()
        # Give tf some time to fill its buffer
        rospy.sleep(2)
        self.odom_frame = '/odom'
        rospy.loginfo("Ready for adjust robot pose by using odom")
        self.cmd_vel = rospy.Publisher('/cmd_vel_mux/input/navi',
                                       Twist,
                                       queue_size=5)

        # Set Ros parameters
        self.set_params()
        self.main_loop()
Beispiel #8
0
    def __init__(self, script_path):
        rospy.init_node('navibot')

        rospy.on_shutdown(self.cleanup)

        # Create the sound client object
        #self.soundhandle = SoundClient()
        self.soundhandle = SoundClient(blocking=True)

        # Wait a moment to let the client connect to the sound_play server
        rospy.sleep(1)

        # Make sure any lingering sound_play processes are stopped.
        self.soundhandle.stopAll()

        #Announce that we are ready
        self.soundhandle.say('Hello, I am Bully. What can I do for you?',
                             volume=0.05)
        rospy.sleep(3)

        rospy.loginfo("Say one of the navigation commands...")

        # Subscribe to the recognizer output and set the callback function
        rospy.Subscriber('/lm_data', String, self.talkback)

        #Publish to the navito_point topic to use rviz
        self.navi = rospy.Publisher("/navi_to_point", String, queue_size=10)

        # Subscribe to the navigation result
        self.navigation_back = ""
        rospy.Subscriber('/navigation_feed_point', String, self.naviback)
    def watson(self, data):
        # stop_recognizer()
        temp_file_name = "voice.wav"

        url = "https://stream.watsonplatform.net/text-to-speech/api/v1/synthesize?voice=en-US_AllisonVoice"
        user = "******"
        password = "******"
        msg = data.strip()
        storage = StringIO()
        c = pycurl.Curl()
        c.setopt(c.URL, url)
        c.setopt(pycurl.HTTPHEADER,
                 ['Content-Type: application/json', 'Accept: audio/wav'])
        c.setopt(pycurl.USERNAME, user)
        c.setopt(pycurl.PASSWORD, password)
        c.setopt(pycurl.POST, 1)
        c.setopt(pycurl.POSTFIELDS, '{ "text" : "' + msg + '" }')
        c.setopt(c.WRITEFUNCTION, storage.write)
        c.perform()
        c.close()
        content = storage.getvalue()

        with open(os.path.join(self.SOUND_FILE_PATH, temp_file_name),
                  'w') as f:
            f.write(content)

        sound_client = SoundClient()
        sound = sound_client.waveSound(temp_file_name)
        sound.play()
        self.wave_counter(temp_file_name)

        os.remove(os.path.join(self.SOUND_FILE_PATH, temp_file_name))
Beispiel #10
0
	def __init__(self):
		rospy.init_node('a2dr_soundplay_node')
		self.soundhandle = SoundClient()
		self.sound_volume = rospy.get_param("~sound_volume", 1.0)
		self.sound_to_play = rospy.get_param("~sound_to_play", "/home/ohm/a2dr_ws/src/a2dr_voice/voice/base_station.wav")
		self.sound_cycle_time = rospy.get_param("~sound_cycle_time", 5.0)
		self.play()
Beispiel #11
0
    def __init__(self, get_fn, trans_fn, object_IDs):
        self.get_fn = get_fn
        self.trans_fn = trans_fn
        self.object_IDs = object_IDs
        self.last_say = None

        # get the point cloud objects on the table for pointing / recognizing touches
        tries = 10
        while tries > 0:
            self.pointCloud2_plane, self.cloud_plane_coef, self.pointCloud2_objects = self.get_pointCloud2_objects(
            )
            if len(self.pointCloud2_objects) == len(self.object_IDs):
                break
            tries -= 1
        if tries == 0:
            sys.exit("ERROR: " + str(len(self.pointCloud2_objects)) +
                     " PointCloud2 objects detected " + "while " +
                     str(len(self.object_IDs)) + " objects were expected")

        # initialize a sound client instance for TTS
        self.sound_client = SoundClient()
        rospy.sleep(1)
        self.sound_client.stopAll()

        # have operator interaction to confirm ordering of objects is correct, terminate if it isn't
        op_resp = None
        while op_resp != "Y" and op_resp != "N":
            print "perform detection and ordering check?[Y/N]:"
            op_resp = raw_input()
            if op_resp == "Y":
                print "touching objects from left-most to right-most... please watch and confirm detection and order"
                for i in range(0, len(object_IDs)):
                    print "... touching object in position " + str(i)
                    self.point(i, log=False)
                    rospy.sleep(2)
                    self.point(-1, log=False)
                    rospy.sleep(2)
                op_resp = None
                while op_resp != "Y" and op_resp != "N":
                    print "confirm detection and ordering[Y/N]:"
                    op_resp = raw_input()
                    if op_resp == "N":
                        sys.exit("Try to fix my detection and try again.")

        # have open-ended operator interaction to confirm detection of touches is working
        print "testing touch detection..."
        op_resp = None
        while op_resp != "Y" and op_resp != "N":
            print "detect a new touch?[Y/N]:"
            op_resp = raw_input()
            if op_resp == "Y":
                print "...waiting to see what you point to"
                t_idx = self.get_guess(log=False, block_until_prompted=False)
                if t_idx == -1:
                    print "...no touch detected"
                else:
                    print "...touching at detected position " + str(t_idx)
                    self.point(t_idx, log=False)
                op_resp = None
            self.point(-1, log=False)
 def __init__(self):
     rospy.init_node('coconut_alert_node')
     self.alerthandle = SoundClient()
     self.alert_to_play = '{}/coconut_ws/src/coconut_sound/sound/obstacle.wav'.format(
         home)
     self.alert_cycle_time = 7.0
     self.listener()
Beispiel #13
0
    def __init__(self):
        self._order_queue = deque()

        rospy.wait_for_service(
            'serving')  # service for placing and grabbing tray
        # calling the serving service via self._serving_server(ServingRequest.RETREIVE) or ServingRequest.PLACE
        self._serving_server = rospy.ServiceProxy('serving', Serving)

        rospy.wait_for_service('navigation')  # service for navigation
        # use rossrv show navigator_msg/Navigator to see the possible call values
        self._navigator_server = rospy.ServiceProxy('navigation', Navigation)

        # _order_callback is the callback for the frontend's topic
        # make a subscriber to the frontend
        self._frontend_sub = rospy.Subscriber('/orders', Order,
                                              self._order_callback)

        # make a publisher to the frontend to send errors
        self._frontend_error_pub = rospy.Publisher('/order_failure',
                                                   Order,
                                                   queue_size=10)

        self._soundhandle = SoundClient()
        rospy.sleep(1)
        self._soundhandle.stopAll()
Beispiel #14
0
def play_nonblocking():
    """
    Play the same sounds with manual pauses between them.
    """
    rospy.loginfo('Example: Playing sounds in *non-blocking* mode.')
    # NOTE: you must sleep at the beginning to let the SoundClient publisher
    # establish a connection to the soundplay_node.
    soundhandle = SoundClient(blocking=False)
    rospy.sleep(1)

    # In the non-blocking version you need to sleep between calls.
    rospy.loginfo('Playing say-beep at full volume.')
    soundhandle.playWave('say-beep.wav')
    rospy.sleep(1)

    rospy.loginfo('Playing say-beep at volume 0.3.')
    soundhandle.playWave('say-beep.wav', volume=0.3)
    rospy.sleep(1)

    rospy.loginfo('Playing sound for NEEDS_PLUGGING.')
    soundhandle.play(SoundRequest.NEEDS_PLUGGING)
    rospy.sleep(1)

    rospy.loginfo('Speaking some long string.')
    soundhandle.say('It was the best of times, it was the worst of times.')
    def __init__(self):
        rospy.on_shutdown(self.cleanup)

        self.rate = rospy.get_param("~rate", 5)
        r = rospy.Rate(self.rate)
          
        self.voice = rospy.get_param("~voice", "voice_don_diphone")
        self.wavepath = rospy.get_param("~wavepath", "")
        
        # Create the sound client object
        self.soundhandle = SoundClient()
        
        rospy.sleep(1)
        self.soundhandle.stopAll()
        
        # Announce that we are ready for input
        self.soundhandle.playWave(self.wavepath + "/R2D2a.wav")
        rospy.sleep(1)
        self.soundhandle.say("Ready", self.voice)

        # Subscribe to the recognizer output
        rospy.Subscriber('/recognizer/output', String, self.identify)


	while not rospy.is_shutdown():
    		r.sleep()                       
Beispiel #16
0
def main():

    rospy.init_node('interactive_behavior_executor')

    speech_recognition_client = SpeechRecognitionClient()
    sound_client = SoundClient(sound_action='/robotsound_jp',
                               sound_topic='/robotsound_jp')
    action_server_lead_to = actionlib.SimpleActionClient(
        '~execute_behaviors', LeadPersonAction)

    node_list = rospy.get_param('~nodes', {})

    while not rospy.is_shutdown():

        rospy.loginfo('Asking package information')
        while not rospy.is_shutdown():
            sound_client.say('行き先を教えてください。', blocking=True)
            recogntion_result = speech_recognition_client.recognize()
            if len(recogntion_result.transcript) == 0:
                rospy.logerr(
                    'No matching node found from spoken \'{}\''.format(
                        recogntion_result))
                sound_client.say('行き先がわかりませんでした', blocking=True)
                continue
            recognized_destination = recogntion_result.transcript[0]
            target_node_candidates = {}
            for node_id, value in node_list.items():
                try:
                    if not value.has_key('name_jp'):
                        continue
                    if type(value['name_jp']) is list:
                        # DO HOGE
                        for name in value['name_jp']:
                            if name.encode('utf-8') == recognized_destination:
                                target_node_candidates[node_id] = value
                    else:
                        if value['name_jp'].encode(
                                'utf-8') == recognized_destination:
                            target_node_candidates[node_id] = value
                except Exception as e:
                    rospy.logerr('Error: {}'.format(e))
            if len(target_node_candidates) == 0:
                rospy.logerr(
                    'No matching node found from spoken \'{}\''.format(
                        recogntion_result))
                sound_client.say('行き先がわかりませんでした', blocking=True)
            else:
                rospy.loginfo('target_node_candidates: {}'.format(
                    target_node_candidates))
                break

        target_node_id = target_node_candidates.keys()[0]
        target_node_name_jp = node_list[target_node_id]['name_jp'].encode(
            'utf-8')

        sound_client.say('{} へ移動します'.format(target_node_name_jp))

        rospy.loginfo('executing behaviors to {}'.format(target_node_name_jp))
        action_server_lead_to.send_goal_and_wait(
            LeadPersonGoal(target_node_id=target_node_id))
Beispiel #17
0
def dist_from_goal():
    global x_goal, y_goal, pose_x, pose_y, goal_set
    rospy.Subscriber('/odom', Odometry, odom_callback)

    if sqrt(pow((x_goal - pose_x), 2) + pow((y_goal - pose_y), 2)) < 0.75:
        SoundClient().say('I have arrived at the destination')
        goal_set = False
def goal_status():
    global state
    global state_info
    sub = rospy.Subscriber('move_base/status', GoalStatusArray, status_cb)
    soundhandle = SoundClient()
    last_state = -1

    snd_failed = rospy.get_param("~snd_failed", "")
    snd_accepted = rospy.get_param("~snd_accepted", "")
    snd_success = rospy.get_param("~snd_success", "")

    while not rospy.is_shutdown():

        # print "s: %d, l: %d" % (state, last_state)

        if state != last_state and last_state != -1:
            # Failed
            if state == 4:
                soundhandle.playWave(snd_failed)
            # Accepted
            if state == 1:
                soundhandle.playWave(snd_accepted)
            # Success
            if state == 3:
                soundhandle.playWave(snd_success)

            rospy.loginfo("State changed to: [%d] %s" % (state, state_info))

        last_state = state
        rospy.sleep(2)
    def __init__(self):
        rospy.init_node('select_cmd_vel')
        rospy.on_shutdown(self.cleanup)

        self.rate = rospy.Rate(5)

        self.first_follow_raise = True
        self.first_car_raise = True
        self.task_done = True

        #create the sound client object
        self.soundclient = SoundClient()

        #set the sound voice
        self.voice = 'voice_rab_diphone'

        #wait a moment to let the sound client to connect to the sound_play server
        rospy.sleep(1)

        #是否暂停解析语音指令
        self.paused = True

        #订阅voice_command
        self.voice_cmd_sub = rospy.Subscriber('voice_command', String,
                                              self.speech_callback)

        self.nav_result = rospy.Subscriber('move_base/result',
                                           MoveBaseActionResult,
                                           self.nav_result_cb)

        rospy.wait_for_service('mux/select', 30)
        self.mux_select = rospy.ServiceProxy('mux/select', MuxSelect)

        rospy.loginfo("Connected to mux select service. ")
Beispiel #20
0
    def set_params(self):
        #Initialize sound client
        print("Initialize Sound Client")
        self.sh = SoundClient(blocking=True)
        rospy.sleep(1)
        self.sh.stopAll()
        rospy.sleep(1)
        self.voice = rospy.get_param("~voice", "voice_kal_diphone")

        # set params through rosparam
        self.pub_to_nav_topic_name = rospy.get_param("pub_to_nav_topic_name",
                                                     "/control_to_nav")

        self.sub_nav_back_topic_name = rospy.get_param(
            "sub_nav_back_topic_name", "/nav_to_control")

        # initialize publishers & subscribers
        self.pub_nav = rospy.Publisher(self.pub_to_nav_topic_name,
                                       Mission,
                                       queue_size=1)

        self.sub_nav = rospy.Subscriber(self.sub_nav_back_topic_name, Result,
                                        self.nav_callback)
        self.sub_image = rospy.Subscriber("/image_to_control", Result,
                                          self.image_callback)
Beispiel #21
0
    def __init__(self, script_path):
        rospy.init_node('talkback')

        rospy.on_shutdown(self.cleanup)

        # Create the sound client object
        self.soundhandle = SoundClient()

        # Wait a moment to let the client connect to the
        # sound_play server
        rospy.sleep(1)

        # Make sure any lingering sound_play processes are stopped.
        self.soundhandle.stopAll()

        # Announce that we are ready for input
        #self.soundhandle.playWave('say-beep.wav')
        #rospy.sleep(2)
        #self.soundhandle.say('Ready')

        rospy.loginfo("Say one of the navigation commands...")

        # Subscribe to the recognizer output and set the callback function
        #self.pubs = rospy.Publisher("state", bool, queue_size=10)
        #self.pubs.publish(true)
        if i == 1:
            rospy.Subscriber('/lm_data', String, self.talkback, queue_size=1)
Beispiel #22
0
    def __init__(self, delay=60, timeout=None):
        smach.State.__init__(self,
                             outcomes=['success', 'failure', 'timeout'],
                             input_keys=['start_time', 'stop_time'])

        #rospy.init_node('follow_person', anonymous = True)

        self.soundhandle = SoundClient(blocking=True)
        rospy.sleep(1)
        self.soundhandle.stopAll()

        # Announce that we are ready for input
        #self.soundhandle.playWave("/home/roboworks/erasersedu_ws/src/carry_luggage/sounds/R2D2a.wav")

        # Subscribe to the recognizer output and set the callback function
        rospy.Subscriber('/lm_data', String, self.talkback_cb)

        #Leg finder
        self.fp_enable_leg_finder_pub = rospy.Publisher(
            '/leg_finder/enable', Bool)
        self.fp_start_follow_pub = rospy.Publisher(
            '/human_following/start_follow', Bool)

        self.fp_legs_found_sub = rospy.Subscriber('/leg_finder/legs_found',
                                                  Bool, self._fp_legs_found_cb)

        #TODO: Call STARTSTOP publisher/subscriber
        #self.fp_wrist_wrench_sub = rospy.Subscriber('/wrist_wrench/raw', WrenchStamped, self._wrist_wrench_cb)

        self.fp_legs_found = False

        self.start = False
        self.stop = False

        self.delay = delay
Beispiel #23
0
	def __init__(self):

		rospy.on_shutdown(self.cleanup)
		self.voice = rospy.get_param("~voice", "voice_cmu_us_clb_arctic_clunits")
		self.wavepath = rospy.get_param("~wavepath", "")
		self.state="true"
		self.soundhandle=SoundClient()
		rospy.sleep(1)
		self.soundhandle.stopAll()
		rospy.sleep(1)
		self.soundhandle.say("ready",self.voice)
		rospy.sleep(1.1)
		self.pub = rospy.Publisher('/ifFollowme', String, queue_size=15)
		self.loc_pub = rospy.Publisher('voice2bring', String, queue_size=15)
		self.srt_guide = rospy.Publisher('voice2guide', String, queue_size=15)
		self.inspect = rospy.Publisher('go_out', String, queue_size=15)


		rospy.Subscriber('inspect2speech',String,self.inspect_callback)
		rospy.Subscriber('/emergency2speech',String,self.emergency_callback)		

		self.difmsg='null'
		self.if_followme=0
		self.if_stop=0
		self.if_locpub=0
		self.say_time=0
Beispiel #24
0
    def __init__(self):

        rospy.on_shutdown(self.cleanup)
        self.voice = rospy.get_param("~voice",
                                     "voice_cmu_us_clb_arctic_clunits")
        self.wavepath = rospy.get_param("~wavepath", "")
        self.soundhandle = SoundClient()
        rospy.sleep(1)
        self.soundhandle.stopAll()
        rospy.sleep(2)
        self.soundhandle.say("ready", self.voice)

        rospy.sleep(3)
        rospy.Subscriber('Point', String, self.nav_sp)
        self.pub = rospy.Publisher('ifFollowme', String, queue_size=10)

        self.gpsr_srclocation = rospy.Publisher('gpsr_srclocation',
                                                String,
                                                queue_size=10)

        self.if_followme = 0
        self.if_stop = 0
        self.flag = 0
        self.if_followflag = 0
        self.if_stopflag = 0
        self.flaga = -1
        self.flagb = -1
        self.flag24 = 0
Beispiel #25
0
def speak_whatever(s):
	soundhandle2 = SoundClient()
	rospy.sleep(1)
	voice = 'voice_kal_diphone'
	volume = 100.0
	soundhandle2.say(s,voice)
	rospy.sleep(1)
Beispiel #26
0
    def follower(self):
        sound_client = SoundClient()
	tts = gTTS(text = 'I am going to follow you, here I come!', lang = 'en')
      	tts.save('/home/turtlebot/wavFiles/follow.wav')
       	rospy.loginfo('Turtlebot says I understood what you said...')
       	sound_client.playWave('/home/turtlebot/wavFiles/follow.wav', blocking=True)
	max_time = 10
	# The os.setsid() is passed in the argument preexec_fn so
	# it's run after the fork() and before  exec() to run the shell.
	follow = subprocess.Popen(["roslaunch", "turtlebot_follower", "follower.launch"])#, stdout=subprocess.PIPE, shell=True, preexec_fn=os.setsid)   
	#sound = subprocess.Popen(["rosrun", "sound_play", "soundplay_node.py"], stdout=subprocess.PIPE, shell=True, preexec_fn=os.setsid)     
	#rospy.sleep(10)
	start_time = time.time()  # remember when we started
	count = 0
	#soundhandle = SoundClient(blocking=False)
	#soundhandle.playWave('/home/turtlebot/wavFiles/dancesong.wav')
	while (time.time() - start_time) < max_time: 
	    #wait()
	    count = count +1
	    #print count

	os.killpg(os.getpgid(follow.pid), signal.SIGTERM)  # Send the signal to all the process groups
	print "killed successfully" 
	tts = gTTS(text = 'Whew! I am tired! You are sooooo fast', lang = 'en')
      	tts.save('/home/turtlebot/wavFiles/followEnd.wav')
       	rospy.loginfo('Turtlebot says I understood what you said...')
       	sound_client.playWave('/home/turtlebot/wavFiles/followEnd.wav', blocking=True)
	
	return None
Beispiel #27
0
	def __init__(self):
		"""
			初始化函数,初始化录音以及语音识别api需要用到的各项参数
		"""
		# 初始化ros node
		rospy.init_node("robot_speech")

		# Soundplay 参数
		self.voice = rospy.get_param("~voice", "voice_kal_diphone")
		self.speaker = SoundClient(blocking=True)
		rospy.sleep(1)
		self.speaker.stopAll()
		rospy.sleep(1)

		# 录音参数
		self.start_record = False
		self.stop_record = False
		self.count = 0
		self.chunk = 256
		self.format = pyaudio.paInt16
		self.channels = 1
		self.rate = 11025
		self.record_second = 11

		# api参数
		self.URL = "http://api.xfyun.cn/v1/service/v1/iat"
		self.APPID = "15944331"
		self.API_KEY = "bpNdxEhagyalZVtC6fddFeGZ"
		self.SECRET_KEY = '1QRtmDnXAA9TUQuGH8zHL5K1OW2GnpDu'
		self.audio_folder = os.path.join(os.path.dirname(CURRENT_FOLDER_PATH),"/sounds/gpsr_record/")
		self.ASR_URL = 'http://vop.baidu.com/server_api'
		self.DEV_PID = 1737
		self.CUID = '123456PYTHON'
		self.FORMAT = 'wav'
		self.RATE = 16000
Beispiel #28
0
    def dance(self):
	max_time = 33
    	sound_client = SoundClient(blocking=False)
    	# In the non-blocking version you need to sleep between calls.
        rospy.sleep(1)
	#PLAY THE SONG HERE
        rospy.loginfo('Playing the song, getting ready to dance')
	sound_client.playWave('/home/turtlebot/wavFiles/dancesong.wav')
    	rospy.sleep(1)
	#for some random number of times
	times = randint(4,7)
	count = 0
	start_time = time.time()  # remember when we started
	while (time.time() - start_time) < max_time:
	    #while (count < times):
	    count = count + 1
	    #generate random angle for dance
	    rad = randint(30, 90)		
	    self.turn('left', rad) #BY DEFAULT, LEFT(?)
	    #generate random length to go forward
	    rangeDist = randint(5, 10)
	    self.goForward(rangeDist)
	# turn or go forward 
	tts = gTTS(text = 'Whew! I am tired! I think I will have to stop now!', lang = 'en')
      	tts.save('/home/turtlebot/wavFiles/danceEnd.wav')
       	rospy.loginfo('Turtlebot says I understood what you said...')
       	sound_client.playWave('/home/turtlebot/wavFiles/danceEnd.wav', blocking=True)
Beispiel #29
0
    def __init__(self, script_path):
        rospy.init_node("riddle")
        self.soundhandle = SoundClient()
        self.voice = rospy.get_param("~voice", "voice_don_diphone")
        self.wavepath = rospy.get_param("~wavepath",
                                        script_path + "/../sounds")
        self.move_base_client = actionlib.SimpleActionClient(
            'move_base', MoveBaseAction)
        self.ori_pub = rospy.Publisher('/cmd_vel', Twist, queue_size=10)
        self.ori_msg = Twist()
        self.ori_msg.angular.x = 0
        self.ori_msg.angular.y = 0
        self.stop_msg = Twist()
        self.angle = '000'

        self.people_ori = 0
        self.conf = 0
        self.count = 0
        self.load_aiml('startup.xml')
        #mybot.learn('0.aiml')

        self.sl("I want to play the riddle game!", 1, 2)
        #rospy.sleep(10)
        rot1 = [0.000000, 0.000000, 0.775809, -0.630967]
        self.rot = [0, 0, 0.775809, -0.630967]
        self.pos1 = [9.549557, 2.289376, 0.000000]
        self.move(rot1, self.pos1, self.count_people)
Beispiel #30
0
    def get_params(self):
        # Initialize sound client
        self.sh = SoundClient()
        rospy.sleep(1)
        self.sh.stopAll()
        rospy.sleep(1)

        # Get parameters
        self.voice = rospy.get_param("~voice", "voice_us2_mbrola")
        self.cmd_files = rospy.get_param("~cmd_file", "/home/kamerider/catkin_ws/src/kamerider_speech/CommonFiles")

        self.pub_to_arm_topic_name   = rospy.get_param("pub_to_arm_topic_name"  , "/speech_to_arm")
        self.pub_to_nav_topic_name   = rospy.get_param("pub_to_nav_topic_name"  , "/speech_to_nav")
        self.pub_to_image_topic_name = rospy.get_param("pub_to_image_topic_name", "/speech_to_image")

        self.sub_arm_back_topic_name   = rospy.get_param("sub_arm_back_topic_name"  , "/arm_to_speech")
        self.sub_nav_back_topic_name   = rospy.get_param("sub_nav_back_topic_name"  , "/nav_to_speech")
        self.sub_image_back_topic_name = rospy.get_param("sub_image_back_topic_name", "/image_to_speech")

        rospy.Subscriber(self.sub_arm_back_topic_name, String, self.armCallback)
        rospy.Subscriber(self.sub_nav_back_topic_name, String, self.navCallback)
        rospy.Subscriber(self.sub_image_back_topic_name, String, self.imageCallback)

        self.arm_pub   = rospy.Publisher(self.pub_to_arm_topic_name, String, queue_size=1)
        self.nav_pub   = rospy.Publisher(self.pub_to_nav_topic_name, String, queue_size=1)
        self.image_pub = rospy.Publisher(self.pub_to_image_topic_name, String, queue_size=1)

        # Start gpsr task
        self.start_gpsr()