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.")
Beispiel #3
0
def main():
    motors = Sensorimotor(number_of_motors=2, verbose=False)

    try:
        # checking 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])
        # starting motorcord
        motors.start()

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

        while (True):
            print_position(motors.get_position())
            sleep(0.2)

#prints the current position

        motors.stop()

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