Python rospy 模块,spin() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用rospy.spin()

项目:roshelper    作者:wallarelvo    | 项目源码 | 文件源码
def _start(self, spin):
        for args, kwargs in self.subscribers:
            self.subscribers_init.append(rospy.Subscriber(*args, **kwargs))
        is_func = isinstance(self.cl, types.FunctionType)
        is_class = isinstance(self.cl, types.TypeType)
        if is_class:
            targ = self.__start_class
        elif is_func:
            targ = self.__start_func
        self.thread = threading.Thread(target=targ,
                                       args=(self.cl,) + self.cl_args,
                                       kwargs=self.cl_kwargs)
        self.thread.daemon = True
        self.thread.start()
        if spin:
            rospy.spin()
        return self
项目:amosero    作者:PaulPetring    | 项目源码 | 文件源码
def listener():
    global odom_pub,left_motor_pub,left_motor_speed_pub,right_motor_pub,right_motor_speed_pub

    #subscribing to required topics
    rospy.Subscriber("/cmd_vel", Twist, cmd_velCb)
    rospy.Subscriber('imu_data',Imu,imuCb)
    rospy.Subscriber('north',std_msgs.msg.Float32,northCb)

    odom_pub = rospy.Publisher('/odom', Odometry, queue_size=10)
    left_motor_pub = rospy.Publisher('/left_motor', std_msgs.msg.Int32, queue_size=10)
    right_motor_pub = rospy.Publisher('/right_motor', std_msgs.msg.Int32, queue_size=10)

    #left_motor_speed_pub = rospy.Publisher('/left_motor_speed', std_msgs.msg.Int32, queue_size=10)
    #right_motor_speed_pub = rospy.Publisher('/right_motor_speed', std_msgs.msg.Int32, queue_size=10)


    rospy.spin()
项目:mhri    作者:mhri    | 项目源码 | 文件源码
def __init__(self):
        rospy.init_node('multiplexer_node', anonymous=False)

        rospy.loginfo('\033[93m[%s]\033[0m wait for bringup social_events_memory...'%rospy.get_name())
        rospy.wait_for_service('social_events_memory/read_data')
        self.rd_event_mem = rospy.ServiceProxy('social_events_memory/read_data', ReadData)
        rospy.Subscriber('forwarding_event', ForwardingEvent, self.handle_social_events)
        self.pub_rasing_event = rospy.Publisher('raising_events', RaisingEvents, queue_size=10)

        self.events_queue = Queue.Queue()
        self.recognized_words_queue = Queue.Queue()

        event_period = rospy.get_param('~event_period', 0.5)
        rospy.Timer(rospy.Duration(event_period), self.handle_trigger_events)

        rospy.loginfo('\033[93m[%s]\033[0m initialized...'%rospy.get_name())
        rospy.spin()
项目:cnn_picture_gazebo    作者:liuyandong1988    | 项目源码 | 文件源码
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)
项目:amosero    作者:PaulPetring    | 项目源码 | 文件源码
def listener():
    global odom_pub,left_motor_pub,left_motor_speed_pub,right_motor_pub,right_motor_speed_pub

    #subscribing to required topics
    rospy.Subscriber("/cmd_vel", Twist, cmd_velCb)
    rospy.Subscriber('imu_data',Imu,imuCb)
    rospy.Subscriber('north',std_msgs.msg.Float32,northCb)

    odom_pub = rospy.Publisher('/odom', Odometry, queue_size=10)
    left_motor_pub = rospy.Publisher('/left_motor', std_msgs.msg.Int32, queue_size=10)
    right_motor_pub = rospy.Publisher('/right_motor', std_msgs.msg.Int32, queue_size=10)

    #left_motor_speed_pub = rospy.Publisher('/left_motor_speed', std_msgs.msg.Int32, queue_size=10)
    #right_motor_speed_pub = rospy.Publisher('/right_motor_speed', std_msgs.msg.Int32, queue_size=10)


    rospy.spin()
