python类String()的实例源码

talker.py 文件源码 项目:cnn_picture_gazebo 作者: liuyandong1988 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def talker():
    pub = rospy.Publisher('chatter', String, queue_size=10)
    rospy.init_node('talker', anonymous=True)
    rate = rospy.Rate(10) # 10hz
    while not rospy.is_shutdown():
        hello_str = "hello world %s" % rospy.get_time()
        rospy.loginfo(hello_str)
        pub.publish(hello_str)
        rate.sleep()

#    rate = rospy.Rate(10)
#    hello_str = "hello world"
 #   rospy.loginfo(hello_str)
 #   pub.publish(hello_str)
 #   rospy.spin()
 #   exit(0)
interface_test.py 文件源码 项目:Story_CoWriting 作者: alexis-jacq 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def ros_loop(test):
    while True:

        rospy.Subscriber('human_turn_topic', String, human_turn)
        rospy.Subscriber('human_chosen_topic', String, have_chosen)
        rospy.Subscriber('human_predict_turn_topic', String, human_predict)
        rospy.Subscriber('robot_turn_topic', String, robot_turn)
        rospy.Subscriber('robot_chosen_topic', String, have_chosen)
        rospy.Subscriber('story_telling', String, new_phrase)
        rospy.Subscriber('new_element', String, new_element)

        rospy.sleep(0.1)

    rospy.spin()


################################################
interface _test.py 文件源码 项目:Story_CoWriting 作者: alexis-jacq 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def ros_loop(test):
    while True:

        rospy.Subscriber('human_turn_topic', String, human_turn)
        rospy.Subscriber('human_chosen_topic', String, have_chosen)
        rospy.Subscriber('human_predict_turn_topic', String, human_predict)
        rospy.Subscriber('robot_turn_topic', String, robot_turn)
        rospy.Subscriber('robot_chosen_topic', String, have_chosen)
        rospy.Subscriber('story_telling', String, new_phrase)
        rospy.Subscriber('new_element', String, new_element)

        rospy.sleep(0.1)

    rospy.spin()


################################################
interface.py 文件源码 项目:Story_CoWriting 作者: alexis-jacq 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def ros_loop(test):
    while True:

        rospy.Subscriber('human_turn_topic', String, human_turn)
        rospy.Subscriber('human_chosen_topic', String, have_chosen)
        rospy.Subscriber('human_predict_turn_topic', String, human_predict)
        rospy.Subscriber('robot_turn_topic', String, robot_turn)
        rospy.Subscriber('robot_chosen_topic', String, have_chosen)
        rospy.Subscriber('story_telling', String, new_phrase)
        rospy.Subscriber('new_element', String, new_element)

        rospy.sleep(0.1)

    rospy.spin()


################################################
action_handler.py 文件源码 项目:aide 作者: Lambda-3 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def main():
    rospy.init_node("actions")
    loginfo("Creating action handler...")
    action_handler = ActionHandler()
    loginfo("Registering services...")

    get_service_handler(CallFunction).register_service(
        lambda func_name, kwargs: action_handler.call_func(func_name, **json.loads(kwargs))
    )
    rospy.Subscriber("/aide/update_apis", String, lambda x: action_handler.reload_api_references(x.data))

    get_service_handler(GetActionProvider).register_service(lambda name: action_handler.get_action_provider(name) or ())
    get_service_handler(GetAllActionProviders).register_service(action_handler.get_all_action_providers)
    get_service_handler(AddActionProvider).register_service(action_handler.add_action_provider)
    get_service_handler(DeleteActionProvider).register_service(action_handler.remove_action_provider)

    loginfo("Registered services. Spinning.")

    rospy.spin()
