Ejemplo n.º 1
0
    def __init__(self):
        self.is_initialized = False
        rospy.init_node('manipulator_interface', anonymous=False)
        self.sub = rospy.Subscriber('manipulator_command', Manipulator,
                                    self.callback)

        rospy.on_shutdown(self.shutdown)

        try:
            self.claw_stepper = Stepper(STEPPER_NUM_STEPS, STEPPER_CLAW_PINS,
                                        STEPPER_CLAW_PWM_PINS, COMPUTER)
            self.claw_direction = 0
            self.vertical_stepper = Stepper(STEPPER_NUM_STEPS,
                                            STEPPER_VERTICAL_PINS,
                                            STEPPER_VERTICAL_PWM_PINS,
                                            COMPUTER)
            self.vertical_stepper_direction = 0
        except NameError:
            rospy.logfatal(
                'Could not initialize stepper.py. Is /computer parameter set correctly? '
                'Shutting down node...')
            rospy.signal_shutdown('')

        self.claw_stepper.disable()
        self.vertical_stepper.disable()

        rospy.loginfo('Initialized with {0} RPM steppers.'.format(STEPPER_RPM))
        self.is_initialized = True
        self.spin()
Ejemplo n.º 2
0
class Shelly(BaseTurtle):

    bipolar1 = Stepper()
    bipolar2 = Stepper(2)

    def __init__(self):
        self.readingarray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

    def start(self):
        rcpy.set_state(rcpy.RUNNING)
        time.sleep(.5)
        mpu9250.initialize(enable_magnetometer=False)
        time.sleep(.5)

    def reset(self):
        self.xyz = [0, 0, 0]
        return 0

    def move(self, action_vector):

        t_0 = time.time()
        t_stop = t_0 + 0.50
        t_sensing = t_0 + 0.10  # was .25
        t1 = t_0

        max_accel = [0, 0, 0]
        min_accel = [0, 0, 0]
        sum_accel = [0, 0, 0]

        max_gyro = [0, 0, 0]
        min_gyro = [0, 0, 0]
        motor.motor1.set(action_vector[0] * 0.35)
        motor.motor2.set(action_vector[1] * 0.36)
        count = 0
        while t1 <= t_stop:
            if t1 <= t_sensing:
                data = mpu9250.read()
                max_accel = np.maximum(max_accel, data['accel'])
                min_accel = np.minimum(min_accel, data['accel'])
                sum_accel = np.add(data['accel'], sum_accel)
                max_gyro = np.maximum(max_gyro, data['gyro'])
                min_gyro = np.minimum(min_gyro, data['gyro'])
                count += 1
            t1 = time.time()

        motor.motor1.set(action_vector[0] * 0.00)
        motor.motor2.set(action_vector[1] * 0.00)
        if max_gyro[Z] > 100.0:
            return 'TL'
        elif min_gyro[Z] < -100.0:  # was -150
            return 'TR'
        elif sum_accel[1] > 0:
            return 'F'
        else:
            return 'R'

    def stop(self):
        rcpy.exit()
Ejemplo n.º 3
0
def setup():
	global Light
	Light = mraa.Gpio(8)  
	Light.dir(mraa.DIR_OUT) 

	global sensorPin
	sensorPin = mraa.Aio(5)

	global BaseStepper
	BaseStepper = Stepper(10,11,9,'eighth_step')

	global ReceiverStepper
	ReceiverStepper = Stepper(7,6,2,'eighth_step')
	ReceiverStepper.rotateMotor(45)
    def __init__(self, debug=False):
        """
        0 : pallete
        1 : Cyan
        2 : Magenta
        3 : Yellow
        4 : Black
        5 : White
        """
        self.palettePosition = 0
        self.stepsPerCup = 63.3333
        self.maxPalettePosition = 19 * self.stepsPerCup
        self.palette_colors = {}
        self.debug = debug
        self.activeCup = 0

        # self.mixerStepper = StepperBasic(12,6,13,19)

        if debug:
            self.steppers = []
            self.steppers.append(Stepper(0))
            for i in range(1, 5):
                self.steppers.append(StepperTest(i))

        # set up position switches for the mixer arm
        for pin in [18, 26]:
            GPIO.setup(pin, GPIO.IN)
            #print("testing pin {}".format(pin))
            val = GPIO.input(pin)
            #print(pin, val)
        for out_pin in self.pin_list:
            GPIO.setup(out_pin, GPIO.OUT)
            GPIO.output(out_pin, GPIO.LOW)
