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


Python msg.String类代码示例

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


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

示例1: recognizer

def recognizer():
    pub = rospy.Publisher('/recognizer/output',String, queue_size=10)
    rospy.init_node('HRI_Recognizer')
    msg = String()
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.bind(("127.0.0.1", 0))
    port = s.getsockname()[1]
    s.listen(1)


    p = multiprocessing.Process(target=callJulius, args=(port,))
    p.start()
    conn, addr = s.accept()

    while not rospy.is_shutdown():
        data = conn.recv(4096)
        if data.find("sentence1") >= 0:
            data=data[data.find("sentence1")+15:data.find(" </s>")]
            if data == "GO A HEAD":
                data = "GO AHEAD"
            elif data == "GOLEFT":
                data = "GO LEFT"
            elif data == "TAKEOFF":
                data = "TAKE OFF"
            msg.data = data
            pub.publish(msg)

    s.close()
    p.close()
开发者ID:yazdani,项目名称:cram_sar_mission,代码行数:29,代码来源:juliusToRos.py

示例2: execute

    def execute(self, userdata):


        tosay = String()
        myint = Int32()
        tosay.data = "Bonne nuit."
        self.french_pub.publish(tosay)
        rospy.sleep(0.01)

        myint.data = 1
        self.brightness1_pub.publish(myint)
        rospy.sleep(0.01)
        myint.data = 6
        self.brightness2_pub.publish(myint)
        rospy.sleep(0.01)
        myint.data = 6
        self.brightness3_pub.publish(myint)
        rospy.sleep(0.3)

        # Shutdown everything
        self.OFF3_pub.publish(Empty())
        rospy.sleep(0.01)
        self.OFF2_pub.publish(Empty())
        rospy.sleep(0.01)
        self.OFF1_pub.publish(Empty())
        rospy.sleep(0.01)
        self.heatOFF_pub.publish(Empty())
        rospy.sleep(0.01)

        return 'succeeded'
开发者ID:smart-robotics-team,项目名称:smart-home-ros-pkg,代码行数:30,代码来源:smach_home_status.py

示例3: callback_thread

def callback_thread(data,time):
   global res
   global test_var
   global thread1
   if checker == "true":
      if data.data != "SWITCH":
         result = data.data
         if result == "COMEBACK":
            result="COME BACK"
         elif result == "TAKEPICTURE": 
            result = "TAKE PICTURE"
         elif result == "SCANFOREST":
            result = "SCAN FOREST"
         elif result == "SCANAREA":
            result = "SCAN AREA"
         elif result == "TAKEOFF":
            result="TAKE OFF"
         elif result == "NEXTTO":
            result="NEXT"
         print "hello"
         window.insert(INSERT,'Genius:  ','hcolor')
         window.insert(END,result.upper()+'\n','hnbcolor')
         string = String()
         string.data = result.upper()
         result = result.lower()
         res = result
         thread1 = res
         thread.start_new_thread(sleeping_time, (res,5,))
         thread.start_new_thread(compare_thread, (res,1,))
开发者ID:yazdani,项目名称:cram_sar_mission,代码行数:29,代码来源:gui2.py

示例4: test_unsubscribe_does_not_receive_further_msgs

    def test_unsubscribe_does_not_receive_further_msgs(self):
        topic = "/test_unsubscribe_does_not_receive_further_msgs"
        msg_type = "std_msgs/String"
        client = "client_test_unsubscribe_does_not_receive_further_msgs"

        msg = String()
        msg.data = "dsajfadsufasdjf"

        pub = rospy.Publisher(topic, String)
        multi = MultiSubscriber(topic, msg_type)

        received = {"count": 0}

        def cb(msg):
            received["count"] = received["count"] + 1

        multi.subscribe(client, cb)
        sleep(0.5)
        pub.publish(msg)
        sleep(0.5)
        self.assertEqual(received["count"], 1)
        multi.unsubscribe(client)
        sleep(0.5)
        pub.publish(msg)
        sleep(0.5)
        self.assertEqual(received["count"], 1)
开发者ID:1487quantum,项目名称:fyp-autonomous-bot,代码行数:26,代码来源:test_multi_subscriber.py

示例5: final_result

 def final_result(self, hyp, uttid):
     """ Insert the final result. """
     rospy.loginfo("final_result publish!!!!")
     msg = String()
     msg.data = str(hyp.lower())
     rospy.loginfo(msg.data)
     self.pub.publish(msg)
开发者ID:ppp2006,项目名称:pocketsphinx_web,代码行数:7,代码来源:recognizer_cn.py