api_handler.py 文件源码 项目:aide 作者: Lambda-3 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def main():
    rospy.init_node("api_handler")
    loginfo("Creating api handler...")
    notify_publisher = rospy.Publisher("/aide/update_apis", String, queue_size=50)

    api = ApiHandler(lambda x: notify_publisher.publish(x))
    loginfo("Registering services...")

    get_service_handler(GetApi).register_service(lambda **args: api.get_api(**args) or ())
    get_service_handler(GetAllApis).register_service(api.get_all_apis)
    get_service_handler(AddApi).register_service(api.add_api)
    get_service_handler(DeleteApi).register_service(api.remove_api)

    loginfo("Registered services. Spinning.")

    rospy.spin()
Planner.py 文件源码 项目:pddl4j_rospy 作者: pellierd 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def listenerDomainNameProblem(self):
        '''
        listen on the topic domain_problem_from_controller_topic
        It get a String msg structured like [problemDirectory__problemName]
        The callback function is resolvProblemAsTopic which take the data received in parameter
        :param: void
    :return: void
        '''
        rospy.Subscriber("domain_problem_from_controller_topic",
                         String, self.resolvProblemAsTopic)
        print(">> Ready to be requested, waiting a std_msgs/String...")
        print(">> Topic : /domain_problem_from_controller_topic...")
        print(">> Callback : resolvProblemAsTopic...")
        print("############################"
              + "######################################")
        rospy.spin()
subscriber.py 文件源码 项目:ab2016-ros-gazebo 作者: akademikbilisim 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def main():
    rospy.init_node("listener")

    sub = rospy.Subscriber("/chatter_topic", String, callback)

    rospy.spin()
gaze_node.py 文件源码 项目:mhri 作者: mhri 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self):
        rospy.init_node('gaze', anonymous=False)

        self.lock = threading.RLock()
        with self.lock:
            self.current_state = GazeState.IDLE
            self.last_state = self.current_state

        # Initialize Variables
        self.glance_timeout = 0
        self.glance_timecount = 0
        self.glance_played = False

        self.idle_timeout = 0
        self.idle_timecount = 0
        self.idle_played = False


        rospy.loginfo('\033[92m[%s]\033[0m waiting for bringup social_mind...'%rospy.get_name())
        rospy.wait_for_service('environmental_memory/read_data')
        rospy.wait_for_service('social_events_memory/read_data')

        self.rd_memory = {}
        self.rd_memory['environmental_memory'] = rospy.ServiceProxy('environmental_memory/read_data', ReadData)
        self.rd_memory['social_events_memory'] = rospy.ServiceProxy('social_events_memory/read_data', ReadData)

        rospy.Subscriber('raising_events', RaisingEvents, self.handle_raising_events)
        rospy.Subscriber('gaze_focusing', String, self.handle_gaze_focusing)
        self.pub_gaze_cmd = rospy.Publisher('gaze_command', GazeCommand, queue_size=10)
        self.pub_viz_gaze_cmd = rospy.Publisher('visualization_gaze_cmd', PointStamped, queue_size=10)

        rospy.Timer(rospy.Duration(GAZE_CONTROLLER_PERIOD), self.handle_gaze_controller)
        rospy.loginfo('\033[92m[%s]\033[0m initialized...'%rospy.get_name())
        rospy.spin()
base.py 文件源码 项目:needybot-core 作者: needybot 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def abort(self, req=None):
        """
        Service function for the aborting the task '[name]_abort'.

        handles a shutdown of the task but instead of calling signal_complete,
        this method calls `signal_aborted`, which lets the task server know
        that it can proceed with launching a mayday task (as opposed to queueing
        up another general task).

        Args:
            msg (std_msgs.msg.String): the message received through the
                subscriber channel.
        """
        if not self.active:
            logwarn("Can't abort {} because task isn't active.".format(self.name))
            return False

        self.instruct()
        self.prep_shutdown(did_fail=True)
        return True
