Пример #1
0
def Turning(flag, Offset, a, readValue):
    calcAngle = a

    if calcAngle < 0.0: 
        calcAngle = calcAngle + 360.0
    elif calcAngle > 360.0:
        calcAngle = calcAngle - 360.0

    print("Turning now:")
    print("Target Angle" + str(calcAngle))


    if flag == 1:
        angle = IMU(Offset,readValue)
        motorSelfTest.RightTurn()
        while angle < calcAngle:
            print("Current angle " + str(angle))
            #Loops until angle is achieved
            angle = IMU(Offset,readValue)
        motorSelfTest.Stop()
        
    elif flag == 2:
        angle = IMU(Offset,readValue)
        motorSelfTest.LeftTurn()
        while angle > calcAngle:
            print("Current angle " + str(angle))
            #Loops until angle is achieved
            angle = IMU(Offset,readValue) 
        motorSelfTest.Stop()
    motorSelfTest.Stop()
Пример #2
0
def returnTurn(flag, Offset):
    if flag == 1:
        while (IMU(Offset) > 0) or (IMU(Offset) < 360):
            motorSelfTest.LeftTurn(1.5)
    elif flag == 2:
        while (IMU(Offset) > 0) or (IMU(Offset) < 360):
            motorSelfTest.RightTurn(1.5)
    motorSelfTest.Stop(0.25)
Пример #3
0
def returnTurn(flag, Offset):
    if flag == 1:
        while (IMU(Offset) > 10) or (IMU(Offset) < 350):
            motorSelfTest.LeftTurn()
    elif flag == 2:
        while (IMU(Offset) > 10) or (IMU(Offset) < 350):
            motorSelfTest.RightTurn()
    motorSelfTest.Stop()
Пример #4
0
def motorTesting():
    motorSelfTest.Forward(100,75)
    motorSelfTest.Stop()
    motorSelfTest.Backward(100,75)
    motorSelfTest.Stop()
    motorSelfTest.RightTurn()
    motorSelfTest.Stop()
    motorSelfTest.LeftTurn()
    motorSelfTest.Stop()
Пример #5
0
def returnTurn(flag, Offset,readValue):
    angle = IMU(Offset,readValue)
    if flag == 1:
        while (angle > 10) or (angle < 350):
            motorSelfTest.LeftTurn()
    elif flag == 2:
        while (angle > 10) or (angle < 350):
            motorSelfTest.RightTurn()
    motorSelfTest.Stop()
Пример #6
0
def Turning(flag, Offset, a):
    CurrentAngle = IMU(Offset)
    calcAngle = CurrentAngle + a
    if flag == 1:
        while IMU(Offset) < calcAngle:
            print(IMU(Offset))
            motorSelfTest.RightTurn(1.5)
    elif flag == 2:
        while IMU(Offset) > calcAngle:
            print(IMU(Offset))
            motorSelfTest.LeftTurn(1.5)
    motorSelfTest.Stop(0.25)
Пример #7
0
def returnTurn(flag, Offset, readValue):
    if flag == 1:
        angle = IMU(Offset, readValue)
        while (angle > 10):
            motorSelfTest.LeftTurn()
            print(angle)
            angle = IMU(Offset, readValue)
        motorSelfTest.Stop()
    elif flag == 2:
        angle = IMU(Offset, readValue)
        while (angle < 350):
            motorSelfTest.RightTurn()
            print(angle)
            angle = IMU(Offset, readValue)
        motorSelfTest.Stop()
    motorSelfTest.Stop()
    return
Пример #8
0
            lat, lon = GPSdata()
            distance = distanceFormula(lat,lon,desLat,desLong)
            motorSelfTest.Forward(random.randint(25,100),100)
        elif lat < destLat and flag==2:
            motorSelfTest.Stop()
            Turning(flag, Offset, 270, readValue)
            lat, lon = GPSdata()
            distance = distanceFormula(lat,lon,desLat,desLong)
            motorSelfTest.Forward(random.randint(25,100),100)
        distance = distanceFormula(lat, lon, desLat, desLong)
        print distance
    motorSelfTest.Stop()
    if flag == 1:
        motorSelfTest.LeftTurn()
    elif flag == 2:
        motorSelfTest.RightTurn()

    #===== Turn to North =====
    returnTurning(flag, Offset, readValue)
    
    #===== Turret Code =====
    # Fix turret calculation 
    TurretRotation(lat, lon)
    os.system('python /home/pi/Desktop/build/Platform/platformCCW.py')
    # Arm Up works fine, no need to touch it
    os.system('python /home/pi/Desktop/build/Platform/armUp.py')
    start_time = time.time()
    while time.time() - start_time <= 4:
        os.system('python /home/pi/Desktop/build/Platform/vibration.py')
        vibration = open("/home/pi/Desktop/build/Platform/vibration.txt","r")
        data = vibration.readline()
Пример #9
0
def returnTurning(flag):
    if flag == 1:
        motorSelfTest.LeftTurn(1.5)
    elif flag == 2:
        motorSelfTest.RightTurn(1.5)
    motorSelfTest.Stop(0.25)