def prepareSim(): robot = spotmicroai.Robot(True, True, reset) spurWidth = robot.W / 2 + 20 stepLength = 0 stepHeight = 72 iXf = 120 iXb = -132 IDheight = p.addUserDebugParameter("height", -40, 90, 20) Lp = np.array([[iXf, -100, spurWidth, 1], [iXf, -100, -spurWidth, 1], [-50, -100, spurWidth, 1], [-50, -100, -spurWidth, 1]])
joy_x, joy_y, joy_z, joy_rz = 128, 128, 128, 128 # define our clear function def consoleClear(): # for windows if name == 'nt': _ = system('cls') # for mac and linux(here, os.name is 'posix') else: _ = system('clear') robot = spotmicroai.Robot(True, True, reset) spurWidth = robot.W / 2 + 20 stepLength = 0 stepHeight = 72 iXf = 120 iXb = -132 IDheight = p.addUserDebugParameter("height", -40, 90, 20) Lp = np.array([[iXf, -100, spurWidth, 1], [iXf, -100, -spurWidth, 1], [-50, -100, spurWidth, 1], [-50, -100, -spurWidth, 1]]) resetPose() trotting = TrottingGait()
import math import datetime as dt import matplotlib.animation as animation import random from inputs import devices, get_gamepad from thinputs import ThreadedInputs import spotmicroai from kinematicMotion import KinematicMotion import matplotlib matplotlib.use('GTKAgg') import matplotlib.pyplot as plt from matplotlib.figure import Figure from matplotlib.animation import TimedAnimation robot=spotmicroai.Robot(False,False) speed1=240 speed2=170 speed3=300 spurWidth=robot.W/2+20 stepLength=0 stepHeight=72 iXf=120 iXb=-132 IDspurWidth = p.addUserDebugParameter("spur width", 0, robot.W, spurWidth) IDstepLength = p.addUserDebugParameter("step length", -70, 115, stepLength) IDstepHeight = p.addUserDebugParameter("step height", 0, 150, stepHeight) IDspeed1 = p.addUserDebugParameter("speed 1", 100, 1000, speed1) IDspeed2 = p.addUserDebugParameter("speed 2", 100, 1000, speed2) IDspeed3 = p.addUserDebugParameter("speed 3", 100, 1000, speed3) IDixf = p.addUserDebugParameter("iXf", 0, 400, iXf)
commandInput, commandValue = keyboard.read() print(commandInput) # Gamepad button command filter if commandInput == 'UPPER_ARROW': joy_x = commandValue if commandInput == 'RIGHT_ARROW': joy_y = commandValue if commandInput == 'DOWN_ARROW': joy_z = commandValue if commandInput == 'LEFT_ARROW': joy_rz = commandValue if commandInput == 'SPACE': resetPose() robot = spotmicroai.Robot() IDheight = p.addUserDebugParameter("height", -40, 90, 0) IDroll = p.addUserDebugParameter("roll", -20, 20, 0) #robot.feetPosition(Lp) resetPose() # Initialise the gamepad object using the gamepad inputs Python package keyboard = ThreadedInputsKeyBoard(keyboardInputs) for keyboardInput in keyboardInputs: keyboard.append_command(keyboardInput, keyboardInputs[keyboardInput]) keyboard.start() while True: handleKeyboard() height = p.readUserDebugParameter(IDheight)