from MotorModule import Motor from LaneModule import getLaneCurve import WebcamModule as webcam import utils import cv2 ################################################## motor = Motor(2, 3, 4, 17, 22, 27) ################################################## def main(): img = webcam.getImg() curveVal = getLaneCurve(img, display=1) #print(curveVal) sen = 1.3 # SENSITIVITY maxVAl = 0.3 # MAX SPEED if curveVal > maxVAl: curveVal = maxVAl if curveVal < -maxVAl: curveVal = -maxVAl if curveVal > 0: sen = 1.7 if curveVal < 0.05: curveVal = 0 else: if curveVal > -0.08: curveVal = 0 motor.move(0.35, -curveVal * sen, 0.05) #cv2.waitKey(1) if __name__ == '__main__': initialTrackBarVals = [102, 80, 20, 214]
from MotorModule import Motor #import KeyPressModule as kp #from CameraModule import piCam import JoystickModule as js from time import sleep ################################# motor = Motor(25, 24, 23, 20, 16, 12) #GPIO pins of both motor movement = 'Joystick' #Option of use Keybord, ['Keyboard', 'Joystick'] ################################# def main(): if movement == 'Joystick': #print(js.getJS()) #sleep(0.05) jsVal = js.getJS() motor.move(-(jsVal['axis2']), jsVal['axis1'], 0.1) else: motor.move( 0.5, -1, 2) #Negative values for speed is backward and for turn is left motor.stop(2) motor.move(-0.5, 1, 2) motor.stop(2) if __name__ == '__main__': while True: main()