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


Python rospy.spin方法代碼示例

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


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

示例1: start

# 需要導入模塊: import rospy [as 別名]
# 或者: from rospy import spin [as 別名]
def start(self, node_name='polly_node', service_name='polly'):
        """The entry point of a ROS service node.

        Details of the service API can be found in Polly.srv.

        :param node_name: name of ROS node
        :param service_name:  name of ROS service
        :return: it doesn't return
        """
        rospy.init_node(node_name)

        service = rospy.Service(service_name, Polly, self._node_request_handler)

        rospy.loginfo('polly running: {}'.format(service.uri))

        rospy.spin() 
開發者ID:aws-robotics,項目名稱:tts-ros1,代碼行數:18,代碼來源:amazonpolly.py

示例2: scaleWheel

# 需要導入模塊: import rospy [as 別名]
# 或者: from rospy import spin [as 別名]
def scaleWheel():
    rospy.init_node("wheel_scaler")
    rospy.loginfo("wheel_scaler started")
    
    scale = rospy.get_param('distance_scale', 1)
    rospy.loginfo("wheel_scaler scale: %0.2f", scale)
    
    rospy.Subscriber("lwheel", Int16, lwheelCallback)
    rospy.Subscriber("rwheel", Int16, rwheelCallback)
    
    lscaled_pub = rospy.Publisher("lwheel_scaled", Int16, queue_size=10)
    rscaled_pub = rospy.Publisher("rwheel_scaled", Int16, queue_size=10) 
    
    ### testing sleep CPU usage
    r = rospy.Rate(50) 
    while not rospy.is_shutdown:
        r.sleep()
        
    rospy.spin() 
開發者ID:jfstepha,項目名稱:differential-drive,代碼行數:21,代碼來源:wheel_scaler.py

示例3: __init__

# 需要導入模塊: import rospy [as 別名]
# 或者: from rospy import spin [as 別名]
def __init__(self, args):
        self.index = 0
        if len(sys.argv) > 1:
            self.index = int(sys.argv[1])
        rospy.init_node('save_img')
        self.bridge = CvBridge()

        while not rospy.is_shutdown():
            raw_input()

            data = rospy.wait_for_message('/camera1/usb_cam/image_raw', Image)

            try:
                cv_image = self.bridge.imgmsg_to_cv2(data, "passthrough")
            except CvBridgeError as e:
                print(e)

            print "Saved to: ", base_path+str(self.index)+".jpg"
            cv2.cvtColor(cv_image, cv2.COLOR_BGR2RGB, cv_image)
            cv2.imwrite(join(base_path, "frame{:06d}.jpg".format(self.index)), cv_image)#*255)
            self.index += 1
        rospy.spin() 
開發者ID:SudeepDasari,項目名稱:visual_foresight,代碼行數:24,代碼來源:save_images_from_topic.py

示例4: main_sawyer

# 需要導入模塊: import rospy [as 別名]
# 或者: from rospy import spin [as 別名]
def main_sawyer():
    import intera_interface
    from visual_mpc.envs.robot_envs.sawyer.sawyer_impedance import SawyerImpedanceController
    
    controller = SawyerImpedanceController('sawyer', True, gripper_attached='none')       # doesn't initial gripper object even if gripper is attached

    def print_eep(value):
        if not value:
            return
        xyz, quat = controller.get_xyz_quat()
        yaw, roll, pitch = [np.rad2deg(x) for x in controller.quat_2_euler(quat)]
        logging.getLogger('robot_logger').info("XYZ IS: {}, ROTATION IS: yaw={} roll={} pitch={}".format(xyz, yaw, roll, pitch))
    
    navigator = intera_interface.Navigator()
    navigator.register_callback(print_eep, 'right_button_show')
    rospy.spin() 
開發者ID:SudeepDasari,項目名稱:visual_foresight,代碼行數:18,代碼來源:get_points.py

示例5: listener

# 需要導入模塊: import rospy [as 別名]
# 或者: from rospy import spin [as 別名]
def listener():

	global obj
	global pub

	rospy.loginfo("Starting prediction node")

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

	rospy.Subscriber("sensor_read", Int32, read_sensor_data)

	pub = rospy.Publisher('predict', Int32, queue_size=1)


	obj = Classify_Data()

	obj.read_file('pos_readings.csv')

	obj.train()

	rospy.spin() 
開發者ID:PacktPublishing,項目名稱:ROS-Programming-Building-Powerful-Robots,代碼行數:23,代碼來源:ros_svm.py

示例6: run