Ejemplo n.º 5
0
def move_a_bit(a):
    stepper = Stepper(a, 2000, 1000)

    df = pd.DataFrame(index=np.arange(0, 1500 * 2),
                      columns=('v', 's', 'd', 't'))

    t = 0.0
    s = 0
    try:
        stepper.target_pos = 1500
        while True:
            d = stepper.step()
            m = 1 << stepper.micro
            if d == 0 or stepper.pos / m >= 300:
                stepper.set_target_speed(6000)
                break
            t += d
            df.loc[s] = [1e6 / d / m, stepper.pos / m, d / 1e6, t / 1e6]
            s += 1
        while True:
            d = stepper.step()
            m = 1 << stepper.micro
            if d == 0:
                break
            if 1e6 / d / m < 200:
                i = 1
            df.loc[s] = [1e6 / d / m, stepper.pos / m, d / 1e6, t / 1e6]
            t += d
            s += 1
    except:
        print("FAIL")
    return df.dropna()
Ejemplo n.º 6
0
    def __init__(self, step_pin):
        self.stepper = Stepper(step_pin, None)
        self.isRunning = False

        self.maxSpeedDelay = 100
        self.minSpeedDelay = 2000
        self.setSpeed(0)
    def __init__(self):
        GPIO.setup(self.HOME_DOWN_GPIO, GPIO.IN, pull_up_down = GPIO.PUD_UP)
        GPIO.setup(self.HOME_UP_GPIO, GPIO.IN, pull_up_down = GPIO.PUD_UP)
        self.__stepper = Stepper(self.MICROSTEPS * self.GEAR_RATIO, self.DIRECTION_GPIO, self.PULSE_GPIO, self.BACKLASH_STEPS)

        steps = 0
        while self.is_home_down():
            self.__stepper.pulse(self.UP_DIRECTION)
            steps += 1
            if (steps > self.__stepper.total_steps()):
                raise ValueError("Cannot home the elevation stepper. It is likely not moving or the sensor is broken.")
        while not self.is_home_down():
            self.__stepper.pulse(self.DOWN_DIRECTION)
            steps += 1
            if (steps > self.__stepper.total_steps()):
                raise ValueError("Cannot home the elevation stepper. It is likely not moving or the sensor is broken.")

        steps = 0
        self.__amplitude = 0
        while not self.is_home_up():
            self.__stepper.pulse(self.UP_DIRECTION)
            steps += 1
            self.__amplitude += 1
            if (steps > self.__stepper.total_steps()):
                raise ValueError("Cannot home the elevation stepper. It is likely not moving or the sensor is broken.")
        self.__stepper.reset_position()
Ejemplo n.º 8
0
def setup():
	global LED
	LED = mraa.Gpio(7)  
	LED.dir(mraa.DIR_OUT) 

	global Light
	Light = mraa.Gpio(8)  
	Light.dir(mraa.DIR_OUT) 

	global sensorPin
	sensorPin = mraa.Aio(5)

	global BaseStepper
	BaseStepper = Stepper(7,6,2)

	global ReceiverStepper
	ReceiverStepper = Stepper(10,11,9)
Ejemplo n.º 9
0
def test_stepper():
    A = 18
    B = 23
    C = 24
    D = 25

    stepper = Stepper(A, B, C, D)
    stepper.do_full_turn()
    time.sleep(1)
Ejemplo n.º 10
0
 def __init__(self):
     Thread.__init__(self)
     self.window = curses.initscr()
     #Klasse für die drei Schrittmotoren
     self.stepperMotor = Stepper()
     self.wheels = Wheel()
     curses.noecho()
     self.window.keypad(True)
     self.daemon = True
     self.start()
Ejemplo n.º 11
0
 def __init__(self, dataFromClient, socketConnection):
     Thread.__init__(self)
     self.dataFromClient = dataFromClient
     self.komm_handy = socketConnection
     self.motorCamera = Stepper()
     self.wheels = Wheel()
     # angabe wie gerade gefahren wird. 0=halt 1=vorwärts 2=rückwärts 3=links 4=rechts
     self.richtung = 0
     self.verglRichtung1 = 90  # der Motor startet bei 90Grad in der Mitte
     self.verglRichtung2 = 90  # der Motor startet bei 90Grad in der Mitte
     self.daemon = True
     self.start()
