def doInstruct(robot, dispenser, mailfrom, instruction, values, arena, arenaRad, FlyPlate, HomeZwd, HomeZdp, turnZ, vacZ, disponlyifsure=0, maxconsecstuck=6, robotEMailAccount='*****@*****.**', PWrobotEMailAccount='examplePW'):
    camcoordZ = 40
    if instruction == 'SWP':
        CamX = []
        CamY = []
        for i in range(values[0], values[1]):
            tempX = arena.getCamCoords(i)[0]
            tempY = arena.getCamCoords(i)[1]
            np.append(CamX, tempX)
            np.append(CamY, tempY)
        flyremainvect = commonFlyTasks.sweep(CamX[values[0]:values[1]], CamY[values[0]:values[1]], camz=camcoordZ)
        unsurevect = commonFlyTasks.sweep(CamX[flyremainvect], CamY[flyremainvect], camz=camcoordZ)
        try:
            flyremainvect = flyremainvect[unsurevect]
            commonFlyTasks.SavePicAt(Xcoords=CamX[flyremainvect], Ycoords=CamY[flyremainvect], IndVect=flyremainvect)
            notifyUserFail(flyremainvect, mailfrom=mailfrom, attImg=1)
        except:
            print 'No failed arenas detected'
    elif instruction == 'SWPFL':
        commonFlyTasks.SavePicAt(Xcoords=CamX[values[0]:values[1]], Ycoords=CamY[values[0]:values[1]], IndVect=range(values[0], values[1]))
        notifyUserFail(range(values[0], values[1]), mailfrom=mailfrom, attImg=1)
    elif instruction == 'H2A':
        try:        # If not specified, add repetitions as 1
            values[4]
        except:
            values.append(1)
        for repeat in range(0, values[4]):
            for depositValue in range(values[0], values[1]):
                commonFlyTasks.homeWithdraw(robot, FlyPlate, depositValue, refptX='N', refptY='N', carefulZ=7, dislodgeZ=25, vacBurst=1, homeZ=45)
                checkmiss = commonFlyTasks.arenaDeposit(robot, arena, depositValue, arenaRad=arena.Radii, turnZ=arena.POIz, airPos=values[2], airZ=arena.Vacz, closePos=values[3])
                if (values[1] - depositValue)%4 == 0:
                    print 'Resetting Z position to maintain accuracy.'
                    robot.homeZ2()
                if checkmiss['missonce'] != 0:
                    print 'Missed opening at least once - realigning...'
                    robot.homeZ2()
    elif instruction == 'A2H':
        try:        # If not specified, add repetitions as 1
            values[5]
        except:
            values.append(1)
        for repeat in range(0, values[5]):
            for depositValue in range(values[0], values[1]):
                checkmiss = commonFlyTasks.arenaWithdraw(robot, arena, depositValue, arenaRad=arena.Radii, turnZ=arena.POIz, vacPos=values[2], vacZ=arena.Vacz, closePos=values[3], vacstrategy=values[4], vacBurst=1, imgshow=0)
                commonFlyTasks.homeDeposit(robot, FlyPlate, depositValue, refptX='N', refptY='N', carefulZ=9, vacBurst=1, homeZ=44)
                if (values[1] - depositValue)%4 == 0:
                    print 'Resetting Z position to maintain accuracy.'
                    robot.homeZ2()
                if checkmiss['missonce'] != 0:
                    print 'Missed opening at least once - realigning...'
                    robot.homeZ2()
    elif instruction == 'HELP':
        gmail_user = robotEMailAccount
        gmail_password = PWrobotEMailAccount
        try:
           server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
        except:
            print 'SMTP went wrong...'
        try:
            server.ehlo()
        except:
            print 'Handshake went wrong...'
        try:
            server.login(gmail_user, gmail_password)
        except:
            print 'Login went wrong...'
        msg = MIMEText('Format: Use KEYWORD in subject line. Enter arenas and settings as "#,#,#,..." without spaces.\n \nKEYWORDS: \nSWP: Sweeps from arenas [1] through [2] and sends back pictures of arenas in which motion was detected.\nSWPFL: Sends back pictures of arenas [1] through [2].\nA2H: Moves flies in arenas [1] through [2] to their homeplates. Vacuums at radian [3] and closes the lid at radian [4] using strategy [5].\nH2A: Same as A2H but from homeplates to arenas.\nCLCT: Starts virgin collection process for [1] seconds total every [2] seconds.\n \nExample:\nSubject: A2H\nText: 0,18,50,180,2.')
        msg['Subject'] = 'RE: MAPLE Remote Access Help'
        msg['From'] = robotEMailAccount
        msg['To'] = mailfrom
        server.sendmail(robotEMailAccount, mailfrom, msg.as_string())
        server.quit()
    elif instruction == 'CLCT':
        commonFlyTasks.collectHatchedForT(robot, FlyPlate, dispenser, onlyifsure=1, carefulZ=9, vacBurst=1, homeZ=44, dispiter=1, carryovernDispensed=0, collectT=values[0], collectInt=values[1], maxconsecstuck=4)
示例#2
0
    arenaRad=ExampleSocialWorkspace.SocialWorkspace['socialArena'].Radii,
    turnZ=ExampleSocialWorkspace.SocialWorkspace['socialArena'].POIz,
    vacPos=50,
    vacZ=ExampleSocialWorkspace.SocialWorkspace['socialArena'].Vacz,
    closePos=0,
    vacstrategy=2,
    vacBurst=1,
    imgshow=0)
cft.homeDeposit(robot,
                ExampleSocialWorkspace.SocialWorkspace['plate1'],
                1,
                refptX='N',
                refptY='N',
                carefulZ=9,
                vacBurst=1,
                homeZ=44)
cft.collectHatchedForT(robot,
                       ExampleSocialWorkspace.SocialWorkspace['plate1'],
                       ExampleSocialWorkspace.SocialWorkspace['dispenser1'],
                       onlyifsure=1,
                       carefulZ=9,
                       vacBurst=1,
                       homeZ=44,
                       dispiter=1,
                       carryovernDispensed=0,
                       collectT=20,
                       collectInt=10,
                       maxconsecstuck=4)
#mail = remote.listenMode(statusURL="", duration=60, listenInterval=2, robotEMailAccount='*****@*****.**', PWrobotEMailAccount='H@rvard2017!')
#remote.doInstruct(robot=robot, instruction=mail['instruct'], mailfrom=mail['from'], values=mail['values'], arena=ExampleSocialWorkspace.SocialWorkspace['socialArena'], FlyPlate=ExampleSocialWorkspace.SocialWorkspace['plate1'], turnZ=ExampleSocialWorkspace.SocialWorkspace['socialArena'].POIz, vacZ=ExampleSocialWorkspace.SocialWorkspace['socialArena'].Vacz, arenaRad=ExampleSocialWorkspace.SocialWorkspace['socialArena'].Radii, dispenser=ExampleSocialWorkspace.SocialWorkspace['dispenser1'], HomeZwd=44, HomeZdp=44)
## Dependencies
import cv2
import numpy as np
import time
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
import robotutil
import math
import random as rand
import matplotlib.pyplot as plt
import ConfigParser
import commonFlyTasks as cft

# Import relevant workspace
import ExampleSocialWorkspace

# Virgin collection variables
tCollect = 86400		# Total virgin collection time in seconds.
intCollect = 1800		# Virgin collection interval in seconds.

#### Initialize MAPLE ####
robot = robotutil.MAPLE("MAPLE.cfg")
robot.smoothie.sendCmd("M999")
robot.flyManipAir(False)
robot.smallPartManipVac(False)
robot.home()