grasp_generator_cube.py 文件源码 项目:cu-perception-manipulation-stack 作者: correlllab 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self):
        self.listen = tf.TransformListener()
        self.broadcast = tf.TransformBroadcaster()

        self.obj_pose_sub = rospy.Subscriber("/pick_frame_name", String,
                                          self.set_pick_frame,
                                          queue_size=1)

        self.obj_pose_sub = rospy.Subscriber("/place_frame_name", String,
                                          self.set_place_frame,
                                          queue_size=1)

        self.obj_pose_sub = rospy.Subscriber("/num_objects", Int64,
                                  self.broadcast_frames,
                                  queue_size=1)

        self.place_frame = ''
        self.pick_frame = ''
        self.tower_size = 1
        self.tower_size_sub = rospy.Subscriber("/tower_size",Int64,self.set_tower_size)
services.py 文件源码 项目:APEX 作者: ymollard 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def __init__(self):
        self.services = {'set_iteration': {'name': 'learning/set_iteration', 'type': SetIteration},
                         'set_focus': {'name': 'learning/set_interest', 'type': SetFocus},
                         'assess': {'name': 'controller/assess', 'type': Assess},
                         'get_interests': {'name': 'learning/get_interests', 'type': GetInterests}}

        rospy.Subscriber('learning/current_focus', String, self._cb_focus)
        rospy.Subscriber('learning/user_focus', String, self._cb_user_focus)
        rospy.Subscriber('learning/ready_for_interaction', Bool, self._cb_ready)

        self.current_focus = ""
        self.user_focus = ""
        self.ready_for_interaction = False

        for service_name, service in self.services.items():
            rospy.loginfo("User node is waiting service {}...".format(service['name']))
            rospy.wait_for_service(service['name'])
            service['call'] = rospy.ServiceProxy(service['name'], service['type'])

        rospy.loginfo("User node started!")
voice_node.py 文件源码 项目:baidu_speech 作者: DinnerHowe 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def __init__(self):
  if_continue=''
  while not rospy.is_shutdown() and if_continue == '':

   self.define()

   self.recode()

   words = self.reg()

   reg = rospy.Publisher('Rog_result', String, queue_size=1)

   reg.publish(words)

   #self.savewav("testing")#testing

   if_continue = raw_input('pls input ????? to continue')
__init__.py 文件源码 项目:lidapy-framework 作者: CognitiveComputingResearchGroup 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def __init__(self, topic_name, msg_type=None, queue_size=None, preprocessor=None):
        super(RosTopicPublisher, self).__init__(topic_name, msg_type, queue_size, preprocessor)

        self.msg_type = std_msgs.String if msg_type is None else msg_type
        self.queue_size = 10

        if preprocessor is None:
            if self.msg_type is std_msgs.String:
                def default_preprocessor(msg):
                    return MsgUtils.serialize(msg)

                self.preprocessor = default_preprocessor

        self._publisher = rospy.Publisher(name=self.topic_name,
                                          data_class=self.msg_type,
                                          queue_size=self.queue_size)
__init__.py 文件源码 项目:lidapy-framework 作者: CognitiveComputingResearchGroup 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def __init__(self, topic_name, msg_type=None, queue_size=None, postprocessor=None):
        super(RosTopicSubscriber, self).__init__(topic_name=topic_name,
                                                 msg_type=std_msgs.String if msg_type is None else msg_type,
                                                 queue_size=1 if queue_size is None else queue_size,
                                                 postprocessor=postprocessor)

        if postprocessor is None:
            if self.msg_type is std_msgs.String:
                def default_postprocessor(msg):
                    return MsgUtils.deserialize(RosMsgUtils.unwrap(msg, 'data'))

                self.postprocessor = default_postprocessor

        self._subscriber = rospy.Subscriber(name=self.topic_name,
                                            data_class=self.msg_type,
                                            callback=self._subscribe,
                                            callback_args=None,
                                            queue_size=self.queue_size)
