sleep(2)
                                break
                        if (correctionError > 0):
                            print 'Correct Right!'  # Got rid of exclamation points cuz Mackenzie rude af
                            print 'ERROR for Right turn:', correctionError
                            rightSlow = 255 - correctionError * motorK
                            print 'Decreasing Right Motor:', rightSlow
                            M1.pwmSet(rightSlow, a)
                            M2.pwmSet(maxPWM, a)

                        if (correctionError < 0):
                            print 'Correct Left!'
                            print 'ERROR for Left turn:', correctionError
                            leftSlow = 255 + correctionError * motorK  # sign here is positive because the angle is negative
                            print 'Decreasing Left Motor:', leftSlow
                            M1.pwmSet(maxPWM, a)
                            M2.pwmSet(leftSlow, a)
        except KeyboardInterrupt:
            M1.stopAll(a)
            M2.stopAll(a)
            manualControl(a, M1, M2,
                          MANUAL)  # This sends the code into Manual Control
            AUTO = manualControl(
                a, M1, M2, MANUAL)  # For more info refer to ManualControl.py

    except KeyboardInterrupt:
        M1.stopAll(a)
        M2.stopAll(a)

M1.stopAll(a)
M2.stopAll(a)
from MotorClass import Motor
from Trig import Trig
from math import fabs
from time import sleep
import sys

a = nanpyConnect()

M1En = 3
M1A = 4
M1B = 5
M2En = 11
M2A = 9
M2B = 10

motorK = 2
maxPWM = 255

AUTO = True
MANUAL = True

M1 = Motor("LEFT", M1En, M1A, M1B)
M2 = Motor("RIGHT", M2En, M2A, M2B)

M1.pinSet(a)
M2.pinSet(a)

AUTO = manualControl(a, M1, M2, MANUAL)
M1.stopAll(a)
M2.stopAll(a)
print(AUTO)
Exemplo n.º 3
0
                                    sleep(0.0001)
                                sleep(2)
                                break
                        if (correctionError > 0):
                            print 'Correct Right!'  # Got rid of exclamation points cuz Mackenzie rude af
                            print 'ERROR for Right turn:', correctionError
                            rightSlow = 255 - correctionError * motorK
                            print 'Decreasing Right Motor:', rightSlow
                            M1.pwmSet(rightSlow, a)
                            M2.pwmSet(maxPWM, a)

                        if (correctionError < 0):
                            print 'Correct Left!'
                            print 'ERROR for Left turn:', correctionError
                            leftSlow = 255 + correctionError * motorK  # sign here is positive because the angle is negative
                            print 'Decreasing Left Motor:', leftSlow
                            M1.pwmSet(maxPWM, a)
                            M2.pwmSet(leftSlow, a)

            except KeyboardInterrupt:
                M1.stopAll(a)
                M2.stopAll(a)
                manualControl(
                    a, M1, M2,
                    MANUAL)  # This sends the code into Manual Control
                AUTO = manualControl(a, M1, M2, MANUAL)
    # For more info refer to ManualControl.py
    except KeyboardInterrupt:
        M1.stopAll(a)
        M2.stopAll(a)