當前位置: 首頁>>代碼示例>>Python>>正文


Python msg.String方法代碼示例

本文整理匯總了Python中std_msgs.msg.String方法的典型用法代碼示例。如果您正苦於以下問題:Python msg.String方法的具體用法?Python msg.String怎麽用?Python msg.String使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在std_msgs.msg的用法示例。


在下文中一共展示了msg.String方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import String [as 別名]
def __init__(self):
        # Audio stream input setup
        FORMAT = pyaudio.paInt16
        CHANNELS = 1
        RATE = 16000
        self.CHUNK = 4096
        self.audio = pyaudio.PyAudio()
        self.stream = self.audio.open(format=FORMAT, channels=CHANNELS,
                                      rate=RATE, input=True,
                                      frames_per_buffer=self.CHUNK,
                                      stream_callback=self.get_data)
        self._buff = Queue.Queue()  # Buffer to hold audio data
        self.closed = False

        # ROS Text Publisher
        self.text_pub = rospy.Publisher('/google_client/text', String, queue_size=10)

        # Context clues in yaml file
        rospack = rospkg.RosPack()
        yamlFileDir = rospack.get_path('dialogflow_ros') + '/config/context.yaml'
        with open(yamlFileDir, 'r') as f:
            self.context = yaml.load(f) 
開發者ID:piraka9011,項目名稱:dialogflow_ros,代碼行數:24,代碼來源:google_client.py

示例2: __init__

# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import String [as 別名]
def __init__(self):
        # Audio stream input setup
        FORMAT = pyaudio.paInt16
        CHANNELS = 1
        RATE = 16000
        self.CHUNK = 4096
        self.audio = pyaudio.PyAudio()
        self.stream = self.audio.open(format=FORMAT, channels=CHANNELS,
                                      rate=RATE, input=True,
                                      frames_per_buffer=self.CHUNK,
                                      stream_callback=self._get_data)
        self._buff = Queue.Queue()  # Buffer to hold audio data
        self.closed = False

        # ROS Text Publisher
        text_topic = rospy.get_param('/text_topic', '/dialogflow_text')
        self.text_pub = rospy.Publisher(text_topic, String, queue_size=10) 
開發者ID:piraka9011,項目名稱:dialogflow_ros,代碼行數:19,代碼來源:mic_client.py

示例3: __init__

# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import String [as 別名]
def __init__(self):
        self.evadeSet = False
        self.controller = XBox360()
        self.bridge = CvBridge()
        self.throttle = 0
        self.grid_img = None
        ##self.throttleLock = Lock()
        print "evasion"
        rospy.Subscriber("/lidargrid", Image, self.gridCB, queue_size=1)
        rospy.Subscriber("/cmd_vel", TwistStamped , self.twistCB , queue_size = 1)
        rospy.Subscriber("/joy", Joy, self.joyCB, queue_size=5)
        self.pub_img = rospy.Publisher("/steering_img", Image)
        self.pub_twist = rospy.Publisher("/lidar_twist", TwistStamped, queue_size=1)
        self.sound = rospy.Publisher("/sound_server/speech_synth", String, queue_size=1)        
        rospy.init_node ('lidar_cmd',anonymous=True)
        rospy.spin() 
開發者ID:DJTobias,項目名稱:Cherry-Autonomous-Racecar,代碼行數:18,代碼來源:lidarEvasion.py

示例4: __init__

# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import String [as 別名]
def __init__(self):
        print "dataRecorder"
        self.record = False
        self.twist = None
        self.twistLock = Lock()
        self.bridge = CvBridge()
        self.globaltime = None
        self.controller = XBox360()
        ##rospy.Subscriber("/camera/depth/points" , PointCloud2, self.ptcloudCB)
        rospy.Subscriber("/camera/depth/image_rect_raw_drop", Image, self.depthCB)
        rospy.Subscriber("/camera/rgb/image_rect_color_drop", Image, self.streamCB)
        #rospy.Subscriber("/camera/rgb/image_rect_mono_drop", Image, self.streamCB)  ##for black and white images see run.launch and look at the drop fps nodes near the bottom
        rospy.Subscriber("/lidargrid", Image, self.lidargridCB)
        rospy.Subscriber("/cmd_vel", TwistStamped, self.cmd_velCB)
        rospy.Subscriber("/joy", Joy ,self.joyCB)
        self.sound = rospy.Publisher("/sound_server/speech_synth", String, queue_size=1)
        rospy.init_node('dataRecorder',anonymous=True)
        rospy.spin() 
開發者ID:DJTobias,項目名稱:Cherry-Autonomous-Racecar,代碼行數:20,代碼來源:dataRecorder.py

示例5: __init__

# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import String [as 別名]
def __init__(self):
        rospy.loginfo("runner.__init__")
        # ----------------------------
        self.sess = tf.InteractiveSession()
        self.model = cnn_cccccfffff()
        saver = tf.train.Saver()
        saver.restore(self.sess, "/home/ubuntu/catkin_ws/src/car/scripts/model.ckpt")
        rospy.loginfo("runner.__init__: model restored")
        # ----------------------------
        self.bridge = CvBridge()
        self.netEnable = False
        self.controller = XBox360()
        rospy.Subscriber("/camera/rgb/image_rect_color", Image, self.runCB)
        rospy.Subscriber("/joy", Joy ,self.joyCB)
        self.pub_twist = rospy.Publisher("/neural_twist", TwistStamped, queue_size=1)
        self.sound = rospy.Publisher("/sound_server/speech_synth", String, queue_size=1)
        rospy.init_node('neural_cmd',anonymous=True)
        rospy.spin() 
