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.25, 0.18])
        # Start motors
        motors.start()

        #TODO: set this parameters according to your desired motor positon control behaviour
        motors.set_pos_ctrl_params(0,
                                   Kp=2.3,
                                   Ki=0.4,
                                   Kd=0.1,
                                   deadband=0.1,
                                   pulse_threshold=0.1)
        motors.set_pos_ctrl_params(1,
                                   Kp=0.4,
                                   Ki=0.2,
                                   Kd=0.01,
                                   deadband=0.1,
                                   pulse_threshold=0.1)

        # Set the motor position
        motors.set_position([0.6, 0])
        sleep(1.5)

        # Print the current position
        print_position(motors.get_position())

        # Set the motor position
        motors.set_position([-0.6, 0])
        sleep(1.5)

        # Print the current position
        print_position(motors.get_position())

        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 the supply voltage limit
        motors.set_voltage_limit([0.11, 0.11])

        # Start motors
        motors.start()

        motors.set_pos_ctrl_params(0,
                                   Kp=1.8,
                                   Ki=0.2,
                                   Kd=0.1,
                                   deadband=0.1,
                                   pulse_threshold=0.1)
        motors.set_pos_ctrl_params(1,
                                   Kp=1.8,
                                   Ki=0.2,
                                   Kd=0.1,
                                   deadband=0.1,
                                   pulse_threshold=0.1)

        motors.set_position([0.5, 0.5])
        sleep(1.5)

        # Print the current position
        print_position(motors.get_position())

        motors.set_position([-0.5, -0.5])
        sleep(1.5)

        # Print the current position
        print_position(motors.get_position())

        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.")
Пример #3
0
def main():
    motors = Sensorimotor(number_of_motors=2, 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])

        # starting motorcord
        motors.start()

        #TODO: set this parameters according to your desired motor positon control behaviour
        #motors.set_pos_ctrl_params(0, Kp = 1.0, Ki = 0.0, Kd = 0.0, deadband = 0.00, pulse_threshold = 0.00)

        while (True):
            # USER CODE HERE BEGIN

            motors.set_position([0.2, 0.2])
            for i in range(100):
                sleep(0.01)
                print_position(motors.get_position())

            motors.set_position([-0.2, 0.2])
            sleep(1.0)

            # 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.")
Пример #4
0
def main():
    motors = Sensorimotor(number_of_motors=2, verbose=True)

    # checking for motors
    N = motors.ping()
    print("Found {0} sensorimotors.".format(N))
    sleep(1.0)

    # starting motorcord
    motors.set_voltage_limit([0.1, 0.1])
    motors.start()

    try:

        while (True):
            # USER CODE HERE BEGIN

            motors.set_position([0.2, 0.2])
            #print_position(motors.get_position())
            sleep(0.25)
            motors.set_position([0.2, -0.2])
            #print_position(motors.get_position())
            sleep(0.25)
            motors.set_position([-0.2, -0.2])
            #print_position(motors.get_position())
            sleep(0.25)
            motors.set_position([-0.2, +0.2])
            #print_position(motors.get_position())
            sleep(0.25)

            # 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.")
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()

        #these parameters influences the desired motor positon control behaviour
        motors.set_pos_ctrl_params(0,
                                   Kp=1.2,
                                   Ki=0.3,
                                   Kd=0.1,
                                   deadband=0,
                                   pulse_threshold=0)
        motors.set_pos_ctrl_params(1,
                                   Kp=1.2,
                                   Ki=0.3,
                                   Kd=0.1,
                                   deadband=0,
                                   pulse_threshold=0)

        motors.set_position([0.0, 0.0])
        sleep(2)

        # Print the current position
        print_position(motors.get_position())

        #TODO: set the position for the robot to move
        motors.set_position([])
        sleep(2)

        # Print the current position
        print_position(motors.get_position())

        #TODO: set the position for the robot to move
        motors.set_position([])
        sleep(2)

        # Print the current position
        print_position(motors.get_position())

        #TODO: set the position for the robot to move
        motors.set_position([])
        sleep(2)

        # Print the current position
        print_position(motors.get_position())

        #TODO: set the position for the robot to move
        motors.set_position([])
        sleep(2)

        # Print the current position
        print_position(motors.get_position())

        #TODO: set the position for the robot to move
        motors.set_position([])
        sleep(2)

        # Print the current position
        print_position(motors.get_position())

        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.")