当前位置: 首页>>代码示例>>Python>>正文


Python String.data方法代码示例

本文整理汇总了Python中std_msgs.msg.String.data方法的典型用法代码示例。如果您正苦于以下问题:Python String.data方法的具体用法?Python String.data怎么用?Python String.data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std_msgs.msg.String的用法示例。


在下文中一共展示了String.data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: execute

# 需要导入模块: from std_msgs.msg import String [as 别名]
# 或者: from std_msgs.msg.String import data [as 别名]
    def execute(self, ud):

        tts_msg = String()
        tts_msg.data = 'Do you want me to start guiding you back to the arena?'
        self.tts_pub.publish(tts_msg)

        self.question_asked = True

        return_param = ''

        while True:
            self.mutex.acquire()
            if self.confirmation_received:
                if self.start_guiding:
                    tts_msg.data = "I will guide you back to the arena."
                    self.tts_pub.publish(tts_msg)
                    try:
                        self.people_follower_srv.call(request=peopleFollowerRequest.RELEASE_TARGET)
                    except rospy.ServiceException:
                        pass
                    return_param = 'start_guiding'
                else:
                    return_param = 'do_not_guide'

                self.mutex.release()
                break
            self.mutex.release()

        return return_param
开发者ID:WalkingMachine,项目名称:sara_commun,代码行数:31,代码来源:stage1_following_guiding.py

示例2: run

# 需要导入模块: from std_msgs.msg import String [as 别名]
# 或者: from std_msgs.msg.String import data [as 别名]
  def run(self):
    self.speechRecogProxy.setLanguage("English")
    wordList = ["come", "go", "stand", "sit", "relax", "stiffen"]
    self.speechRecogProxy.setWordListAsVocabulary(wordList)
    self.speechRecogProxy.subscribe("ros")

    self.dataNamesList = ["WordRecognized"]
    
    self.recognizedWordPub = rospy.Publisher("recognized_word", String)   
    self.textToSpeechPub   = rospy.Publisher("speech", String)

    r = rospy.Rate(5)
    prev_word = str()
    while not rospy.is_shutdown():
      try:
        memoryData = self.memoryProxy.getListData(self.dataNamesList)
      except RuntimeError,e:
        rospy.logerr("Error accessing ALMemory: %s", e)
        rospy.signal_shutdown("No NaoQI available anymore")

      if (memoryData[0][1] >= 0.2) and (memoryData[0][0] != prev_word):
        msg = String()
        msg.data = memoryData[0][0]
        self.recognizedWordPub.publish(msg)
        msg = String()
        msg.data = "Oh kay."
        self.textToSpeechPub.publish(msg)
        prev_word = memoryData[0][0]

      # reset  
      if memoryData[0][0] == '':
        prev_word = ''

      r.sleep()
开发者ID:veltrop,项目名称:veltrop_ros_pkg,代码行数:36,代码来源:nao_speech_recognition.py

示例3: property_changed

# 需要导入模块: from std_msgs.msg import String [as 别名]
# 或者: from std_msgs.msg.String import data [as 别名]
def property_changed(interface, changed, invalidated, path):
        iface = interface[interface.rfind(".") + 1:]
        for name, value in changed.iteritems():
                val = str(value)
                #print(name + "=" + val)
                if name == 'Connected':
                        if val == "1":
                                print("ON")
                                message = String()
                                message.data = "gpio,w,on"
                                send(message)
                        elif val == "0":
                                print("OFF")
                                message = String()
                                message.data = "gpio,w,off"
                                send(message)
                                advertise()

                        else:
                                pass
                elif name == 'Alias' or name == 'Name':
                    print("ON")
                    message = String()
                    message.data = "gpio,w,on"
                    send(message)
                else:
                        pass
开发者ID:MitsuhiroYabu,项目名称:ros_test,代码行数:29,代码来源:bleNode.py

示例4: decision_function

