Ejemplo n.º 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()
Ejemplo n.º 2
0
# Pickup disk
cd_pickedup = arm.pickup_object(config.src_tray_pos, config.src_tray_z_min)
if not cd_pickedup:
    log.fatal("Could not pick up disk, bailing out")
    display.msg("ERR PICKUP DISK")
    sys.exit(1)

arm.pump(True)
time.sleep(config.t_grab)

display.msg("MOVE TO DRIVE")

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")
Ejemplo n.º 3
0
drive = Drive("/dev/cdrom", storage_path)

# Self-test
log.info("Starting drive self-check")
display.msg("DRIVE SELF-CHECK")

#
# 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