開發者ID:DJTobias,項目名稱:Cherry-Autonomous-Racecar,代碼行數:20,代碼來源:runModel.py

示例6: main

# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import String [as 別名]
def main(args=None):
    global g_node
    rclpy.init(args=args)

    g_node = rclpy.create_node('minimal_subscriber')

    subscription = g_node.create_subscription(String, 'topic', chatter_callback, 10)
    subscription  # prevent unused variable warning

    while rclpy.ok():
        rclpy.spin_once(g_node)

    # Destroy the node explicitly
    # (optional - otherwise it will be done automatically
    # when the garbage collector destroys the node object)
    g_node.destroy_node()
    rclpy.shutdown() 
開發者ID:ros2,項目名稱:examples,代碼行數:19,代碼來源:subscriber_old_school.py

示例7: main

# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import String [as 別名]
def main(args=None):
    rclpy.init(args=args)

    node = rclpy.create_node('minimal_publisher')

    publisher = node.create_publisher(String, 'topic', 10)

    msg = String()

    i = 0
    while rclpy.ok():
        msg.data = 'Hello World: %d' % i
        i += 1
        node.get_logger().info('Publishing: "%s"' % msg.data)
        publisher.publish(msg)
        sleep(0.5)  # seconds

    # Destroy the node explicitly
    # (optional - otherwise it will be done automatically
    # when the garbage collector destroys the node object)
    node.destroy_node()
    rclpy.shutdown() 
開發者ID:ros2,項目名稱:examples,代碼行數:24,代碼來源:publisher_old_school.py

示例8: __init__

# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import String [as 別名]
def __init__(self):
	
        # Create a publisher for our custom message.
        self.pub = rospy.Publisher('from_ros_to_slack', String, queue_size=10)
	rospy.Subscriber("from_slack_to_ros", String, self.callback)

        # Main while loop.
        while not rospy.is_shutdown():
	    # Sleep for a while before publishing new messages. Division is so rate != period.
            rospy.sleep(5.0) 
開發者ID:smart-robotics-team,項目名稱:slack-ros-pkg,代碼行數:12,代碼來源:slack_test.py

示例9: __init__

# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import String [as 別名]
def __init__(self):
        # Get the ~private namespace parameters from command line or launch file.
        self.token = rospy.get_param('~token', 'xoxp-123456789')
        self.channel = rospy.get_param('~channel', 'G1234567Q')
        self.username = rospy.get_param('~username', 'ros-bot')
	
        # Create a publisher for our custom message.
        pub = rospy.Publisher('from_slack_to_ros', String, queue_size=10)
	rospy.Subscriber("from_ros_to_slack", String, self.callback)
	rospy.Subscriber("send_file_to_slack", String, self.filecallback)

	# Create the slack client
	self.sc = SlackClient(self.token)

	if self.sc.rtm_connect():

            # Main while loop.
            while not rospy.is_shutdown():
                for reply in self.sc.rtm_read():
                    if "type" in reply and "user" in reply:
                        #print reply
                        if reply["type"] == "message" and reply["channel"] == self.channel:
                            pub.publish(reply["text"])
                
	        # Sleep for a while before publishing new messages. Division is so rate != period.
                rospy.sleep(2.0) 
開發者ID:smart-robotics-team,項目名稱:slack-ros-pkg,代碼行數:28,代碼來源:slack_ros.py

示例10: write_serial

# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import String [as 別名]
def write_serial(self, message):
        self._SerialPublisher.publish(String(str(self._counter) + ", out: " + message))
        self._SerialDataGateway.Write(message) 
開發者ID:tianbot,項目名稱:tianbot_racecar,代碼行數:5,代碼來源:tianbot_racecar_node.py

示例11: __init__

# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import String [as 別名]
def __init__(self, node, topic, summary_table, *, qos=qos_profile_system_default):
        self._summary_table = summary_table
        self._pub = node.create_publisher(String, topic, qos) 
開發者ID:ros2,項目名稱:ros2cli,代碼行數:5,代碼來源:hello.py

示例12: publish

# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import String [as 別名]
def publish(self):
        msg = String()
        hostname = socket.gethostname()
        msg.data = f"hello, it's me {hostname}"
        self._summary_table.increment_pub()
        self._pub.publish(msg) 
開發者ID:ros2,項目名稱:ros2cli,代碼行數:8,代碼來源:hello.py

示例13: __init__

# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import String [as 別名]
def __init__(self):
        super().__init__('talker_node')
        self.count = 1
        self.pub = self.create_publisher(String, 'chatter', 10)
        self.tmr = self.create_timer(1.0, self.callback) 
開發者ID:ros2,項目名稱:ros2cli,代碼行數:7,代碼來源:talker_node.py

示例14: callback

# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import String [as 別名]
def callback(self):
        self.pub.publish(String(data='Hello World: {0}'.format(self.count)))
        self.count += 1 
開發者ID:ros2,項目名稱:ros2cli,代碼行數:5,代碼來源:talker_node.py

示例15: _text_request_cb

# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import String [as 別名]
def _text_request_cb(self, msg):
        """ROS Callback that sends text received from a topic to Dialogflow,
        :param msg: A String message.
        :type msg: String
        """
        rospy.logdebug("DF_CLIENT: Request received")
        new_msg = DialogflowRequest(query_text=msg.data)
        df_msg = self.detect_intent_text(new_msg) 
開發者ID:piraka9011,項目名稱:dialogflow_ros,代碼行數:10,代碼來源:dialogflow_client.py


注:本文中的std_msgs.msg.String方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。