# 需要导入模块: from std_msgs.msg import String [as 别名]
# 或者: from std_msgs.msg.String import data [as 别名]
    def decision_function(self):
        last_three = self.engagement_history[-3:]
        mean = sum(last_three)/3
        
        # Let at least do 3 trials in 5 min with a bad mean
        #if mean < 10 and self.current_time > 300 and np.size(self.engagement_history) > 3:
#        if self.current_time > 36000000:
#            self.engagement_history = self.engagement_history[0:-3]
#            msg = String()
#            if self.activity_turn:
#                msg.data = "drawing_nao"
#                #self.activity_turn = False
#            else:
#                pass
#                #msg.data = "joke_nao"
#                #self.activity_turn = True
#            self.pub_activity.publish(msg)
        
        msg = String()
        if self.nb_repetitions == 14:
            msg.data = "drawing_nao"
            #self.activity_turn = False
            self.pub_activity.publish(msg)
        if self.nb_repetitions == 7:
            msg.data = "drawing_nao"
            #self.activity_turn = False
            self.pub_activity.publish(msg)
开发者ID:zhuangfangwang,项目名称:emotional-manager,代码行数:29,代码来源:emotional_manager.py

示例5: execute

# 需要导入模块: from std_msgs.msg import String [as 别名]
# 或者: from std_msgs.msg.String import data [as 别名]
    def execute(self, userdata):

        #self.ON_pub.publish(Empty())
        rospy.sleep(120)

	my_string=String()
	my_string.data="Il est l'heure de se lever. Debout les feignants."
	self.french_pub.publish(my_string)

        rospy.sleep(480)
	self.ON2_pub.publish(Empty())

        rospy.sleep(120)
	my_string.data="Chauffage de la salle de bain en cours."
	self.french_pub.publish(my_string)
        rospy.sleep(0.01)
	self.heatON_pub.publish(Empty())
        rospy.sleep(0.01)
	self.music_pub.publish(Empty())

        rospy.sleep(60)
	self.weather_pub.publish(Empty())

        rospy.sleep(240)
	self.heatOFF_pub.publish(Empty())

        return 'succeeded'
开发者ID:JBot,项目名称:smart-robotics-ros-pkg,代码行数:29,代码来源:home_status.py

示例6: connect_with_arduino

# 需要导入模块: from std_msgs.msg import String [as 别名]
# 或者: from std_msgs.msg.String import data [as 别名]
def connect_with_arduino():
	global send_str
	port = rospy.get_param('steer_motor_port',"/dev/ttyUSB0")
	pub = rospy.Publisher('motor_controller_input', String, queue_size=10)
	pub_str = String()
	print port
	try:
		ser = serial.Serial(port,9600)
		ser.setDTR(False)
		time.sleep(1)
		ser.setDTR(True)
		print "start connection with steer_motor"

	except:
		print "cannot start connection with steer_motor"
		sys.exit()

	time.sleep(2)
	rate = rospy.Rate(100)

	count = 0
	while count < 4:
		count += 1
		send_zero_to_steer_motor(ser)
		rate.sleep()

	print "Did You Turn On a Motor Switch??"

	wait_count = 0
	while  not wait_count > 200:
		ser.write("EN\n")
		ser.write("NP\n")
		while ser.inWaiting() > 0:
			if ser.read() == "p":
				ser.write("EN\n")
				send_devision_to_steer_motor(ser)				
				pub_str.data = send_str[:-1]
				pub.publish(pub_str)
		rate.sleep()
		wait_count = wait_count + 1


	print "Control Start"

	while  not rospy.is_shutdown():
		if enable_motor == True:
			ser.write("NP\n")
			while ser.inWaiting() > 0:
				if ser.read() == "p":
					ser.write("EN\n")
					send_devision_to_steer_motor(ser)				
					pub_str.data = send_str[:-1]
					pub.publish(pub_str)
		else:
			ser.write("DI\n")

		rate.sleep()

	ser.close()