示例6: test_immediate_publish

    def test_immediate_publish(self):
        """ This test makes sure the PublisherConsistencyListener is working"""
        topic = "/test_immediate_publish"
        msg_class = String

        msg = String()
        string = "why halo thar"
        msg.data = string

        received = {"msg": None}
        def callback(msg):
            print "Received a msg! ", msg
            received["msg"] = msg

        rospy.Subscriber(topic, msg_class, callback)

        class temp_listener(rospy.SubscribeListener):
            def peer_subscribe(self, topic_name, topic_publish, peer_publish):
                print "peer subscribe in temp listener"

        listener = PublisherConsistencyListener()
        publisher = rospy.Publisher(topic, msg_class, temp_listener())
        listener.attach(publisher)
        publisher.publish(msg)
        sleep(0.5)

        self.assertEqual(received["msg"], msg)
开发者ID:1487quantum,项目名称:fyp-autonomous-bot,代码行数:27,代码来源:test_publisher_consistency_listener.py

示例7: test_cmd_handler_right

 def test_cmd_handler_right(self):
     """Checks that person rotates clockwise when given right msg."""
     msg = String()
     msg.data = "right"
     self.person.cmd_handler(msg)
     self.assertTrue(self.person.rotation_executing)
     self.assertEqual(self.person.velocity.angular.z, -0.5)
开发者ID:SarenCurrie,项目名称:SpeedKiwi,代码行数:7,代码来源:test_educated_person.py

示例8: _send_heat

    def _send_heat(self, heat):
	h = Int16()
        h.data = heat
	self._publisherth.publish(h)
	str = String()
        str.data = "setheat"
        self._publisherauto.publish(str)
开发者ID:ChunkyBART,项目名称:gitUploadAuto2015,代码行数:7,代码来源:robot_steering.py

示例9: execute

    def execute(self, ud):

        initial_pose = PoseWithCovarianceStamped()
        initial_pose.header.frame_id = 'map'
        initial_pose.pose.pose.position.x = 0.0
        initial_pose.pose.pose.position.y = 0.0
        initial_pose.pose.pose.orientation.x = 0.0
        initial_pose.pose.pose.orientation.y = 0.0
        initial_pose.pose.pose.orientation.z = 0.0
        initial_pose.pose.pose.orientation.w = 1.0

        self.amcl_initial_pose_pub.publish(initial_pose)

        neck_cmd = Float64()
        neck_cmd.data = -2.0
        self.neck_pub.publish(neck_cmd)

        rospy.sleep(rospy.Duration(2))
        neck_cmd.data = -0.7
        self.neck_pub.publish(neck_cmd)

        rospy.sleep(rospy.Duration(4))

        tts_msg = String()
        tts_msg.data = "I am ready to begin the inspection."
        self.tts_pub.publish(tts_msg)

        return 'init_done'
开发者ID:WalkingMachine,项目名称:sara_commun,代码行数:28,代码来源:inspection.py

示例10: auto_callback

    def auto_callback(self, data):
	#self._widget.textEdit.append('autocall')  
	str = String() 
        if data.data == "detectC":
	   self._widget.victim_label.setText('Found Hole')
           self._widget.current_z_angular_label.setEnabled(True)
	   self._widget.label.setEnabled(True)
	  # self._widget.groupBox.setEnabled(True)
	   self._widget.comfirm_button.setEnabled(True)
	   self._widget.approach_victim_button.setEnabled(True)
	   self._widget.ignor_button.setEnabled(True)
           str.data = "stop"
           self._publishersys.publish(str)
   	if data.data == "detectT":
	   self._widget.victim_label.setText('Found Temp')
           self._widget.current_z_angular_label.setEnabled(True)
	   self._widget.label.setEnabled(True)
	  # self._widget.groupBox.setEnabled(True)
	   self._widget.comfirm_button.setEnabled(True)
	   self._widget.approach_victim_button.setEnabled(True)
	   self._widget.ignor_button.setEnabled(True)
	if data.data == "detectQ":
	   self._widget.victim_label.setText('QR Found')
           self._widget.current_z_angular_label.setEnabled(True)
	   self._widget.label.setEnabled(True)
开发者ID:ChunkyBART,项目名称:gitUploadAuto2015,代码行数:25,代码来源:robot_steering.py

示例11: _on_check_sensor_pressed

    def	_on_check_sensor_pressed(self):
	str = String()
	str.data = "check_sensor"
	self._publishersys.publish(str)
	self._widget.victim_label.setText('Check SS')
	self._widget.CO2.setText('0')
	self._widget.current_z_angular_label.setText('0')