Ejemplo n.º 12
0
    def __init__(self):
        self.is_initialized = False
        rospy.init_node('manipulator_interface', anonymous=False)
        self.pub = rospy.Publisher('pwm', Pwm, queue_size=1)
        self.sub = rospy.Subscriber('manipulator_command', Manipulator, self.callback)

        self.neutral_pulse_width = servo_position_to_microsecs(0)

        rospy.sleep(0.1)  # Initial set to zero seems to disappear without a short sleep here
        self.servo_set_to_zero()
        rospy.on_shutdown(self.shutdown)
        self.claw_direction = 0.0
        self.claw_position = 0.0  # 1 = open, -1 = closed
        self.claw_speed = 1.0

        try:
            self.valve_stepper = Stepper(STEPPER_NUM_STEPS,
                                         STEPPER_VALVE_PINS,
                                         STEPPER_VALVE_ENABLE_PIN,
                                         COMPUTER)
            self.valve_direction = 0

            self.agar_stepper = Stepper(STEPPER_NUM_STEPS,
                                        STEPPER_AGAR_PINS,
                                        STEPPER_AGAR_ENABLE_PIN,
                                        COMPUTER)
            self.agar_direction = 0
        except NameError:
            rospy.logfatal('Could not initialize stepper.py. Is /computer parameter set correctly? '
                           'Shutting down node...')
            rospy.signal_shutdown('')

        self.valve_stepper.disable()
        self.agar_stepper.disable()

        rospy.loginfo('Initialized with {0} RPM steppers.'.format(STEPPER_RPM))
        self.is_initialized = True
        self.spin()
Ejemplo n.º 13
0
def stepper_test():
    #stepper variables
    # [stepPin, directionPin, enablePin]

    testStepper = Stepper([24, 22, 23])

    #test stepper
    testStepper.step(20000, "CW"); #steps, dir, speed, stayOn

    sleep(2)
    # test stepper
    testStepper.step(64000, "CCW");  # steps, dir, speed, stayOn

    return {"Stepper test": "done"}
Ejemplo n.º 14
0
def setup():
    global LED
    LED = mraa.Gpio(7)
    LED.dir(mraa.DIR_OUT)

    global sensorPin
    sensorPin = mraa.Aio(2)

    global myStepper
    myStepper = Stepper()

    global myServo
    myServo = Servo()
    myServo.attach(9)
    myServo.write(30)
Ejemplo n.º 15
0
    def __init__(self,
                 name="fibre",
                 length=1.0,
                 alpha=None,
                 beta=None,
                 gamma=0.0,
                 sim_type=None,
                 traces=1,
                 local_error=1.0e-6,
                 method="RK4IP",
                 total_steps=100,
                 self_steepening=False,
                 raman_scattering=False,
                 rs_factor=0.003,
                 use_all=False,
                 centre_omega=None,
                 tau_1=12.2e-3,
                 tau_2=32.0e-3,
                 f_R=0.18):

        use_cache = not (method.upper().startswith('A'))

        self.name = name
        self.length = length
        self.linearity = Linearity(alpha, beta, sim_type, use_cache,
                                   centre_omega)
        self.nonlinearity = Nonlinearity(gamma, sim_type, self_steepening,
                                         raman_scattering, rs_factor, use_all,
                                         tau_1, tau_2, f_R)

        class Function():
            """ Class to hold linear and nonlinear functions. """
            def __init__(self, l, n, linear, nonlinear):
                self.l = l
                self.n = n
                self.linear = linear
                self.nonlinear = nonlinear

            def __call__(self, A, z):
                return self.l(A, z) + self.n(A, z)

        self.function = Function(self.l, self.n, self.linear, self.nonlinear)

        self.stepper = Stepper(traces, local_error, method, self.function,
                               self.length, total_steps)