开发者ID:interimadd,项目名称:seniorcar_src,代码行数:61,代码来源:steer_motor_controller_connecter_div.py

示例7: publishSimulatedFeedback

# 需要导入模块: from std_msgs.msg import String [as 别名]
# 或者: from std_msgs.msg.String import data [as 别名]
def publishSimulatedFeedback(bestShape_index, shapeType_index, doGroupwiseComparison):           
        feedback = String();
        if(doGroupwiseComparison):
            feedback.data = str(shapeType_index) + '_' + str(bestShape_index);
        else:
            names = ('old', 'new');
            feedback.data = names[bestShape_index];            
        onFeedbackReceived(feedback);
开发者ID:dhood,项目名称:nao_ros_cowriter,代码行数:10,代码来源:shape_learning.py

示例8: callback_sub_msg

# 需要导入模块: from std_msgs.msg import String [as 别名]
# 或者: from std_msgs.msg.String import data [as 别名]
    def callback_sub_msg(self, msg):
        try:
            symbol = String()
            symbol.data = chr(msg.data)
        except ValueError:
            symbol.data = "Symbol not exist!"

        self.pub.publish(symbol)
开发者ID:fantaa499,项目名称:urs_laba1,代码行数:10,代码来源:node.py

示例9: _on_approach_pressed

# 需要导入模块: from std_msgs.msg import String [as 别名]
# 或者: from std_msgs.msg.String import data [as 别名]
    def _on_approach_pressed(self):
	str = String()
	str.data = "getposition"
	self._publishersys.publish(str)
	d = rospy.Duration(0.2,0)
	rospy.sleep(d)
	str.data = "approach_victim"
	self._publishersys.publish(str)
	self._widget.victim_label.setText('Approach Victim..')
开发者ID:ChunkyBART,项目名称:gitUploadAuto2015,代码行数:11,代码来源:robot_steering.py

示例10: execute

# 需要导入模块: from std_msgs.msg import String [as 别名]
# 或者: from std_msgs.msg.String import data [as 别名]
 def execute(self, userdata):
     my_string = String()
     my_string.data = "Start charging."
     self.charge_pub.publish(Empty())
     self.string_pub.publish(my_string)
     rospy.loginfo("Charging... Sleep 2 hours")
     rospy.sleep(2.1*60.0*60.0)
     my_string.data = "Charge done."
     self.string_pub.publish(my_string)
     return 'succeeded'
开发者ID:smart-robotics-team,项目名称:carry-ros-pkg,代码行数:12,代码来源:carry_moves.py

示例11: _on_sensor_pressed

# 需要导入模块: from std_msgs.msg import String [as 别名]
# 或者: from std_msgs.msg.String import data [as 别名]
    def _on_sensor_pressed(self):
        str = String()
	if RobotSteering.modesensor :
		self._widget.sensor_button.setText('Stop_Sensor')
		RobotSteering.modesensor = False
		str.data = "start_sensor"
	else :
		self._widget.sensor_button.setText('Start_Sensor')
		RobotSteering.modesensor = True
		str.data = "stop_sensor"
        self._publishersys.publish(str)
开发者ID:ChunkyBART,项目名称:gitUploadAuto2015,代码行数:13,代码来源:robot_steering.py

示例12: _on_mode_pressed

# 需要导入模块: from std_msgs.msg import String [as 别名]
# 或者: from std_msgs.msg.String import data [as 别名]
    def _on_mode_pressed(self):
	str = String()
	if RobotSteering.mode :
		self._widget.mode_push_button.setText('Auto_Mode')
		RobotSteering.mode = False
		str.data = "teleop_mode"
	else :
		self._widget.mode_push_button.setText('Teleop_Mode')
		RobotSteering.mode = True
		str.data = "auto_mode"
        self._publishersys.publish(str)
开发者ID:ChunkyBART,项目名称:gitUploadAuto2015,代码行数:13,代码来源:robot_steering.py

示例13: output

