コード例 #1
0
HIP_REACH = 10
KNEE_REACH = -25
ANKLE_REACH = 40

HIP_REST = -10
KNEE_REST = -30
ANKLE_REST = 40

#----------------------------
# PACKAGES, HELPERS, DRIVER SETUP
#----------------------------
from time import sleep

if TEST == False:
    from comm.pwm import PWM
    driver = PWM(0x41)
    driver.setPWMFreq(50)

# Note: These should be enums
FRONT_LEFT = 'front left'
FRONT_RIGHT = 'front right'
BACK_LEFT = 'back left'
BACK_RIGHT = 'back right'

if TEST == True:
    DELAY = 0.0


def map(z, x, y, a, b):
    # x to y is the old range
    # a to b is the new range
コード例 #2
0
from comm.pwm import PWM
from time import sleep

# CALIBRATION
CHANNEL = 0  # Channel of the servo joint
VALUE = 0  # Value to accomplish the pose
DELAY = 0.5

driver = PWM(0x40)
driver.setPWMFreq(50)

while True:
    driver.setPWM(CHANNEL, 0, VALUE)
    sleep(DELAY)
コード例 #3
0
ファイル: calibrate.py プロジェクト: slaattnes/quadruped
from comm.pwm import PWM
from time import sleep

# CALIBRATION

driver = PWM(0x41)
driver.setPWMFreq(50)

print("Hello world!")
print("Turning off all the 12 servos...")

for ch in range(12):
    driver.setPWM(ch, 0, 0)
    pass

print("...done.")


def get_channel():
    ch = 0
    while True:
        ch = input("Input which channel you want to calibrate (0-11): ")
        try:
            ch = int(ch)
        except:
            print("That is not an integer. Try again.")
            continue

        if ch >= 0 and ch < 12:
            break
コード例 #4
0
    'LMH': (3, 312, 451, -1),
    'LMK': (4, 250, 520, -1),
    'LMA': (5, 158, 565, -1),
    'RMH': (28, 240, 390, 1),
    'RMK': (27, 230, 514, -1),
    'RMA': (26, 150, 620, -1),
    'LBH': (6, 315, 465, 1),
    'LBK': (8, 206, 498, -1),
    'LBA': (7, 150, 657, -1),
    'RBH': (25, 320, 480, 1),
    'RBK': (24, 185, 490, -1),
    'RBA': (23, 210, 645, -1),
    'N': (18, 150, 650, 1)
}

driver1 = PWM(0x40)
driver2 = PWM(0x41)

driver1.setPWMFreq(60)
driver2.setPWMFreq(60)


def drive(ch, val):
    driver = driver1 if ch < 16 else driver2
    ch = ch if ch < 16 else ch - 16
    driver.setPWM(ch, 0, val)


def constrain(val, min_val, max_val):
    return min(max_val, max(min_val, val))