def sit(): """ Lowers the chassis to the ground """ global standing standing = False for node in nodes: xjus.setPositionProfile(node, 500, 10000, 10000) for node in nodes: move(node, -degToPos(STAND_ANGLE)) wait()
def startTripod(turnAngle=0, back=False, duty_turn=0): """ Move to the starting position of the tripod gait and fill the buffer with some initial points. """ for node in nodes: xjus.profilePositionMode(node) xjus.setPositionProfile(node, 1500, 10000, 5000) print "Moving to start position..." for node in nodes: [p, v, dt] = getTripodPVT(node, TIME_OFFSET, turnAngle=turnAngle, back=back) print("Start position. node: %d, p: %d, v: %d" % (node, p, v)) #if node in left: if back: move(node, -p, absolute=True) else: move(node, p, absolute=True) wait() for node in nodes: xjus.interpolationMode(node) # Start time is half of dt t = (DT / 1000.) / 2 + TIME_OFFSET # fill buffer for i in range(BUFFER_MAX_LIMIT / 2): [nA, pA, vA, tA] = addTripodPoint(t, turnAngle, back=back, duty_turn=duty_turn) addPvtArray(nA, pA, vA, tA) t += DT / 1000. for node in nodes: xjus.startIPM(node) xjusAnalysis.startAccel(TRIAL_ID, PLOT_ANALYSIS) xjusAnalysis.startAvgVelocity(TRIAL_ID) xjusAnalysis.startAvgCurrent(TRIAL_ID, PLOT_ANALYSIS) return t
def stand(): """ Raises the chassis into a standing position """ global standing standing = True for node in nodes: xjus.setPositionProfile(node, 500, 10000, 10000) for node in nodes: move(node, degToPos(STAND_ANGLE)) wait() for node in nodes: xjus.zeroPosition(node)
def startTripod(turnAngle=0, back=False, duty_turn=0): """ Move to the starting position of the tripod gait and fill the buffer with some initial points. """ for node in nodes: xjus.profilePositionMode(node) xjus.setPositionProfile(node, 1500, 10000, 5000) print "Moving to start position..." for node in nodes: [p, v, dt] = getTripodPVT(node, TIME_OFFSET, turnAngle=turnAngle, back=back) print("Start position. node: %d, p: %d, v: %d" % (node, p, v)) #if node in left: if back: move(node, -p, absolute=True) else: move(node, p, absolute=True) wait() for node in nodes: xjus.interpolationMode(node) # Start time is half of dt t = (DT/1000.) / 2 + TIME_OFFSET # fill buffer for i in range(BUFFER_MAX_LIMIT/2): [nA, pA, vA, tA] = addTripodPoint(t, turnAngle, back=back, duty_turn=duty_turn) addPvtArray(nA, pA, vA, tA) t += DT/1000. for node in nodes: xjus.startIPM(node) xjusAnalysis.startAccel(TRIAL_ID, PLOT_ANALYSIS) xjusAnalysis.startAvgVelocity(TRIAL_ID) xjusAnalysis.startAvgCurrent(TRIAL_ID, PLOT_ANALYSIS) return t;
def moveToFullRotation(node): p = getPosition(node) targetForward = p + (REV - (p % REV)) targetBack = p - (p % REV) forwardDist = targetForward - p backwardDist = p - targetBack #print("node: %s, p: %d, forward: %d, back: %d" % (name[node], p, forwardDist, backwardDist)) xjus.setPositionProfile(node, 1500, 10000, 5000) if (backwardDist < REV / 15.): #print("moving backward to %d" % targetBack) move(node, targetBack, absolute=True) else: #print("moving forward to %d" % targetForward) move(node, targetForward, absolute=True)
def moveToFullRotation(node): p = getPosition(node) targetForward = p + (REV - (p % REV)) targetBack = p - (p % REV) forwardDist = targetForward - p backwardDist = p - targetBack #print("node: %s, p: %d, forward: %d, back: %d" % (name[node], p, forwardDist, backwardDist)) xjus.setPositionProfile(node, 1500, 10000, 5000) if (backwardDist < REV/15.): #print("moving backward to %d" % targetBack) move(node, targetBack, absolute=True) else: #print("moving forward to %d" % targetForward) move(node, targetForward, absolute=True)