# 需要导入模块: from std_msgs.msg import String [as 别名]
# 或者: from std_msgs.msg.String import data [as 别名]
def output():
  global out
  global select
  pub = rospy.Publisher('psoc_cmd',String)
  while not rospy.is_shutdown():
    p = String()
    if select is LEFT:
      p.data = ">FLPC:"+str(out)
    elif select is RIGHT:
      p.data = ">FRPC:"+str(out)
    pub.publish(p)
    time.sleep(.1)
开发者ID:nadavofir,项目名称:IGVC2013,代码行数:14,代码来源:PSoC_Force_PWM_Values.py

示例14: demo

# 需要导入模块: from std_msgs.msg import String [as 别名]
# 或者: from std_msgs.msg.String import data [as 别名]
def demo():
    rospy.init_node('Case2016_Demo')
    pub = rospy.Publisher('CModelRobotOutput', outputMsg.CModel_robot_output)
    pub_arm = rospy.Publisher('/ur_driver/URScript', String)
    rospy.Subscriber("/hands", Hands, h_call)    
    rospy.Subscriber("/faces", Faces, f_call)    
    rospy.Subscriber("/bluetooth_teleop/joy", Joy, joy_call)    

    command = outputMsg.CModel_robot_output();
    pub.publish(command) #Reset
    command.rACT = 1
    command.rGTO = 1
    command.rSP = 255
    command.rFR = 75 
    pub.publish(command) #Activate 

    # Arm Control
    val = String()
    arm_array = [-3.84, -2.1, 1.22, 0.61, 1.57, 0]

    while not rospy.is_shutdown():
        if safe == 1: #Autonomous mode
            print "Auto"
            command.rPR = state
            pub.publish(command)
            global target
            arm_array[0] = arm_array[0] + target[0]*0.001
            arm_array[2] = arm_array[2] + target[1]*0.001
            target = [0,0]
            val.data = "movej(" + str(arm_array) +", a=0.1, v=0.1)"
            pub_arm.publish(val)
            print val.data


        if safe == 2: #Manual mode
            print "Manual"
            scale = 0.1
            if joy.buttons[12] == 1: command.rPR = 0
            if joy.buttons[14] == 1: command.rPR = 255
            if joy.buttons[11] == 1: arm_array = home[:]
            pub.publish(command)
            arm_array[0] = arm_array[0] + joy.axes[0]*scale #base angle value of arm, left analog stick
            arm_array[1] = arm_array[1] + joy.axes[1]*scale #shoulder value of arm, left analog stick
            arm_array[2] = arm_array[2] + joy.axes[2]*scale #elbow value of arm, right analog stick
            arm_array[3] = arm_array[3] + joy.axes[3]*scale #wrist1 value of arm, right analog stick
            #arm_array[4] = arm_array[4] + joy.axes[3]*scale #wrist2 value of arm, right analog stick
            #arm_array[5] = arm_array[5] + joy.axes[3]*scale #wrist3 value of arm, right analog stick
            val.data = "movej(" + str(arm_array) +", a=0.5, v=1.0)"
            pub_arm.publish(val)
            print val.data

        
        rospy.sleep(0.8)
开发者ID:ibaranov-cp,项目名称:hvc_ros,代码行数:55,代码来源:case_demo.py

示例15: output

# 需要导入模块: from std_msgs.msg import String [as 别名]
# 或者: from std_msgs.msg.String import data [as 别名]
def output():
  global leftOut
  global rightOut
  pub = rospy.Publisher('psoc_cmd',String)
  while not rospy.is_shutdown():
    p = String()
    p.data = ">SPLM:"+str(leftOut)
    pub.publish(p)
    p = String()
    p.data = ">SPRM:"+str(rightOut)
    pub.publish(p)
    time.sleep(.1)
开发者ID:nadavofir,项目名称:IGVC2013,代码行数:14,代码来源:PSoC_Raw_Tank_Drive.py


注:本文中的std_msgs.msg.String.data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。