项目:amosero    作者:PaulPetring    | 项目源码 | 文件源码
def listener():
    global odom_pub,left_motor_pub,left_motor_speed_pub,right_motor_pub,right_motor_speed_pub

    #subscribing to required topics
    rospy.Subscriber("/cmd_vel", Twist, cmd_velCb)
    rospy.Subscriber('imu_data',Imu,imuCb)
    rospy.Subscriber('north',std_msgs.msg.Float32,northCb)

    odom_pub = rospy.Publisher('/odom', Odometry, queue_size=10)
    left_motor_pub = rospy.Publisher('/left_motor', std_msgs.msg.Int32, queue_size=10)
    right_motor_pub = rospy.Publisher('/right_motor', std_msgs.msg.Int32, queue_size=10)

    #left_motor_speed_pub = rospy.Publisher('/left_motor_speed', std_msgs.msg.Int32, queue_size=10)
    #right_motor_speed_pub = rospy.Publisher('/right_motor_speed', std_msgs.msg.Int32, queue_size=10)


    rospy.spin()
项目:Story_CoWriting    作者:alexis-jacq    | 项目源码 | 文件源码
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()


################################################
项目:Story_CoWriting    作者:alexis-jacq    | 项目源码 | 文件源码
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()


################################################
项目:Story_CoWriting    作者:alexis-jacq    | 项目源码 | 文件源码
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()


################################################
项目:aide    作者:Lambda-3    | 项目源码 | 文件源码
def main():
    rospy.init_node("whatsapp_service")
    cred = credentials.WHATSAPP
    stackBuilder = YowStackBuilder()
    stack = (stackBuilder
             .pushDefaultLayers(True)
             .push(AideRosLayer)
             .build())
    loginfo("Stack built...")
    stack.setCredentials(cred)
    stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT))  # sending the connect signal
    loginfo("Connected...")
    atexit.register(lambda: stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_DISCONNECT)))

    th = threading.Thread(target=stack.loop)
    th.daemon = True
    th.start()
    loginfo("Running in background.")
    loginfo("All done. spinning.")
    while not rospy.is_shutdown():
        rospy.spin()
项目:aide    作者:Lambda-3    | 项目源码 | 文件源码
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()
项目:aide    作者:Lambda-3    | 项目源码 | 文件源码
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()
项目:RobotSoccer_TheFirstOrder    作者:snydergo    | 项目源码 | 文件源码
def ControlListener():

    rospy.init_node('robot_motion_control', anonymous=True)

    rospy.Subscriber("robot1Com", controldata, callback1)

    P1.pub = rospy.Publisher('/home1/command', Vector3, queue_size=10)

    rospy.Subscriber("robot2Com", controldata, callback2)

    P2.pub = rospy.Publisher('/home2/command', Vector3, queue_size=10)

    while not rospy.is_shutdown():
        rospy.spin()
    return

    # spin() simply keeps python from exiting until this node is stopped
    #rospy.spin()
项目:TA_example_labs    作者:mit-racecar    | 项目源码 | 文件源码
def drive(self):
        while not rospy.is_shutdown():
            if self.received_data is None or self.parsed_data is None:
                rospy.sleep(0.5)
                continue

            if np.any(self.parsed_data['front'][:,0] < MIN_FRONT_DIST):
                rospy.loginfo("stoping!")
                # this is overkill to specify the message, but it doesn't hurt
                # to be overly explicit
                drive_msg_stamped = AckermannDriveStamped()
                drive_msg = AckermannDrive()
                drive_msg.speed = 0.0
                drive_msg.steering_angle = 0.0
                drive_msg.acceleration = 0
                drive_msg.jerk = 0
                drive_msg.steering_angle_velocity = 0
                drive_msg_stamped.drive = drive_msg
                self.pub.publish(drive_msg_stamped)

            # don't spin too fast
            rospy.sleep(.1)
