示例#1
0
def main():

    import config
    import time
    import logging
    from drive import Drive

    logging.basicConfig(level=logging.DEBUG)
    log = logging.getLogger(__name__)

    log.info("Testing vision subsystem")

    vision = Vision(config)
    drive = Drive()
    drive.close_tray()

    calibration_markers = None
    while True:

        drive.close_tray()

        log.info("Acquiring calibration image")
        image_filename = vision.image_acquire()
        if not image_filename:
            log.warn(
                "Could not acquire image for calibration, please check the camera"
            )
            time.sleep(config.camera_calibration_delay)
            continue

        (calibration_markers, frame) = vision.detect_markers(image_filename)
        os.unlink(image_filename)

        log.debug("Markers detected during calibration: '{}'".format(
            calibration_markers))

        if calibration_markers and 'disk_center' in calibration_markers and 'disk_edge' in calibration_markers:
            break
        else:
            log.warn(
                "Both calibration markers need to be detectable, please adjust the camera or lighting conditions"
            )
            time.sleep(config.camera_calibration_delay)

    log.info(
        "Camera calibration was successful, calibration markers detected: {}".
        format(calibration_markers))

    drive.open_tray()

    camera_image_filename = vision.image_acquire('camera-image')
    vision.write_cover_image(camera_image_filename, 'cover.png',
                             calibration_markers)

    drive.close_tray()
示例#2
0
arm.move_abs(config.src_tray_pos)
arm.wait_for_move_end()

drive.open_tray()

arm.move_abs(config.drive_tray_pos)
arm.wait_for_move_end()

arm.pump(False)
time.sleep(config.t_release)

arm.origin()

for i in range(config.close_tray_max_attempts):
    if drive.close_tray():
        break

    log.warn("Could not close drive tray, retry '{}' of '{}'".format(i, config.close_tray_max_attempts))
    display.msg("ERR DRIVE CLOSE")
    drive.open_tray()

# Move the arm away so that the camera can make a photo of the disc
arm.move_abs(config.src_tray_pos)

log.info("Archiving disc in drive tray")
display.msg("IMAGING ...")

dest_tray = config.done_tray_pos

if not drive.read_disc(capture_id):
示例#3
0
#
# This self-check is needed because the JM20337 SATA<->USB bridge takes a while to realize
# that power is on, the drive is connected and it's time to get to work and announce itself on
# the USB bus.
#
while True:

    # Try to open the drive tray
    if not drive.open_tray():
        log.warn("Could not open drive tray, please check drive")
        display.msg("CANNOT OPEN, RETRY IN {} SECONDS".format(config.selfcheck_drive_action_timeout))
        time.sleep(config.selfcheck_drive_action_timeout)
        continue

    # Try to close the drive tray
    if not drive.close_tray():
        log.warn("Could not close drive tray, please check drive")
        display.msg("CANNOT CLOSE, RETRY IN {} SECONDS".format(config.selfcheck_drive_action_timeout))
        time.sleep(config.selfcheck_drive_action_timeout)
        continue

    log.info("Drive self-check passed")
    display.msg("DRIVE OK")
    break

# Calibrate camera
log.info("Starting camera calibration")
display.msg("CALIBRATE VISION")

calibration_markers = None
while True: