def calibrate(port): print "Press A button with light on" while not a_button_clicked(): if digital(13): DEBUG() lightOn = analog(port) print "On value =", lightOn if lightOn > 200: print "Bad calibration" return False print "Press B button with light off" while not b_button_clicked(): if digital(13): DEBUG() lightOff = analog(port) print "Off value =", lightOff if lightOff < 3000: print "Bad calibration" return False if (lightOff - lightOn) < 2000: print "Bad calibration" return False c.startLightThresh = (lightOff - lightOn) / 2 print "Good calibration! ", c.startLightThresh return True
def wait_for_button(): display("Press Button...") while not digital(c.RIGHT_BUTTON): pass msleep(1) display("Pressed") msleep(1000)
def waitForButton(): print("Press Right Button...") while not digital(c.RIGHT_BUTTON): pass msleep(1) print("Pressed") msleep(1000)
def waitForButton(): print "Press Button..." while not digital(c.RIGHT_BUTTON): pass msleep(1) print "Pressed" msleep(1000)
def calibrate6(): global lAdjust lAdjust = 1 while True: drive_speed(3, 50) if analog(0) > 1500: lAdjust = lAdjust + 0.05 while not digital(13): pass msleep(500) elif analog(0) < 1000: lAdjust = lAdjust - 0.05 while not digital(13): pass msleep(500) print lAdjust
def calibrate5(): _clear_ticks() while not digital(13): try: print str(_left_ticks()) + " " + str(_right_ticks()) + " " + str( _right_ticks() / _left_ticks()) except Exception: pass msleep(100) x = _right_ticks() / _left_ticks() global lAdjust lAdjust = x print(x)
from wallaby import digital # Misc ALLOW_BUTTON_WAIT = False START_TIME = 0 CLONE_SWITCH = 9 IS_CLONE = digital(CLONE_SWITCH) IS_PRIME = not IS_CLONE STARTLIGHT = 2 FRONT_BUMPED = 0 # Tophats LEFT_TOPHAT = 0 RIGHT_TOPHAT = 5 THRESHOLD = 1500 # Servos SERVO_CLAW = 3 SERVO_ARM = 1 SERVO_HAY_SPIN = 2 SERVO_HAY_ARM = 0 #2 1569 #3 170 #1 Same for now # Motors Y_ARM = 0 HAY_MOTOR = 1 # Servo Values
from wallaby import digital FRONT_BUMPED = 0 ALLOW_BUTTON_WAIT = True START_TIME = 0 ROBOT_ID_CLONE = 0 IS_CLONE = digital(ROBOT_ID_CLONE) IS_PRIME = not IS_CLONE STARTLIGHT = 0 #Servo Ports sky_claw = 1 electric_arm_base = 2 sky_arm = 3 #Sensor ports left_tophat = 5 right_tophat = 4 pipe_switch = 9 #motor electric_line_motor = 3 if IS_PRIME: # Servo Positions arm_offset = -180 arm_vertical = 1430 + arm_offset arm_low_sky = 815 + arm_offset arm_low_grab = 850 + arm_offset mayor_arm = 1150 + arm_offset
startTime = -1 # Motor ports LMOTOR = 0 RMOTOR = 3 # Digital ports CLONE_SWITCH = 9 RIGHT_BUTTON = 13 # Analog ports TOPHAT = 0 ET = 5 STARTLIGHT = 4 isClone = w.digital(CLONE_SWITCH) # Servos servoArm = 0 servoClaw = 1 armUp = 1500 armMid = 500 armFurrow = 200 armDownMid = 100 armDown = 25 clawOpen = 0 clawClosed = 1980 #1550 if isClone:
# Time startTime = -1 # Motor ports LMOTOR = 2 RMOTOR = 0 # Digital ports ROBOT_ID_YELLOW = 0 ROBOT_ID_BLUE = 1 RIGHT_BUTTON = 13 # Analog ports IS_YELLOW_BOT = w.digital(ROBOT_ID_YELLOW) IS_BLUE_BOT = w.digital(ROBOT_ID_BLUE) IS_ORANGE_BOT = not IS_YELLOW_BOT and not IS_BLUE_BOT # Drive Constants WHEEL_DISTANCE = 5.50 #205 - 4.25 # Distance between the two wheels if IS_ORANGE_BOT: INCHES_TO_TICKS = 222 #192 #larger numbers = longer drive lAdjust = 1.02 #.86 #.875 # 1.12 # .99 # adjust left wheel counter to fix drift; Larger number makes the robot drive left...? else: # Blue Bot INCHES_TO_TICKS = 204 lAdjust = 1.125 # adjust left wheel counter to fix drift #1.083 # Servos
outriggerTurn = 450 outriggerOut = 1650 outriggerFront = 1900 outriggerSpin = 416 outriggerFindLine = 1200 outriggerBaseReturn = 340 outriggerBin = 1080 outriggerApproach = 1500 # PRIME analog sensors values topHatMidValue = 2000 # value between black and white top hat values armLength = 1000 # robot 1 claw length from bin ceilingHeight = 700 # value of ET beneath crater rim isClone = w.digital(CLONE_SWITCH) isPrime = not isClone if isPrime: print("running PRIME") else: print("running CLONE!") armFront = 80 armMid = 500 # Arm to score at bin armUp = 1000 # Arm at 90 degrees up armBack = 1500# Arm backwards armBump = 400 clawOpen = 850 #Claw open (525) clawMid = 900 clawWiggle = 1400
import wallaby as w # Time start_time = -1 # motor values LEFT_MOTOR = 0 RIGHT_MOTOR = 3 # Digital ports CLONE_SWITCH = 9 RIGHT_BUTTON = 13 BUTTON = 0 is_clone = w.digital(CLONE_SWITCH) is_prime = not is_clone #Analog ports FRONT_TOPHAT_RIGHT = 0 # analog FRONT_TOPHAT_LEFT = 1 #sensor values on_black = 1800 #servo ports servo_arm = 0 servo_wrist = 1 servo_claw = 3 #switched from 2 due to broken port if is_clone: # Yellow Lego
import wallaby as w # Time startTime = -1 # Digital ports GREEN_CLONE_SWITCH = 9 YELLOW_CLONE_SWITCH = 8 RIGHT_BUTTON = 13 ALLOW_BUTTON_WAIT = True isGreen = w.digital(GREEN_CLONE_SWITCH) isYellow = False '''w.digital(YELLOW_CLONE_SWITCH)''' isBlue = not isGreen and not isYellow # Motor ports LMOTOR = 3 RMOTOR = 0 if isBlue: DATEMOTOR1 = 1 DATEMOTOR2 = 2 elif isGreen: DATEMOTOR1 = 2 #was 1 DATEMOTOR2 = 1 elif isYellow: DATEMOTOR1 = 1 DATEMOTOR2 = 2 #Analog Ports ET = 0 STARTLIGHT = 5
def getRBUTTON(): return digital (c.RBUTTON)
startTime = -1 # Motor ports LMOTOR = 3 RMOTOR = 0 DATEMOTOR = 1 # Digital ports GREEN_CLONE_SWITCH = 9 YELLOW_CLONE_SWITCH = 8 RIGHT_BUTTON = 13 #Analog Ports ET = 0 isGreen = w.digital(GREEN_CLONE_SWITCH) isYellow = w.digital(YELLOW_CLONE_SWITCH) isBlue = not isGreen and not isYellow # Servos servoArmBin = 0 servoPipeWheel = 2 # camera channels ORANGE = 0 RED = 1 GREEN = 2 YELLOW = 3 # color tolerances COLOR_PROXIMITY = 20
TURN_TIME = 0 LOGFILE = "" # Leave empty ROBOT_NAME = "Create-17" # Digital ports ROBOT_ID_YELLOW = 0 ROBOT_ID_BLUE = 1 ROBOT_ID_GREEN = 2 IGUS_BUTTON = 9 #Analog Ports STARTLIGHT = 0 FRONT_TOPHAT = 5 IS_YELLOW_BOT = digital(ROBOT_ID_YELLOW) IS_BLUE_BOT = digital(ROBOT_ID_BLUE) IS_GREEN_BOT = digital(ROBOT_ID_GREEN) IS_ORANGE_BOT = not IS_BLUE_BOT and not IS_YELLOW_BOT and not IS_GREEN_BOT FIRST_RGY_AREA = 40 if IS_ORANGE_BOT: INCHES_TO_TICKS = 600 #Claw Servo Values clawClosed = 0 clawFrisbeeTight = 397 clawMid = 517 clawBotguy = 620 #630