Ejemplo n.º 16
0
def duster(settings, model_id, zone_id):
    assert ONLY_MODEL_2 and model_id == 2, "ONLY HAVE HYDRO DATA FOR MODEL_IDX=2"

    print(f"M{model_id} (Z{zone_id}) loading input...(slow for now)")
    p = load_particle(settings["particle_inputfile"], \
                      settings["hydrorun_inputfile"], \
                      model_id, zone_id)

    output_d = f"output_M{model_id:03d}"
    os.makedirs(output_d, exist_ok=True)
    output_f = os.path.join(output_d, f"dust{zone_id:04}")

    net = Network(settings["network_file"])

    print(
        f"M{model_id} (Z{zone_id}) loaded, beginnging run: output[{output_f}]")

    gas = SNGas(p, net)
    step = Stepper(gas, net)
    spec    = SolverSpec(time_start = p.times[p.first_idx], time_bound = p.times[p.last_idx], absolute_tol = settings["abs_tol"], \
                     relative_tol = settings["rel_tol"], max_timestep = settings["max_dt"])

    print(f"time_start = {p.times[p.first_idx]}")

    solv = Solver(spec, step)
    obs = Observer(output_f, net, gas, step, solv, settings)

    msg = f"M{model_id} (Z{zone_id}) ok"
    try:
        solv(obs)
    except Exception as e:
        msg = f"M{model_id} (Z{zone_id}) did not finish ok\n{repr(e)}"
        print(msg)
        traceback.print_exc(file=sys.stdout)


#        obs.dump(solv._steps)
    finally:
        #        obs.runout(solv._steps, settings["align_tend_value"], res=settings["align_tend_resolution"])
        ## TIMING
        from stepper import S_DEBUG, S_FASTMATH, S_NOPYTHON, S_PARALLEL
        print(
            f"DEBUG={S_DEBUG}, NOPYTHON={S_NOPYTHON}, FASTMATH={S_FASTMATH}, PARALLEL={S_PARALLEL}"
        )
    return msg
Ejemplo n.º 17
0
def stepper_move(steps,dir,speed):
    #stepper variables
    # [stepPin, directionPin, enablePin]
    #print steps
    testStepper = Stepper([24, 22, 23])
    if dir in VALID_MOVE_DIR:
        #test stepper
        testStepper.step(steps, dir,speed) #steps, dir, speed, stayOn
        data={"Stepper move": "done",
         "dir": dir,
         "steps": steps,
         "speed": speed
         }
    else:
        data={'Move': 'ERROR',
            'error': 'Invalid direction.'}

    return data
Ejemplo n.º 18
0
    def __init__(self, configFile="hardware.cfg", config=None):

        if config == None:

            f = open('hardware.cfg')

            hardconfobj = ujson.loads(f.read())

            self.config = hardconfobj["valve"]

            f.close()

        else:
            self.config = config

        #self.config["homeSencePin"]
        #self.config["homePosToValve"] in mm
        #self.config["valveToValve"] in mm
        #self.config["valveAmmount"]
        #self.config["maxSteps"]

        # mm von ventil zu ventil * schritte pro umdrehung / gewindesteigung
        self.stepsValveToValve = int(
            self.config["valveToValve"] *
            ((4075.7728395061727 / 2) / self._m5_steigung))
        print(self.stepsValveToValve)

        self.stepshomePosToValve = int(
            self.config["homePosToValve"] *
            ((4075.7728395061727 / 2) / self._m5_steigung))

        self.homingIsrunning = False
        self.valveReachedCB = None
        self.homingCB = None

        self.homepin = Pin(self.config["homeSencePin"], Pin.IN)

        pin = self.config["stepperPins"]

        self.valveStepper = Stepper(pin[0], pin[1], pin[2], pin[3],
                                    self.config["steps-s"],
                                    self.config["maxSteps"])
Ejemplo n.º 19
0
def dispense(value):
    value = float(value)
    try:
        print("Setting up OGR")
        ogr = ScaleOGR(False, False)
        stepper = Stepper(1000000)
        f = Filter(0.2)

        print("Setting up camera")
        camera = PiCamera()
        camera.close()
        camera = PiCamera()
        camera.resolution = (1920, 1088)
        camera.framerate = 30
        rawCapture = PiRGBArray(camera, size=(1920, 1088))

        print("Getting images")
        for frame in camera.capture_continuous(rawCapture,
                                               format="bgr",
                                               use_video_port=True):
            image = rawCapture.array
            num = ogr.process(image)
            fv = f.filter(num)
            print('Detected number: {:} -- Filtered number: {:}'.format(
                num, fv))
            rawCapture.truncate(0)

            if fv < value:
                stepper.run(1000, 1)
            else:
                stepper.stop()
                camera.close()

        pass
    except Exception as e:
        print(e)
        print("The scale is probably not on, turn it on and try again")
        pass
