from time import sleep from math import sqrt, pi, atan2, degrees from ev3dev2.sound import Sound from time import sleep medium_motor = MediumMotor() steer_pair = MoveSteering(OUTPUT_B, OUTPUT_C) sound = Sound() my_string = 'ALIKE'.upper( ) # Use only characters AEFHIKLMN. upper() converts lowercase to upper wf = 1 # wheel factor. Use 1 for home version and 0.77 for edu version. scl = 3 # Scale. scl=3 gives 3cm per grid unit. Use scl values between 3 and 5. sp = 20 # speed of steer_pair. Use values between 15 and 30. sep = 10.5 # effective wheel separation in centimeters. degs_per_cm = 26.84 * wf # degrees of wheel turn per cm advanced. degs_per_robot_deg = 2.46 * wf # angle wheels turn when robot turns one degree on the spot medium_motor.position = 0 # needed to protect against a bug. # 'direction' is the direction from the current node to the next node, measured cw from 'north'. heading = 90 # 'heading' is the direction the robot is facing, measured clockwise from 'north'. sequence = { 'A': 'GiMbo', 'E': 'GhCamo', 'F': 'GhCam', 'H': 'aGiCo', 'I': 'AcBnMo' } sequence.update({'K': 'aCgo', 'L': 'Amo', 'M': 'ahco', 'N': 'aoc'}) node = { 'a': (0, 4), 'b': (1, 4),
tts_module = importlib.import_module('tts.ev3') STUD_MM = 8 # TODO: Add code here speed = 20 sound = Sound() tank_drive = MoveTank(OUTPUT_A, OUTPUT_B) steering_drive = MoveSteering(OUTPUT_A, OUTPUT_B) mdiff = MoveDifferential(OUTPUT_A, OUTPUT_B, EV3EducationSetRim, 16 * STUD_MM) btn = Button() arm = MediumMotor() lightswitch = LargeMotor(OUTPUT_D) lightswitch.position = 0 arm.position = 0 supply = PowerSupply() mdiff.odometry_start() scriptname = "/hardware/ev3.py" debug = True stationary_mode = False movements = [] # drive in a turn for 5 rotations of the outer motor # the first two parameters can be unit classes or percentages. def debug_log(message): global debug if (debug): print(message)
sleep(1.9) # initialize motor on Port A for 'dc-motor' mode (am using a Power Functions L motor through an adapter cable) pA = LegoPort(OUTPUT_A).mode = 'dc-motor' sleep(0.6) # looks like it needs time for new mode to settle m1 = DcMotor(OUTPUT_A) # Airjitsu Propeller m1.duty_cycle_sp = 100 #m2 = DcMotor(OUTPUT_B) # Peristaltic Pump #m2.duty_cycle_sp=100 m3 = MediumMotor(OUTPUT_C) # Bubble Handle m3.position = 0 ts1 = TouchSensor(INPUT_1) # Bubble Production #ts2 = TouchSensor(INPUT_2) # Liquid refill t = Thread(target=bubble_handle) bubble_handle_thread = True t.start() while True: if ts1.is_pressed: running = not running sleep(0.25) if running == True: m1.run_forever() else: m1.stop()
from ev3dev2.sound import Sound from time import sleep medium_motor = MediumMotor() steer_pair = MoveSteering(OUTPUT_B, OUTPUT_C) sound = Sound() my_string = 'ALIKE'.upper( ) # Use only characters AEFHIKLMN. upper() converts lowercase to upper wf = 1 # wheel factor. Use 1 for home version and 0.77 for edu version. scl = 3 # Scale. scl=4 gives 4cm per grid unit. Use scl values between 3 and 6. sp = 20 # speed of steer_pair. Use values between 15 and 25. sep = 10.5 # effective wheel separation in centimeters. degs_per_cm = 26.84 * wf # degrees of wheel turn per cm advanced. degs_per_robot_deg = 2.46 * wf # angle wheels turn when robot turns one degree on the spot medium_motor.position = 0 # needed to protect against a bug in on_to_position() # 'direction' is the direction from the current node to the next node, measured cw from 'north'. heading = 90 # 'heading' is the direction the robot is facing, measured clockwise from 'north'. go_forwards = True # initially the robot will move forwards (for positive distance values) sequence = { 'A': 'GiMbo', 'E': 'GhCamo', 'F': 'GhCam', 'H': 'aGiCo', 'I': 'AcBnMo' } sequence.update({'K': 'aCgo', 'L': 'Amo', 'M': 'ahco', 'N': 'aoc'}) node = { 'a': (0, 4),