项目:offboard    作者:Stifael    | 项目源码 | 文件源码
def start():

    # create ros node handle
    nh = rospy.init_node('beziermapping')
    #nh = "fff"

    # create mapping obj
    mp = mapping(nh)

    rospy.spin()

    '''r = rospy.Rate(150)


    while not rospy.is_shutdown():
        if mp._run_bz_controller:

            mp._pub_thrust_sp_desired()

        r.sleep()'''
项目:racecar_7    作者:karennguyen    | 项目源码 | 文件源码
def __init__(self):
        '''
        Instance variables
        '''
        #constants for racecar speed and angle calculations
        self.pSpeed = 0.3
        self.pAngle = 1
        #positive charge behind racecar to give it a "kick" (forward vector)
        self.propelling_charge = 6
        #charge pushing on the car from the laser points
        self.charge = 0.005


        '''
        Node setup and start
        '''
        rospy.init_node('grand_prix', anonymous=False)
        self.drive = rospy.Publisher('/vesc/ackermann_cmd_mux/input/navigation', AckermannDriveStamped, queue_size=5)
        rospy.Subscriber('scan', LaserScan, self.laserCall)

        '''
        Leave the robot going until roscore dies, then set speed to 0
        '''
        rospy.spin()
        self.drive.publish(AckermannDriveStamped())
项目:racecar_7    作者:karennguyen    | 项目源码 | 文件源码
def __init__(self,bool_direction):
        print "Beginning wall follow"
        #setup the node
        rospy.init_node('wall_follower', anonymous=False)
        rospy.on_shutdown(self.shutdown)
        self.right = bool_direction

        # node specific topics (remap on command line or in launch file)
        self.drive = rospy.Publisher('/vesc/ackermann_cmd_mux/input/navigation', AckermannDriveStamped, queue_size=5)

        #sets the subscriber
        rospy.Subscriber('scan', LaserScan, self.laserCall)
        rospy.Subscriber('blob_info', blob_detect,self.blobCall)
        rospy.spin()
        # always make sure to leave the robot stopped
        self.drive.publish(AckermannDriveStamped())
项目:racecar_7    作者:karennguyen    | 项目源码 | 文件源码
def __init__(self,bool_direction):
        print "Beginning wall follow"
        #setup the node
        rospy.init_node('wall_follower', anonymous=False)
        rospy.on_shutdown(self.shutdown)
        self.right = bool_direction

        # node specific topics (remap on command line or in launch file)
        self.drive = rospy.Publisher('/vesc/ackermann_cmd_mux/input/navigation', AckermannDriveStamped, queue_size=5)

        #sets the subscriber
        rospy.Subscriber('scan', LaserScan, self.laserCall)
        rospy.Subscriber('blob_info', blob_detect,self.blobCall)
        rospy.spin()
        # always make sure to leave the robot stopped
        self.drive.publish(AckermannDriveStamped())
项目:pddl4j_rospy    作者:pellierd    | 项目源码 | 文件源码
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()
项目:autonomous_driving    作者:StatueFungus    | 项目源码 | 文件源码
def __init__(self, node_name, sub_topic, pub_topic):
        self.img_prep = ImagePreparator()
        self.bridge = CvBridge()

        self.camera = None
        self.horizon_y = None
        self.transformation_matrix = None
        self.image_resolution = DEFAULT_RESOLUTION
        self.transformated_image_resolution = DEFAULT_RESOLUTION

        self.image_pub = rospy.Publisher(pub_topic, Image, queue_size=QUEUE_SIZE)

        rospy.init_node(node_name, anonymous=True)

        self.image_sub = rospy.Subscriber(sub_topic, Image, self.callback)

        rospy.spin()
项目:piksi_ros    作者:uscresl    | 项目源码 | 文件源码
def main():
    node = SignalMonitor()
    rospy.spin()