Ejemplo n.º 20
0
def accel_2_integer(steps, a):

    stepper = Stepper(a, 10000, 700)
    stepper.target_pos = steps

    df = pd.DataFrame(index=np.arange(0, steps * 16),
                      columns=('v', 's', 'd', 't', 'adj_d', 'micro', 'shift'))

    t = 0
    s = 0
    while True:
        d = stepper.step()
        if d == 0 or s > steps * 16:
            break

        m = 1 << stepper.micro
        v = 1e6 / d / m
        p = stepper.pos / m
        ad = d * m
        t += d
        df.loc[s] = [v, p, d, t / 1e6, ad, m, stepper.shift]
        s += 1
    return df.dropna()
Ejemplo n.º 21
0
from numpy.random import randint, exponential
from numpy import arange, concatenate
import numpy as np
from pyglet.window import key

try:
    from toolbox.toolbox.IO.nidaq import DigitalInput, DigitalOutput, AnalogInput, AnalogOutput
    have_nidaq = True
except:  # Exception, e:
    print("could not import iodaq.")
    have_nidaq = False

sys.path.append('C:\github\syringe_pump')
from stepper import Stepper
import time
s = Stepper(mode='arduino', port='COM3', syringe='3mL')

MOUSE_ID = 'm1'
REWARD_VOLUME = 10  #in µL
REWARD_WINDOW = 1.0  #in seconds

try:
    opts, args = getopt.getopt(sys.argv, "hi:o:",
                               ["mouse_id=", "reward_volume="])
    print(args)
    MOUSE_ID = args[1]
    REWARD_VOLUME = int(args[2])
    REWARD_WINDOW = float(args[3])
    print(MOUSE_ID)
    print(REWARD_VOLUME)
    print(REWARD_WINDOW)
Ejemplo n.º 22
0
from machine import Pin, I2C, PWM, Timer
from stepper import Stepper
import utime as time

pin_dir = Pin(14)
pin_step = Pin(13)
pin_en = Pin(0)

steppy = Stepper(pin_en, pin_dir, pin_step)

steppy.on()
steppy.max_speed = 10000
steppy.acc = 5
for i in range(0, 1):
    steppy.target = steppy.deg_to_steps(360)
    while (steppy.pos != steppy.target):
        _ = steppy.run()
    #steppy.off()
    time.sleep(1.0)

    steppy.target = 0
    while (steppy.pos != steppy.target):
        _ = steppy.run()
    #steppy.off()
    time.sleep(1.0)

print("Done!")

#pwm = PWM(pin_step)
#
#pwm.freq(1000)
Ejemplo n.º 23
0
from stepper import Stepper
from time import sleep

stepper = Stepper()

try:
    print "start"
    stepper.start()
    for i in range(1, 5):
        stepper.setSpeed(i * 200)
        print i * 200
        sleep(1)
    print "stop"
    stepper.stop()
    sleep(.2)
    print "flip"
    stepper.flipDirection()
    stepper.start()
    sleep(5)
    print "stop"
    stepper.stop()

except KeyboardInterrupt:
    print("\nCtrl-C pressed.  Stopping PIGPIO and exiting...")
finally:
    stepper.stop()
Ejemplo n.º 24
0
 def __init__(self):
     GPIO.setmode(GPIO.BCM)
     self.areas = 16
     self.sonicMotor = Stepper()
     self.wheels = Wheel()
     self.motorPosition = 0  #gibt an ob der SonicMotor links oder rechts steht 0=links
Ejemplo n.º 25
0
    load_config()  # Cargamos "config.json"

    # Capturamos webcam
    print "[START] Preparando cámara...."
    camera_recording = False

    while camera_recording is not True:
        camera = cv2.VideoCapture(0)
        time.sleep(1)

        # Esperamos a que la cámara esté preparada
        camera_recording, _ = camera.read()
    print "[DONE] Cámara lista!"

    print "[INFO] Inicializamos los motores..."
    pan_motor = Stepper("Base", 16, 19, 26)
    pan_motor.set_speed(5)
    print(pan_motor.print_info())

    tilt_motor = Stepper("Top", 16, 6, 13)
    tilt_motor.set_speed(5)
    print(tilt_motor.print_info())

    if test_motors == "True":
        motor_test()

    # Loop sobre la camara
    while True:

        # Leemos el primer frame e imprimimos el texto
        (video_signal, frame) = camera.read()
Ejemplo n.º 26
0
from stepper import Stepper
import sys, os, atexit, time, curses

tilt_motor = Stepper("Top", 16, 12, 16)
tilt_motor.set_speed(10)
print(tilt_motor.print_info())
#tilt_motor.off()

