Пример #1
0
def lineFollowRightFrontTilLeftFrontBlack(speed):
    while onBlackFrontLeft():
        if not onBlackFrontRight():
            create_drive_direct(speed/2, speed)
        else:
            create_drive_direct(speed, speed/2)
    cpp.drive(0,0)
Пример #2
0
def lineFollowRightFrontTilRightBlack():
    while onBlackRight():
        if not onBlackFrontRight():
            create_drive_direct(200, 100)
        else:
            create_drive_direct(100, 200)
    cpp.drive(0,0)
Пример #3
0
def driveTillBump(lspeed, rspeed):
    temp = -lspeed
    lspeed = -rspeed
    rspeed = temp
    create_drive_direct(rspeed, lspeed)
    while not cpp.left_bump() and not cpp.right_bump():
        pass
    cpp.drive(0,0)
Пример #4
0
def timedLineFollowFrontTophat(time):
    sec = seconds()
    while(seconds() - sec<time):
        if analog(c.FRONT_TOPHAT) < 1500:
            create_drive_direct(-100, -50)
        else:
            create_drive_direct(-50, -100)
    cpp.drive(0,0)
Пример #5
0
def timedLineFollowLeftFront(speed, time):
    sec = seconds()
    while(seconds() - sec<time):
        if not onBlackFrontLeft():
            create_drive_direct(speed, speed/2)
        else:
            create_drive_direct(speed/2, speed)
    cpp.drive(0,0)
Пример #6
0
def driveTilFrontTophatBlack(lspeed, rspeed):
    temp = -lspeed
    lspeed = -rspeed
    rspeed = temp
    create_drive_direct(rspeed, lspeed)
    while (analog(c.FRONT_TOPHAT) < 2000):
        pass
    cpp.drive(0,0)
Пример #7
0
def timedLineFollowRightFront(speed, time):
    sec = seconds()
    while(seconds() - sec<time):
        if not onBlackFrontRight():
            create_drive_direct(speed, (int)(speed/1.8))
        else:
            create_drive_direct((int)(speed/1.8), speed)
        msleep(10)
    cpp.drive(0,0)
Пример #8
0
def driveTilBlackLRCliffAndSquareUp(lspeedInit, rspeedInit):
    lspeed = -rspeedInit
    rspeed = -lspeedInit
    #print(cpp.TEMP_GET_ROBOT().cliff_right_signal)
    cpp.drive(lspeed, rspeed)
    while not onBlackLeft() or not onBlackRight():
        if onBlackLeft():
            cpp.drive(abs(lspeed)/lspeed * 5, 0)
            print('black on left')
        elif onBlackRight():
            cpp.drive(0, abs(rspeed)/rspeed * 5)
            print('black on right')
        else:
            print('on white')
Пример #9
0
def turnTilRightFrontBlack(left, right):
    create_drive_direct(left, right)
    while onBlackFrontRight():
        pass
    cpp.drive(0,0)
Пример #10
0
def create_drive_direct(left, right):
    cpp.drive(int(left/5), int(right/5))