def quickCheckStepEfficiency(m,p,rtinit,rcinit,ltinit,lcinit,debugPrint=False):
	#Do we need to do anything other than run the build and check the distanes here? I don't think so.
	#STEP 1: Run initial position
	#STEP 2: Check criteria
	#STEP 3: RUN final position
	#STEP 4: Check criteia
	#STEP 5: Compute efficency and results

	if rtinit == ltinit and rcinit == lcinit:
		if debugPrint:
			print "The leg positions are the same. This configuration is not consdered."
		return 'NULL'	
	m.moveAllActuators(rtinit,rcinit,ltinit,lcinit)
	m.computeLocations()
	if debugPrint:
		disp=structureDisplay()
		disp.displayLines(m.struct.getLinesList())
		foo = raw_input("Press enter to exit")
	if not checkCriteria(m,p,debugPrint=debugPrint):
		return 'NULL'
	actuatorDisplacement = m.moveAllActuators(ltinit,lcinit,rtinit,rcinit)
	m.computeLocations()
	if not checkCriteria(m,p):
		return 'NULL'
	moveDistance = math.fabs(m.getFootReferencePoint('l').x - m.getFootReferencePoint('r').x)
	minHeight = m.getCockpitReferencePoint().y - m.getFootReferencePoint('r').y
	resDict = {}
	resDict['moveDistance'] = moveDistance
	resDict['actuatorDisplacement'] = actuatorDisplacement
	resDict['efficency'] = moveDistance/actuatorDisplacement
	resDict['minHeight'] = minHeight
	resDict['vars'] = [rtinit,rcinit,ltinit,lcinit]  	
	return [resDict['efficency'],resDict]
def displayMech_basic(result):
	m = mech()
	rtinit = result[1]['vars'][0]
	rcinit = result[1]['vars'][1]
	ltinit = result[1]['vars'][2]
	lcinit = result[1]['vars'][3]
	m.moveAllActuators(rtinit,rcinit,ltinit,lcinit)
	m.computeLocations()
	disp=structureDisplay()
	disp.displayLines_animate(m.struct)		
def displayMech_walking(result):
	m = mech()
	rtinit = result[1]['vars'][0]
	rcinit = result[1]['vars'][1]
	ltinit = result[1]['vars'][2]
	lcinit = result[1]['vars'][3]
	lc1 = result[1]['vars'][4]
	rt2 = result[1]['vars'][5]
	rc3 = result[1]['vars'][6]
	lt4 = result[1]['vars'][7]
	lc6 = result[1]['vars'][8]	
	lta = m.leftThighActuator
	rta = m.rightThighActuator
	lca = m.leftCalfActuator
	rca = m.rightCalfActuator
	#m.moveAllActuators(result[1]['vars'][0],result[1]['vars'][1],result[1]['vars'][2],result[1]['vars'][3])
	#m.computeLocations()
	disp=structureDisplay()
	commands = []
	commands.append([lta,ltinit,0])
	commands.append([rta,rtinit,0])
	commands.append([lca,lcinit,0])
	commands.append([rca,rcinit,0])
	commands.append([lca,lc1,10])
	commands.append([rta,rt2,10])
	commands.append([rca,rc3,10])
	commands.append([lta,lt4,10])
	commands.append([lta,rtinit,10])
	commands.append([lca,lc6,10])
	commands.append([lca,rcinit,10])
	commands.append([rca,lcinit,10])
	commands.append([rta,ltinit,10])
	#New step
	commands.append([rca,lc1,10])
	commands.append([lta,rt2,10])
	commands.append([lca,rc3,10])
	commands.append([rta,lt4,10])
	commands.append([rta,rtinit,10])
	commands.append([rca,lc6,10])
	commands.append([rca,rcinit,10])
	commands.append([lca,lcinit,10])
	commands.append([lta,ltinit,10])
	disp.displayLines_sequence(m.struct,commands,save=True)	
	#disp.displayLines_animate(m.struct.getLinesList())
	foo = raw_input("Press enter to exit")
示例#4
0
		p = False
	if p:	
		print "Passed tests"

if __name__ == '__main__':
	import sys
	if(len(sys.argv) > 1):
		ar = sys.argv[1]
		if(ar == '-t'):
			test_software()
			sys.exit()
		elif(ar == '-ts'):
			test_software(short=True)
			sys.exit()
		elif(ar == '-td'):
			disp = structureDisplay()	
			structure = test_structureSeed_pyramid()	
			structure.computeLocations()
			disp.displayLines_animate(structure,save=False)
			#disp.displayLines(structure.getLinesList())
		elif(ar == '-rs'): #RUN SIMULATION
			findOptimumMechWalk()		
		elif(ar == '-rf'):
			m = mech(part='foot')
			m.computeLocations()
			ma = m.struct.getCenterOfMass()
			print ma.toString()
			disp = structureDisplay()
			disp.displayLines_animate(m.struct,save=False)		
		elif(ar == '-rl'):
			m = mech(part='leg')