项目:uwb_tracker_ros    作者:eth-ait    | 项目源码 | 文件源码
def exec_(self):
        if self.show_plots:
            import sys
            import pyqtgraph
            if sys.flags.interactive != 1 or not hasattr(QtCore, 'PYQT_VERSION'):
                pyqtgraph.QtGui.QApplication.exec_()
        else:
            rospy.spin()
项目:uwb_tracker_ros    作者:eth-ait    | 项目源码 | 文件源码
def exec_(self):
        rospy.spin()
项目:mav_rtk_gps    作者:ethz-asl    | 项目源码 | 文件源码
def __init__(self):

        if rospy.has_param('~orientation_offset'):
            # Orientation offset as quaterion q = [x,y,z,w].
            self.orientation_offset = rospy.get_param('~orientation_offset')
        else:
            yaw_offset_deg = rospy.get_param('~yaw_offset_deg', 0.0)
            self.orientation_offset = tf.quaternion_from_euler(0.0, 0.0, math.radians(yaw_offset_deg))

        rospy.Subscriber(rospy.get_name() + "/imu_in", Imu, self.imu_callback)

        self.pub_imu_out = rospy.Publisher(rospy.get_name() + '/imu_out',
                                           Imu, queue_size=10)

        rospy.spin()
项目:mav_rtk_gps    作者:ethz-asl    | 项目源码 | 文件源码
def __init__(self):
        # Read Settings
        self.read_settings()

        # Init other variables
        self._num_magnetometer_reads = 0
        self._latest_bearings = np.zeros(shape = (self._number_samples_average, 1))
        self._received_enough_samples = False

        # Subscribe to magnetometer topic
        rospy.Subscriber("magnetic_field", Vector3Stamped, self.magnetic_field_callback)

        # Publishers
        self._pub_bearing_raw = rospy.Publisher(rospy.get_name() + '/bearing_raw_deg',
                                                Float64, queue_size = 10)
        self._pub_bearing_avg = rospy.Publisher(rospy.get_name() + '/bearing_avg_deg',
                                                Float64, queue_size = 10)
        self._pub_imu_bearing_avg = rospy.Publisher(rospy.get_name() + '/imu_bearing_avg',
                                                Imu, queue_size = 10)

        if self._verbose:
            self._pub_mag_corrected = rospy.Publisher(rospy.get_name() + '/mag_corrected',
                                                      Vector3Stamped, queue_size = 10)

        rospy.spin()
项目:ab2016-ros-gazebo    作者:akademikbilisim    | 项目源码 | 文件源码
def main():
    rospy.init_node("listener")

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

    rospy.spin()
项目:camera_calibration_frontend    作者:groundmelon    | 项目源码 | 文件源码
def main():
    from optparse import OptionParser
    rospy.init_node('cameracheck')
    parser = OptionParser()
    parser.add_option("-s", "--size", default="8x6", help="specify chessboard size as nxm [default: %default]")
    parser.add_option("-q", "--square", default=".108", help="specify chessboard square size in meters [default: %default]")
    options, args = parser.parse_args()
    size = tuple([int(c) for c in options.size.split('x')])
    dim = float(options.square)
    CameraCheckerNode(size, dim)
    rospy.spin()
项目:easy_handeye    作者:IFL-CAMP    | 项目源码 | 文件源码
def main():
    rospy.init_node('easy_handeye')
    while rospy.get_time() == 0.0:
        pass

    cw = HandeyeServer()

    rospy.spin()
项目:geom_rcnn    作者:asbroad    | 项目源码 | 文件源码
def main():
    rgb_object_detection = RGBObjectDetection()
    rospy.init_node('rgb_object_detection', anonymous=True)
    try:
      rospy.spin()
    except KeyboardInterrupt:
      print("Shutting down")
项目:geom_rcnn    作者:asbroad    | 项目源码 | 文件源码
def main():
    store_data = StoreData()
    rospy.init_node('store_data', anonymous=True)
    try:
        rospy.spin()
    except KeyboardInterrupt:
      print("Shutting down")
