def main(): motors = Sensorimotor(number_of_motors=2, verbose=False) try: # Check for motors N = motors.ping() print("Found {0} motors.".format(N)) sleep(1.0) #voltage limit for supply voltage and desired max. motor speed motors.set_voltage_limit([0.16, 0.16]) # Start motors motors.start() counter = 0 while (counter < 10): #TODO: set the impuse for each motor #moves left motors.apply_impulse([0.1, 0.1]) print("tak") counter = counter + 1 sleep(0.1) counter = 0 while (counter < 10): #TODO: set the impuse for each motor #move right motors.apply_impulse([0.1, -0.1]) print("tak") counter = counter + 1 sleep(0.1) counter = 0 motors.stop() except (KeyboardInterrupt, SystemExit): # Stop motors print("\rAborted, stopping motors") motors.stop() except: # Script crashed? print("\rException thrown, stopping motors") motors.stop() print("____\nDONE.")
def main(): motors = Sensorimotor(number_of_motors = 2, verbose = False) try: # Check for motors N = motors.ping() print("Found {0} motors.".format(N)) sleep(1.0) #TODO: set this according to your supply voltage and desired max. motor speed motors.set_voltage_limit([0.18, 0.18]) # Start motor motors.start() #move left counter = 0 while(counter < 5): motors.apply_impulse([0.5, 0]) print("tak") counter = counter +1 sleep(0.1) counter = 0 #move right while(counter < 5): motors.apply_impulse([-0.5, 0]) print("tak") counter = counter +1 sleep(0.1) counter = 0 #move down while(counter < 5): motors.apply_impulse([0, 0.5]) print("tak") counter = counter +1 sleep(0.1) counter = 0 #move up while(counter < 5): motors.apply_impulse([0, -0.5]) print("tak") counter = counter +1 sleep(0.1) motors.stop() except (KeyboardInterrupt, SystemExit): # Stop motors print("\rAborted, stopping motors") motors.stop() except: # Script crashed? print("\rException thrown, stopping motors") motors.stop() print("____\nDONE.")
def main(): motors = Sensorimotor(number_of_motors=3, verbose=False) try: # checking for motors N = motors.ping() print("Found {0} sensorimotors.".format(N)) sleep(1.0) #TODO: set this according to your supply voltage and desired max. motor speed #motors.set_voltage_limit([0.25, 0.25, 0.25]) # starting motorcord motors.start() beat = tst0 while (True): # USER CODE HERE BEGIN print("tak") for b in beat: motors.apply_impulse(b[0]) sleep(b[1] * 1.2) # USER CODE HERE END except (KeyboardInterrupt, SystemExit): # stopping motor cord print("\rAborted, stopping motors") motors.stop() except: # Script crashed? print("\rException thrown, stopping motors") motors.stop() raise print("____\nDONE.")