当前位置: 首页>>代码示例>>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;未经允许,请勿转载。