项目:intera_sdk    作者:RethinkRobotics    | 项目源码 | 文件源码
def start_server(limb, rate, mode, valid_limbs):
    rospy.loginfo("Initializing node... ")
    rospy.init_node("sdk_{0}_joint_trajectory_action_server{1}".format(
                        mode, "" if limb == 'all_limbs' else "_" + limb,))

    rospy.loginfo("Initializing joint trajectory action server...")
    robot_name = intera_interface.RobotParams().get_robot_name().lower().capitalize()
    config_module = "intera_interface.cfg"
    if mode == 'velocity':
        config_name = ''.join([robot_name,"VelocityJointTrajectoryActionServerConfig"])
    elif mode == 'position':
        config_name = ''.join([robot_name,"PositionJointTrajectoryActionServerConfig"])
    else:
        config_name = ''.join([robot_name,"PositionFFJointTrajectoryActionServerConfig"])
    cfg = importlib.import_module('.'.join([config_module,config_name]))
    dyn_cfg_srv = Server(cfg, lambda config, level: config)
    jtas = []
    if limb == 'all_limbs':
        for current_limb in valid_limbs:
            jtas.append(JointTrajectoryActionServer(current_limb, dyn_cfg_srv,
                                                    rate, mode))
    else:
        jtas.append(JointTrajectoryActionServer(limb, dyn_cfg_srv, rate, mode))


    def cleanup():
        for j in jtas:
            j.clean_shutdown()

    rospy.on_shutdown(cleanup)
    rospy.loginfo("Joint Trajectory Action Server Running. Ctrl-c to quit")
    rospy.spin()
项目:amosero    作者:PaulPetring    | 项目源码 | 文件源码
def start():
    global left_motor_pub,right_motor_pub
    # publishing to "turtle1/cmd_vel" to control turtle1
    global pub
    pub = rospy.Publisher('turtle1/cmd_vel', Twist)
    left_motor_pub = rospy.Publisher('/left_motor', std_msgs.msg.Int32, queue_size=10)
    right_motor_pub = rospy.Publisher('/right_motor', std_msgs.msg.Int32, queue_size=10)
    # subscribed to joystick inputs on topic "joy"
    rospy.Subscriber("joy", Joy, callback)
    # starts the node
    rospy.init_node('Joy2Turtle')
    rospy.spin()
项目:amosero    作者:PaulPetring    | 项目源码 | 文件源码
def listener():
    global odom_pub,left_motor_pub,left_motor_speed_pub,right_motor_pub,right_motor_speed_pub
    rospy.Subscriber("/cmd_vel", Twist, callback)
    rospy.Subscriber('imu_data',Imu,imuCb)
    rospy.Subscriber('north',std_msgs.msg.Float32,northCb)

    odom_pub = rospy.Publisher('/odom', Odometry, queue_size=10)

    left_motor_pub = rospy.Publisher('/left_motor', std_msgs.msg.Int32, queue_size=10)
    left_motor_speed_pub = rospy.Publisher('/left_motor_speed', std_msgs.msg.Int32, queue_size=10)
    right_motor_pub = rospy.Publisher('/right_motor', std_msgs.msg.Int32, queue_size=10)
    right_motor_speed_pub = rospy.Publisher('/right_motor_speed', std_msgs.msg.Int32, queue_size=10)
    rospy.spin()
项目:amosero    作者:PaulPetring    | 项目源码 | 文件源码
def listener():
    global odom_pub,left_motor_pub,left_motor_speed_pub,right_motor_pub,right_motor_speed_pub
    rospy.Subscriber("/cmd_vel", Twist, callback)
    odom_pub = rospy.Publisher('/odom', Odometry, queue_size=10)
    left_motor_pub = rospy.Publisher('/left_motor', std_msgs.msg.Int32, queue_size=10)
    left_motor_speed_pub = rospy.Publisher('/left_motor_speed', std_msgs.msg.Int32, queue_size=10)
    right_motor_pub = rospy.Publisher('/right_motor', std_msgs.msg.Int32, queue_size=10)
    right_motor_speed_pub = rospy.Publisher('/right_motor_speed', std_msgs.msg.Int32, queue_size=10)
    rospy.spin()