rosmain.py 文件源码 项目:PyByrobotPetrone 作者: ildoonet 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def __init__(self):
        self.petrone = Petrone()

        # subscriber
        self.sub_flight = rospy.Subscriber('cmd_fly', Int8, self.cb_fly, queue_size=1)
        self.sub_cmd = rospy.Subscriber('cmd_vel_raw', Twist, self.cb_cmd, queue_size=1)
        self.sub_color = rospy.Subscriber('led_color', String, self.cb_color, queue_size=1)

        # publisher
        self.pub_battery = rospy.Publisher('battery', Float32, queue_size=1)
        self.pub_status_flight = rospy.Publisher('status/flight', Int8, queue_size=1)
        self.pub_status_system = rospy.Publisher('status/system', Int8, queue_size=1)
        self.pub_imu = rospy.Publisher('imu', Imu, queue_size=1)

        # cache
        self.is_disconnected = True
        self.last_values = defaultdict(lambda: 0)

        # flight parameters
        self.twist = Twist()
        self.twist_at = 0
play_file_server.py 文件源码 项目:audio_file_player 作者: uts-magic-lab 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self):
        rospy.loginfo("Initializing AudioFilePlayer...")
        self.current_playing_process = None
        self.afp_as = SimpleActionServer(rospy.get_name(), AudioFilePlayAction,
                                         self.as_cb, auto_start=False)
        self.afp_sub = rospy.Subscriber('~play', String, self.topic_cb,
                                        queue_size=1)
        # By default this node plays files using the aplay command
        # Feel free to use any other command or flags
        # by using the params provided
        self.command = rospy.get_param('~/command', 'play')
        self.flags = rospy.get_param('~/flags', '')
        self.feedback_rate = rospy.get_param('~/feedback_rate', 10)
        self.afp_as.start()
        # Needs to be done after start
        self.afp_as.register_preempt_callback(self.as_preempt_cb)

        rospy.loginfo(
            "Done, playing files from action server or topic interface.")
time_trial_driver_follower.py 文件源码 项目:racecar_7 作者: karennguyen 项目源码 文件源码 阅读 42 收藏 0 点赞 0 评论 0
def __init__(self):
        '''
        Instance variables
        '''

        #use this for small step accerleration
        self.last_speed=0
        self.e1 = 0
    self.e2 = 0
        '''
        Node setup and start
        '''
        self.drive = rospy.Publisher('/vesc/ackermann_cmd_mux/input/navigation', AckermannDriveStamped, queue_size=5)
        rospy.Subscriber('scan', LaserScan, self.laserCall)
        rospy.Subscriber('/color', String, self.blobCall)

        '''
        Leave the robot going until roscore dies, then set speed to 0
        '''
        self.drive.publish(AckermannDriveStamped())
        print ("init")
launchpad_node.py 文件源码 项目:plantbot 作者: marooncn 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def _WriteSerial(self, message):
        self._SerialPublisher.publish(String(str(self._Counter) + ", out: " + message))
        self._SerialDataGateway.Write(message)

#######################################################################################################################
publisher.py 文件源码 项目:ab2016-ros-gazebo 作者: akademikbilisim 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def main():
    rospy.init_node("talker")
    pub = rospy.Publisher("/chatter_topic", String, queue_size=1)
    rate = rospy.Rate(10) # 10 Hertz ile çal???yor

    while not rospy.is_shutdown():
        message = "Naber Dünya? %s" % (rospy.get_time())
        rospy.loginfo("Mesaj haz?rland?: %s" % message)
        pub.publish(message)
        rate.sleep()
phone_call.py 文件源码 项目:nao_slam_amcl 作者: hu7241 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def talker(fromDavid):
    pub = rospy.Publisher('/recognizer/output', String, queue_size=10)

    action = fromDavid
    #rospy.loginfo(action)
    pub.publish(action)