## Starts main virgin collection routine
cft.collectHatchedForT(robot, ExampleSocialWorkspace.SocialWorkspace['plate1'], ExampleSocialWorkspace.SocialWorkspace['dispenser1'], onlyifsure=1, carefulZ=9, vacBurst=1, homeZ=44, dispiter=1, carryovernDispensed=0, collectT=tCollect, collectInt=intCollect, maxconsecstuck=4)
示例#4
0
def doInstruct(robot, dispenser, mailfrom, instruction, values, arena, arenaRad, FlyPlate, HomeZwd, HomeZdp, turnZ, vacZ, disponlyifsure=0, maxconsecstuck=6, robotEMailAccount='*****@*****.**', PWrobotEMailAccount='examplePW'):
    camcoordZ = 40
    if instruction == 'SWP':
        CamX = []
        CamY = []
        for i in range(values[0], values[1]):
            tempX = arena.getCamCoords(i)[0]
            tempY = arena.getCamCoords(i)[1]
            np.append(CamX, tempX)
            np.append(CamY, tempY)
        flyremainvect = commonFlyTasks.sweep(CamX[values[0]:values[1]], CamY[values[0]:values[1]], camz=camcoordZ)
        unsurevect = commonFlyTasks.sweep(CamX[flyremainvect], CamY[flyremainvect], camz=camcoordZ)
        try:
            flyremainvect = flyremainvect[unsurevect]
            commonFlyTasks.SavePicAt(Xcoords=CamX[flyremainvect], Ycoords=CamY[flyremainvect], IndVect=flyremainvect)
            notifyUserFail(flyremainvect, mailfrom=mailfrom, attImg=1)
        except:
            print 'No failed arenas detected'
    elif instruction == 'SWPFL':
        commonFlyTasks.SavePicAt(Xcoords=CamX[values[0]:values[1]], Ycoords=CamY[values[0]:values[1]], IndVect=range(values[0], values[1]))
        notifyUserFail(range(values[0], values[1]), mailfrom=mailfrom, attImg=1)
    elif instruction == 'H2A':
        try:        # If not specified, add repetitions as 1
            values[4]
        except:
            values.append(1)
        for repeat in range(0, values[4]):
            for depositValue in range(values[0], values[1]):
                commonFlyTasks.homeWithdraw(robot, FlyPlate, depositValue, refptX='N', refptY='N', carefulZ=7, dislodgeZ=25, vacBurst=1, homeZ=45)
                checkmiss = commonFlyTasks.arenaDeposit(robot, arena, depositValue, arenaRad=arena.Radii, turnZ=arena.POIz, airPos=values[2], airZ=arena.Vacz, closePos=values[3])
                if (values[1] - depositValue)%4 == 0:
                    print 'Resetting Z position to maintain accuracy.'
                    robot.homeZ2()
                if checkmiss['missonce'] != 0:
                    print 'Missed opening at least once - realigning...'
                    robot.homeZ2()
    elif instruction == 'A2H':
        try:        # If not specified, add repetitions as 1
            values[5]
        except:
            values.append(1)
        for repeat in range(0, values[5]):
            for depositValue in range(values[0], values[1]):
                checkmiss = commonFlyTasks.arenaWithdraw(robot, arena, depositValue, arenaRad=arena.Radii, turnZ=arena.POIz, vacPos=values[2], vacZ=arena.Vacz, closePos=values[3], vacstrategy=values[4], vacBurst=1, imgshow=0)
                commonFlyTasks.homeDeposit(robot, FlyPlate, depositValue, refptX='N', refptY='N', carefulZ=9, vacBurst=1, homeZ=44)
                if (values[1] - depositValue)%4 == 0:
                    print 'Resetting Z position to maintain accuracy.'
                    robot.homeZ2()
                if checkmiss['missonce'] != 0:
                    print 'Missed opening at least once - realigning...'
                    robot.homeZ2()
    elif instruction == 'HELP':
        gmail_user = robotEMailAccount
        gmail_password = PWrobotEMailAccount
        try:
           server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
        except:
            print 'SMTP went wrong...'
        try:
            server.ehlo()
        except:
            print 'Handshake went wrong...'
        try:
            server.login(gmail_user, gmail_password)
        except:
            print 'Login went wrong...'
        msg = MIMEText('Format: Use KEYWORD in subject line. Enter arenas and settings as "#,#,#,..." without spaces.\n \nKEYWORDS: \nSWP: Sweeps from arenas [1] through [2] and sends back pictures of arenas in which motion was detected.\nSWPFL: Sends back pictures of arenas [1] through [2].\nA2H: Moves flies in arenas [1] through [2] to their homeplates. Vacuums at radian [3] and closes the lid at radian [4] using strategy [5].\nH2A: Same as A2H but from homeplates to arenas.\nCLCT: Starts virgin collection process for [1] seconds total every [2] seconds.\n \nExample:\nSubject: A2H\nText: 0,18,50,180,2.')
        msg['Subject'] = 'RE: MAPLE Remote Access Help'
        msg['From'] = robotEMailAccount
        msg['To'] = mailfrom
        server.sendmail(robotEMailAccount, mailfrom, msg.as_string())
        server.quit()
    elif instruction == 'CLCT':
        commonFlyTasks.collectHatchedForT(robot, FlyPlate, dispenser, onlyifsure=1, carefulZ=9, vacBurst=1, homeZ=44, dispiter=1, carryovernDispensed=0, collectT=values[0], collectInt=values[1], maxconsecstuck=4)