项目:amosero    作者:PaulPetring    | 项目源码 | 文件源码
def start():
    global left_motor_pub,right_motor_pub
    # publishing to "turtle1/cmd_vel" to control turtle1
    global pub
    pub = rospy.Publisher('turtle1/cmd_vel', Twist)
    left_motor_pub = rospy.Publisher('/left_motor', std_msgs.msg.Int32, queue_size=10)
    right_motor_pub = rospy.Publisher('/right_motor', std_msgs.msg.Int32, queue_size=10)
    # subscribed to joystick inputs on topic "joy"
    rospy.Subscriber("joy", Joy, callback)
    # starts the node
    rospy.init_node('Joy2Turtle')
    rospy.spin()
项目:amosero    作者:PaulPetring    | 项目源码 | 文件源码
def start():
    global left_motor_pub,right_motor_pub
    # publishing to "turtle1/cmd_vel" to control turtle1
    global pub
    pub = rospy.Publisher('turtle1/cmd_vel', Twist)
    left_motor_pub = rospy.Publisher('/left_motor', std_msgs.msg.Int32, queue_size=10)
    right_motor_pub = rospy.Publisher('/right_motor', std_msgs.msg.Int32, queue_size=10)
    # subscribed to joystick inputs on topic "joy"
    rospy.Subscriber("joy", Joy, callback)
    # starts the node
    rospy.init_node('Joy2Turtle')
    rospy.spin()
项目:amosero    作者:PaulPetring    | 项目源码 | 文件源码
def start():
    global left_motor_pub,right_motor_pub
    # publishing to "turtle1/cmd_vel" to control turtle1
    global pub
    pub = rospy.Publisher('turtle1/cmd_vel', Twist)
    left_motor_pub = rospy.Publisher('/left_motor', std_msgs.msg.Int32, queue_size=10)
    right_motor_pub = rospy.Publisher('/right_motor', std_msgs.msg.Int32, queue_size=10)
    # subscribed to joystick inputs on topic "joy"
    rospy.Subscriber("joy", Joy, callback)
    # starts the node
    rospy.init_node('Joy2Turtle')
    rospy.spin()
项目:micros_mars_task_alloc    作者:liminglong    | 项目源码 | 文件源码
def avoid_runaway_suppressor():
    rospy.init_node('avoid_runaway_suppressor')
    rospy.Subscriber("/avoid/suppressor/heading", Heading, avoid_headingCB) 
    rospy.Subscriber("/runaway/suppressor/heading", Heading, runaway_headingCB)
    rospy.spin()
项目:micros_mars_task_alloc    作者:liminglong    | 项目源码 | 文件源码
def spin(self):
        rospy.spin()
项目:micros_mars_task_alloc    作者:liminglong    | 项目源码 | 文件源码
def avoid_runaway_suppressor():
        rospy.spin()
项目:micros_mars_task_alloc    作者:liminglong    | 项目源码 | 文件源码
def start_detect(self):
        FunctionUnit.init_node(self)
        #print 'hello 1'
        #print self._receive_topic
        receive_1 = FunctionUnit.create_receive(self, self._receive_topic, Image, self.receive_1_cb)
        #print 'hello 2'
        FunctionUnit.spin(self)
项目:micros_mars_task_alloc    作者:liminglong    | 项目源码 | 文件源码
def run(self):
        rospy.init_node('hello2')
        print 'hello2'
        rospy.spin()
