import time, tty, sys from ev3dev2.motor import LargeMotor, OUTPUT_D, SpeedPercent, SpeedDPS, MoveTank from ev3dev2.sensor import INPUT_1 tty.setcbreak(sys.stdin) mShuttle = LargeMotor(OUTPUT_D) time.sleep(0.5) mShuttle.reset() time.sleep(2) mShuttle.duty_cycle_sp = 0 mShuttleDtyMax = 22 mShuttle.stop_action = 'coast' mShuttle.polarity = 'inversed' mShuttle.position = 0 prev_mShuttle_pos = 0 # Turn motor on with run_direct and duty_cycle_sp of '0' mShuttle.run_direct() print ("Ready for keyboard commands...") while (True): x = ord(sys.stdin.read(1)) if x == 120: # x key pushed - exit mShuttle.duty_cycle_sp = 0 mShuttle.off(brake=False) break
beaconLock = False # has the beacon been found and data read? cmpGenHeading = False # do we have a lock on compass heading for North? beaconSearch = False # are we searching for the beacon right now? cmpSearch = False # are we searching for North with the compass right now? navPrint = 10 # print the Nav msgs every nth cycle i = 0 # iterator for testing # setup motors mL = LargeMotor(OUTPUT_A) time.sleep(0.5) mL.reset() time.sleep(2) mLspd = 0 mL.stop_action = 'coast' mL.polarity = 'inversed' mL.position = 0 mR = LargeMotor(OUTPUT_B) time.sleep(0.5) mR.reset() time.sleep(2) mRspd = 0 mR.stop_action = 'coast' mR.polarity = 'inversed' mR.position = 0 spd = 0 # set this value to -30 to +90; use to set outer wheel/motor speed; default to mL for driving straight turnRatio = 0.0 # set this value to -0.5 to +0.5; subtract from 1 to set turn ratio; multiply * spd to set inside motor speed
# Removed all traces of Pistorms version (issues and comments) import time, tty, sys from ev3dev2.motor import LargeMotor, OUTPUT_C, OUTPUT_D, SpeedPercent, SpeedDPS, MoveTank from ev3dev2.sensor import INPUT_1 tty.setcbreak(sys.stdin) mLift = LargeMotor(OUTPUT_C) time.sleep(0.5) mLift.reset() time.sleep(2) mLift.duty_cycle_sp = 0 mLiftDtyMax = 36 mLift.stop_action = 'coast' mLift.polarity = 'inversed' mLift.position = 0 mGrab = LargeMotor(OUTPUT_D) time.sleep(0.5) mGrab.reset() time.sleep(2) mGrab.duty_cycle_sp = 0 mGrabDtyMax = 36 mGrab.stop_action = 'coast' mGrab.polarity = 'inversed' mGrab.position = 0 # Turn motors on with run_direct and duty_cycle_sp of '0' mLift.run_direct() mGrab.run_direct()