示例#1
0
def move_robot():
    global translate
    global tilt
    global rotate
    global updown
    # initialise hexapod object
    leg_end_coords = np.tile((0.0, 68.75, 0.0), (6, 1))  # check back
    leg_angles = np.tile(0.0, 6)  # leg angle init
    # print(leg_end_coords, leg_end_coords.shape)
    walky = hexapod.hexapod(leg_end_loc=leg_end_coords, leg_angle=leg_angles)

    leg_rst_flag = 0

    # Write, consume it nonblocking
    while True:
        print("Translate values:", translate)
        print("Tilt values:", tilt)
        print("Rotate:", rotate)
        tilt_use = np.copy(tilt)
        translate_use = np.copy(translate)
        updown_use = np.copy(updown)
        rotate_use = np.copy(rotate)

        # walky.body_pitch(tilt_use[0])
        # walky.body_roll(tilt_use[1])
        # walky.body_translate_z(updown_use*4)
        if abs(translate_use[0]) > 10 or abs(
                translate_use[1]) > 10 or abs(rotate) > 10:
            walky.tripod_gait(translate_use[0],
                              translate_use[1],
                              rotate_use,
                              tilt_use[0],
                              tilt_use[1],
                              step_speed=2.0)
            leg_rst_flag = 0
        else:
            if leg_rst_flag == 0 or leg_rst_flag == 1:
                walky.tripod_gait(0, 0, 0, 0, 0, step_speed=2.0)
                leg_rst_flag += 1
            else:
                walky.write_leg_angles()
示例#2
0
# import hex_legs
import hexapod
import numpy as np
from adafruit_servokit import ServoKit
import time

# initialise hexapod object
leg_end_coords = np.tile((0.0, 68.75, 0.0), (6,1)) # check back
leg_angles = np.tile(90.0, 6)  # leg angle init
# print(leg_end_coords, leg_end_coords.shape)
walky = hexapod.hexapod(leg_end_loc=leg_end_coords, leg_angle=leg_angles)

amplitude = 30
TEST_DUR = 8.0
TIME_DELTA = 0.05
TEST_LEN = 1

print("Walkybot initial status:")
walky.print_state()
for leg in walky.legs:
    leg.debug_print()

print("")

def reset(delay):
    # Reset
    print("Resetting to normal stance")
    walky.body_pitch(0.0)
    walky.body_roll(0.0)
    walky.body_rotate_absolute(0.0)
    walky.update_legs_stance()