# 需要導入模塊: import rospy [as 別名]
# 或者: from rospy import spin [as 別名]
def run(args=None):    
    parser = OptionParser(description='Crazyflie ROS Driver')
#     parser.add_option('--uri', '-u',
#                         dest='uri',
#                         default='radio://0/4',
#                         help='URI to connect to')    
    (options, leftargs) = parser.parse_args(args=args)
        
    #Load some DB depending on options 
    rospy.init_node('CrazyFlieJoystickDriver')   
    joydriver = JoyController(options)

    #START NODE
    try:
        rospy.loginfo("Starting CrazyFlie joystick driver")
        rospy.spin()
    except KeyboardInterrupt:    
        rospy.loginfo('...exiting due to keyboard interrupt') 
開發者ID:omwdunkley,項目名稱:crazyflieROS,代碼行數:20,代碼來源:joy_driver_pid.py

示例7: __init__

# 需要導入模塊: import rospy [as 別名]
# 或者: from rospy import spin [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

示例8: __init__

# 需要導入模塊: import rospy [as 別名]
# 或者: from rospy import spin [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

示例9: __init__

# 需要導入模塊: import rospy [as 別名]
# 或者: from rospy import spin [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

示例10: __init__

# 需要導入模塊: import rospy [as 別名]
# 或者: from rospy import spin [as 別名]
def __init__(self):
        rospy.init_node('gripper_controller')
        self.msg = None
       
       
        self.r_pub = rospy.Publisher('gripper_controller/command',
                Float64,
                queue_size=10)
        """
        self.t_pub = rospy.Publisher('arm_controller/command',
                JointTrajectory,
                queue_size=10)
        self.js_sub = rospy.Subscriber('joint_states', JointState,
                self._jointStateCb)
        """

        # subscribe to command and then spin
        self.server = actionlib.SimpleActionServer('~gripper_action', GripperCommandAction, execute_cb=self.actionCb, auto_start=False)
        self.server.start()
        rospy.spin() 
開發者ID:jhu-lcsr,項目名稱:costar_plan,代碼行數:22,代碼來源:robotiq_gripper_action_server.py

示例11: listener

# 需要導入模塊: import rospy [as 別名]
# 或者: from rospy import spin [as 別名]
def listener():
    rospy.init_node('serial_adapter', anonymous=True)
    # Declare the Subscriber to motors orders
    rospy.Subscriber("arduino/servo", Int16, servoCallback, queue_size=2)
    rospy.Subscriber("arduino/motor", Int8, motorCallback, queue_size=2)
    rospy.spin() 
開發者ID:sergionr2,項目名稱:RacingRobot,代碼行數:8,代碼來源:serial_adapter.py

示例12: run

# 需要導入模塊: import rospy [as 別名]
# 或者: from rospy import spin [as 別名]
def run(self):
        rospy.Rate(1)
        rospy.spin() 
開發者ID:kirumang,項目名稱:Pix2Pose,代碼行數:5,代碼來源:ros_pix2pose.py

示例13: run

# 需要導入模塊: import rospy [as 別名]
# 或者: from rospy import spin [as 別名]
def run():
        """
        This function just keeps the node alive.

        """
        rospy.spin() 
開發者ID:OTL,項目名稱:cozmo_driver,代碼行數:8,代碼來源:head_lift_joy.py

示例14: navigation

# 需要導入模塊: import rospy [as 別名]
# 或者: from rospy import spin [as 別名]
def navigation():
    rospy.Publisher('usv_position_setpoint', Odometry) # only create a rostopic, navigation system TODO
    rospy.spin()

   # while not rospy.is_shutdown():
   #     rospy.loginfo(hello_str)
   #     pub.publish(hello_str)
   #     rate.sleep() 
開發者ID:disaster-robotics-proalertas,項目名稱:usv_sim_lsa,代碼行數:10,代碼來源:navigation_block.py

示例15: start

# 需要導入模塊: import rospy [as 別名]
# 或者: from rospy import spin [as 別名]
def start(self, node_name='synthesizer_node', service_name='synthesizer'):
        """The entry point of a ROS service node.

        :param node_name: name of ROS node
        :param service_name:  name of ROS service
        :return: it doesn't return
        """
        rospy.init_node(node_name)

        service = rospy.Service(service_name, Synthesizer, self._node_request_handler)

        rospy.loginfo('{} running: {}'.format(node_name, service.uri))

        rospy.spin() 
開發者ID:aws-robotics,項目名稱:tts-ros1,代碼行數:16,代碼來源:synthesizer.py


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