开发者ID:ChunkyBART,项目名称:gitUploadAuto2015,代码行数:7,代码来源:robot_steering.py

示例12: main

def main(argv=sys.argv[1:]):
    parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument(
        '--reliable', dest='reliable', action='store_true',
        help='set qos profile to reliable')
    parser.set_defaults(reliable=False)
    parser.add_argument(
        '-n', '--number_of_cycles', type=int, default=20,
        help='number of sending attempts')
    args = parser.parse_args(argv)
    rclpy.init()

    if args.reliable:
        custom_qos_profile = qos_profile_default
        print('Reliable publisher')
    else:
        custom_qos_profile = qos_profile_sensor_data
        print('Best effort publisher')

    node = rclpy.create_node('talker_qos')

    chatter_pub = node.create_publisher(String, 'chatter_qos', custom_qos_profile)

    msg = String()

    cycle_count = 0
    while rclpy.ok() and cycle_count < args.number_of_cycles:
        msg.data = 'Hello World: {0}'.format(cycle_count)
        print('Publishing: "{0}"'.format(msg.data))
        chatter_pub.publish(msg)
        cycle_count += 1
        sleep(1)
开发者ID:rohbotics,项目名称:demos,代码行数:32,代码来源:talker_qos_py.py

示例13: createTopLevel

    def createTopLevel(self, stimuliFile, numReps):
        """Creates the top level directory, randomizes input list"""
        self.sessionID = str(rospy.Time.now())
        self.topleveldir = os.environ["HOME"] + "/UltraspeechData/" + str(datetime.date.today()) + "_" + self.sessionID

        os.makedirs(self.topleveldir)
        monocamdir = self.topleveldir + "/monocam"
        os.makedirs(monocamdir)
        stereorightdir = self.topleveldir + "/stereoright"
        os.makedirs(stereorightdir)
        stereoleftdir = self.topleveldir + "/stereoleft"
        os.makedirs(stereoleftdir)
        ultrasounddir = self.topleveldir + "/ultrasound"
        os.makedirs(ultrasounddir)

        stimuli = open(stimuliFile, "r").readlines()
        random.shuffle(stimuli)

        self.stimuliList = []
        for i in range(numReps):
            for j in stimuli:
                if j != "\n":
                    self.stimuliList.append(j[:-1])

        self.numReps = numReps
        self.numBatches = int(math.ceil(float(len(self.stimuliList)) / 10.0))
        self.console.set_text("Press Start to begin")

        for i in range(2):
            # this tells the logger where to create the logfile
            msg = String()
            msg.data = str(self.topleveldir)
            self.startupTopic.publish(msg)
            time.sleep(1)  # for some reason the first one is not published
开发者ID:ZhengYi0310,项目名称:ua-ros-pkg,代码行数:34,代码来源:subjectUI.py

示例14: publish_haptic_control

    def publish_haptic_control(self, ctrl):
        # publish haptic feedback
        haptic_msg = String()
        haptic_msg.data = "{:d},{:d}".format(int(ctrl[0]), int(ctrl[1]))
        print haptic_msg.data, "\r"

        self.haptic_msg_pub.publish(haptic_msg)
开发者ID:yuhangc,项目名称:proactive_guidance,代码行数:7,代码来源:random_guidance_exp.py

示例15: default

    def default(self, ci='unused'):
        """ Publish the data of the semantic camera as a ROS String message that contains a lisp-list.

        This function was designed for the use with CRAM and the Adapto group
        """
        string = String()
        string.data = "("
        for obj in self.data['visible_objects']:
            # if object has no description, set to '-'
            if obj['description'] == '':
                description = '-'

            # send tf-frame for every object
            self.sendTransform(self, obj['position'], obj['orientation'], \
                               rospy.Time.now(), str(obj['name']), "/map")

            # Build string from name, description, location and orientation in the global world frame
            string.data += "(" + str(obj['name']) + " " + description + " " + \
                           str(obj['position'].x) + " " + \
                           str(obj['position'].y) + " " + \
                           str(obj['position'].z) + " " + \
                           str(obj['orientation'].x) + " " + \
                           str(obj['orientation'].y) + " " + \
                           str(obj['orientation'].z) + " " + \
                           str(obj['orientation'].w) + ")"

        string.data += ")"
        self.publish(string)
开发者ID:matrixchan,项目名称:morse,代码行数:28,代码来源:semantic_camera.py


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