项目:mhri    作者:mhri    | 项目源码 | 文件源码
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()
项目:mhri    作者:mhri    | 项目源码 | 文件源码
def __init__(self):
        rospy.init_node('fake_renderer', anonymous=True)

        try:
            topic_name = rospy.get_param('~action_name')
        except KeyError as e:
            print('[ERROR] Needed parameter for (topic_name)...')
            quit()

        if 'render_gesture' in rospy.get_name():
            self.GetInstalledGesturesService = rospy.Service(
                "get_installed_gestures",
                GetInstalledGestures,
                self.handle_get_installed_gestures
            )

            self.motion_list = {
                'neutral': ['neutral_motion1'],
                'encourge': ['encourge_motion1'],
                'attention': ['attention_motion1'],
                'consolation': ['consolation_motion1'],
                'greeting': ['greeting_motion1'],
                'waiting': ['waiting_motion1'],
                'advice': ['advice_motion1'],
                'praise': ['praise_motion1'],
                'command': ['command_motion1'],
            }

        self.server = actionlib.SimpleActionServer(
            topic_name, RenderItemAction, self.execute_callback, False)
        self.server.start()

        rospy.loginfo('[%s] initialized...' % rospy.get_name())
        rospy.spin()
项目:uwb_tracker_ros    作者:bennihepp    | 项目源码 | 文件源码
def exec_(self):
        if self.show_plots:
            import sys
            import pyqtgraph
            if sys.flags.interactive != 1 or not hasattr(QtCore, 'PYQT_VERSION'):
                pyqtgraph.QtGui.QApplication.exec_()
        else:
            rospy.spin()
项目:uwb_tracker_ros    作者:bennihepp    | 项目源码 | 文件源码
def exec_(self):
        rospy.spin()
项目:TrajectoryPlanner    作者:LetsPlayNow    | 项目源码 | 文件源码
def main():
    rospy.init_node("trajectory_planner")
    planner = TrajectoryPlanner()
    rospy.spin()
项目:TurtleBot_IMU_Integration    作者:therrma2    | 项目源码 | 文件源码
def main():
    trans= 0
    rot = 0
    rospy.init_node('odom_sync')
    listener = tf.TransformListener()
    pubfiltered = rospy.Publisher('set_pose',PoseWithCovarianceStamped,queue_size = 10)
    pubodom = rospy.Publisher('mobile_base/commands/reset_odometry', Empty, queue_size = 10)
    serv = rospy.ServiceProxy("set_offset",SetOdomOffset)
    rospy.Subscriber('/command_input',UInt8,callback,callback_args=(pubodom,pubfiltered,listener,trans,rot,serv))
    rospy.sleep(1)
    print "done sleeping"

    while not rospy.is_shutdown():
        try:
            (trans,rot) = listener.lookupTransform('/base_meas', '/odom_meas',rospy.Time(0))

        except: continue


    rospy.spin()
项目:cloudrobot-semantic-map    作者:liyiying    | 项目源码 | 文件源码
def listener():

    # In ROS, nodes are uniquely named. If two nodes with the same
    # node are launched, the previous one is kicked off. The
    # anonymous=True flag means that rospy will choose a unique
    # name for our 'listener' node so that multiple listeners can
    # run simultaneously.
    rospy.init_node('listener', anonymous=True)

    rospy.Subscriber("/turtlebot_angle", Float64, callback1)
    rospy.Subscriber("/turtlebot_posex", Float64, callback2)
    rospy.Subscriber("/turtlebot_posey", Float64, callback3)

    rospy.Subscriber("/turtlebot_follower/dist_object1", Float64, callback4)
    rospy.Subscriber("/turtlebot_follower/dist_object2", Float64, callback5)
    rospy.Subscriber("/turtlebot_follower/dist_object3", Float64, callback6)
    rospy.Subscriber("/turtlebot_follower/dist_object4", Float64, callback7)
    #rospy.Subscriber("/turtlebot_follower/dist_object", Float64, callback8)

    # spin() simply keeps python from exiting until this node is stopped
    rospy.spin()
项目:micros_mars_task_alloc    作者:liminglong    | 项目源码 | 文件源码
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()