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