# Activamos curses para controlar la impresion
screen = curses.initscr()  # Cogemos el cursor
curses.noecho()  # Desactivamos el echo del input
curses.cbreak()  # Reconocemos inmediatamente las teclas
screen.keypad(True)  # Reconocemos teclas "especiales"

try:
    while True:
        char = screen.getch()
        if char == ord('q'):
            break
        elif char == curses.KEY_UP:
            screen.addstr(0, 0, 'Moviendo arriba...  ')
            tilt_motor.move_forward(1)
        elif char == curses.KEY_RIGHT:
            screen.addstr(0, 0, 'Vuelta arriba...')
            tilt_motor.round_forward()
        elif char == curses.KEY_LEFT:
            screen.addstr(0, 0, 'Vuelta abajo...')
            tilt_motor.round_backwards()
        elif char == curses.KEY_DOWN:
            screen.addstr(0, 0, 'Moviendo abajo...')
            tilt_motor.move_backwards(1)
Ejemplo n.º 27
0
from sensor import Sensor
from stepper import Stepper

sensor = Sensor()
stepper = Stepper(100)

#stepper.start()

while True:
    print(sensor.measure())

Ejemplo n.º 28
0
            servo.update_duty(duty)
            print("Current servo duty cycle: ", duty)
            continue
        else:
            duty = float(input_duty)
            servo.update_duty(duty)
            print("Current servo duty cycle: ", duty)
            continue


if __name__ == "__main__":

    # initializing  classes
    home_switch = Digital_Io(config.limit_home_pin, "in")  # NEVER DELETE
    end_switch = Digital_Io(config.limit_end_pin, "in")  # NEVER DELETE
    slide = Stepper(config.slide_pins, 72, 1)
    force_pwr = Digital_Io(config.force_pins, "out", 0)  # NEVER DELETE
    force_sig = Analog_In(config.force_pins)  # NEVER DELETE

    while True:
        try:
            input_servo = str(
                input("\nEnter servo name [r=rotation, l=linear, p=pulley]: "))
        except ValueError:
            print("Error: Invalid Input")
            continue
        # rotation servo: 1.98 - 12.85 @ 50Hz (7.415 straight) (5 trash bin)
        if input_servo == "r":
            servo = Servo(config.rotation_pin, 180)
            servo.start(1.98, 12.85)
            servo.update_duty(7.415)
Ejemplo n.º 29
0
stream_splitter_port = 3

# Webserver
g_camera = None
g_output = None
g_server = None
stream_enabled = True
webserver_restart = True

# Stepper
pin_IN1 = 15
pin_IN2 = 18
pin_IN3 = 4
pin_IN4 = 17
pulse_timeout = 0.001 # time to wait before sending another pulse to the stepper motor (smaller = faster but less strong and less precise)
stepper = Stepper(pin_IN1, pin_IN2, pin_IN3, pin_IN4, pulse_timeout)

# PIR sensors
IR_PIN = 23
IR2_PIN = 27
IR_front = Pin(IR_PIN, Pin.IN)
IR_back = Pin(IR2_PIN, Pin.IN)
IR_timestamp = monotonic()
IR_time_threshold = 15 # seconds before subsequent IR input is recognized again
IR_loop_running = False

# Processes object detection results and calculates if the device should adjust its rotation or not
def process_coords(data):
    im_width = stream_resolution[0]
    prioritized_target = None
    targets = data["tar"]
Ejemplo n.º 30
0
from stepper import Stepper
import sys, os, atexit, time,curses
pan_motor = Stepper("Base",16,19,26)
pan_motor.set_speed(10)
print(pan_motor.print_info())


# Activamos curses para controlar la impresion
screen = curses.initscr()     # Cogemos el cursor
curses.noecho()               # Desactivamos el echo del input
curses.cbreak()               # Reconocemos inmediatamente las teclas
screen.keypad(True)           # Reconocemos teclas "especiales"

try:
	while True:
		char = screen.getch()
		if char == ord('q'):
			break
		elif char == curses.KEY_UP:
			screen.addstr(0, 0, 'Vuelta...')
			pan_motor.round_forward()
		elif char == curses.KEY_RIGHT:
			screen.addstr(0, 0, 'Moviendo a derecha...  ')
			pan_motor.move_forward(1)
		elif char == curses.KEY_LEFT:
			screen.addstr(0, 0, 'Moviendo a izquierda...')
			pan_motor.move_backwards(1)
		elif char == curses.KEY_DOWN:
			screen.addstr(0, 0, 'Vuelta...')
			pan_motor.round_backwards()