nav_asr_6.py 文件源码 项目:nao_slam_amcl 作者: hu7241 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self):
        rospy.init_node('nav_asr', anonymous = True)
        rospy.Subscriber("/recognizer/output", String, self.SpeechUpdateGoal)
        rospy.Subscriber("/WPsOK", String, self.GetWayPoints)

        self.waypoint_list     = dict()
        self.marker_list       = list()
        self.makerArray        = MarkerArray()

        self.makerArray_pub    = rospy.Publisher("Waypoint_Array",MarkerArray,queue_size=5)

        rospy.on_shutdown(self.shutdown) # @@@@
        # How long in seconds should the robot pause at each location?
        self.rest_time = rospy.get_param("~rest_time", 2)
        # Are we running in the fake simulator?
        self.fake_test = rospy.get_param("~fake_test", True)
        # Publisher to manually control the robot (e.g. to stop it, queue_size=5)
        self.cmd_vel_pub = rospy.Publisher('cmd_vel', Twist, queue_size=5)
        # Subscribe to the move_base action server
        self.move_base = actionlib.SimpleActionClient("move_base", MoveBaseAction)
        rospy.loginfo("Waiting for move_base action server...")
        # Wait 60 seconds for the action server to become available
        self.move_base.wait_for_server(rospy.Duration(60))
        rospy.loginfo("Connected to move base server")

    # Create the waypoints list from txt
phone_call.py 文件源码 项目:nao_slam_amcl 作者: hu7241 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def talker(fromDavid):
    pub = rospy.Publisher('/recognizer/output', String, queue_size=10)

    action = fromDavid
    #rospy.loginfo(action)
    pub.publish(action)
gui.py 文件源码 项目:nao_slam_amcl 作者: hu7241 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def pubDataStaus(dataStatus): 
    pub = rospy.Publisher('WPsOK', String, queue_size=10)
    pub.publish(dataStatus)
functions_node_rospy.py 文件源码 项目:roshelper 作者: wallarelvo 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def publish_str(word):
    rospy.loginfo("Pub --> {}".format(word))
    st = String()
    st.data = word[::-1]
    str_pub.publish(st)
class_node.py 文件源码 项目:roshelper 作者: wallarelvo 项目源码 文件源码 阅读 50 收藏 0 点赞 0 评论 0
def str_pub(self, word):
        rospy.loginfo("Pub --> {}".format(word))
        st = String()
        st.data = word[::-1]
        return st
functions_node.py 文件源码 项目:roshelper 作者: wallarelvo 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def str_pub(word):
    rospy.loginfo("Pub --> {}".format(word))
    st = String()
    st.data = word[::-1]
    return st
function_unit.py 文件源码 项目:micros_mars_task_alloc 作者: liminglong 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def run(self):
        pass
        #rospy.init_node(self._node_name)
        #send1 = send.Send('hello_world', String)
        #receive1 = receive.Receive('hello_world_2', String, self.on_received1)#?FunctionUnit??????
        #rospy.spin()
contr_turtle (copy).py 文件源码 项目:cnn_picture_gazebo 作者: liuyandong1988 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def contr( keynumber ):
    rospy.init_node('talker', anonymous=True)
    pub = rospy.Publisher('number', String, queue_size=10)


    rate = rospy.Rate(1) # 10hz
    while not rospy.is_shutdown():
        num = str('%d'%keynumber)
        pub.publish(num)
        rospy.loginfo(num)
        rate.sleep()

    # num = str('%d'%keynumber)
    # pub.publish(num)
    # rospy.loginfo(num)
interface_test.py 文件源码 项目:Story_CoWriting 作者: alexis-jacq 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def robot_turn(msg):
    global last_message
    if msg.data!=last_message:
        last_message = msg.data
        received_msg = String()
        received_msg.data = "receives: " + msg.data
        pub_reception.publish(received_msg)
        label, _, items, name = read_msg(msg)
        p1.robot(label, items, name)
        p1.mainframe.tkraise()


问题


面经


文章

微信
公众号

扫码关注公众号