Пример #1
0
    # cpr encoder 8096 length: 112816
    full_length = 56427
    restricted_length = 10000
    middle = full_length / 2

    axis.set_vel_limit(250000)

    switch = True

    try:
        while True:

            pos = axis.get_pos()

            if pos > -(full_length -
                       restricted_length) and joystick.get_axis('y') < -.05:
                if switch:
                    print("right")
                    switch = False
                axis.set_vel(50000 * joystick.get_axis('y'))

            elif pos < -restricted_length and joystick.get_axis('y') > .05:
                if not switch:
                    print("left")
                    switch = True
                axis.set_vel(50000 * joystick.get_axis('y'))

            else:
                axis.set_vel(0)

            if joystick.button_combo_check([6]):
Пример #2
0
    middle = full_length / 2
    restricted_length = 20000

    # sets the maximum speed the ODrive can go, default set to 20,000
    axis.set_vel_limit(495000)
    vel_speed = 100000

    switch = True

    try:
        while True:

            pos = axis.get_pos()

            if pos < (full_length -
                      restricted_length) and joystick.get_axis('y') < -.05:
                if switch:
                    sleep(.05)
                    print("up")
                    switch = False
                axis.set_vel(vel_speed * -joystick.get_axis('y'))

            elif pos > restricted_length and joystick.get_axis('y') > .05:
                if not switch:
                    sleep(.05)
                    print("down")
                    switch = True
                axis.set_vel(vel_speed * -joystick.get_axis('y'))

            else:
                axis.set_vel(0)