def __init__(self, parameters=None): if parameters is None: for i in xrange(len(self.theta)): self.legs[i] = leg(self.theta[i], self.alpha, self.radius, self.displacement) else: for i in xrange(len(parameters[0])): self.legs[i] = leg(parameters[0][i], parameters[1], parameters[2], parameters[3]) self.updateTrig()
def __init__(self, params): #stash params self.position = params.position self.yaw = params.yaw self.pitch = params.pitch self.roll = params.roll self.alpha = params.alpha self.radius = params.radius self.displacement = params.displacement self.angleRange = params.angleRange self.legThetas = params.legThetas self.legAlphas = params.legAlphas self.legRadii = params.legRadii self.legDisps = params.legDisps #Initialize one-time calculable stuff self.transformMat = generateTransformMat(self.yaw, self.pitch, self.roll, self.position) self.inverseTransformMat = np.linalg.inv(self.transformMat) for i in xrange(len(self.legs)): self.legs[i] = leg(self.alpha[i], self.radius[i], self.displacement[i], self.angleRange[i]) self.legDHMats[i] = generateDHMat(self.legThetas[i],self.legAlphas[i],self.legRadii[i],self.legDisps[i]) self.inverseLegDHMats[i] = np.linalg.inv(self.legDHMats[i])
def __init__(self,con): self.con = con self.RF = leg(con,'rightFront',24,25,26) self.RM = leg(con,'rightMid',20,21,22) self.RB = leg(con,'rightBack',16,17,18) self.LF = leg(con,'leftFront',7,6,5) self.LM = leg(con,'leftMid',11,10,9) self.LB = leg(con,'leftBack',15,14,13) self.legs = [ self.RF, self.RM, self.RB, self.LF, self.LM, self.LB] self.neck = neck(con,31) self.tripod1 = [self.RF,self.RB,self.LM] self.tripod2 = [self.LF,self.LB,self.RM]
from leg import * from math import pi theta = [0, 0, 0, pi/2] alpha = [0, pi/2, 0, 0] radius = [1., .5, 1.5, 2] displacement = [0,0,0,0] l1 = leg(theta, alpha, radius, displacement) print l1.move(theta) print l1.getAllJoints(theta)
from leg import * from math import pi theta = [0, 0, 0, pi / 2] alpha = [0, pi / 2, 0, 0] radius = [1., .5, 1.5, 2] displacement = [0, 0, 0, 0] l1 = leg(theta, alpha, radius, displacement) print l1.move(theta) print l1.getAllJoints(theta)
radius = [1.0, 0.5, 1.5, 2] displacement = [-0.5, 0, 0, 0] theta = [ [0, pi / 6, pi / 4, -pi / 2], [pi / 3, 0, pi / 4, -pi / 2], [2 * pi / 3, -pi / 6, pi / 4, -pi / 2], [pi, pi / 6, pi / 4, -pi / 2], [4 * pi / 3, 0, pi / 4, -pi / 2], [5 * pi / 3, -pi / 6, pi / 4, -pi / 2], ] legs = [None] * 6 for i in xrange(len(theta)): legs[i] = leg(theta[i], alpha, radius, displacement) X = [] Y = [] Z = [] def plotLeg(ax, points): X = [point[0] for point in points] Y = [point[1] for point in points] Z = [point[2] for point in points] for i in range(len(points) - 1): ax.plot([X[i], X[i + 1]], [Y[i], Y[i + 1]], [Z[i], Z[i + 1]]) return (X, Y, Z)
def __init__(self): ''' Initialise parameters ''' scale = 1 self.m_body = 382*scale; self.m_inv = 1/self.m_body self.m = [0.,1.,1.,1.,1.] self.m[1:] = self.muscMasses() # Set masses of parts from Hutchinson's %s self.L_femur = 565*scale self.L_tibia = 505*scale self.L_tarsa = 300*scale self.L_foot = 380*scale self.w_hips = 200*scale self.base = np.array([[0, 0], [0, 0], [0, -9.81]]) self.CoM = [50, 0] self.resetAngles() self.forces = np.matrix(ml.repmat(np.zeros([3,1]), 1, 5)) self.torques = np.matrix(ml.repmat(np.zeros([3,1]), 1, 5)) self.toe_oldx = 0 ''' DH params ''' alpha = np.array([0, 0, 0, 0, 0]) a = np.array([0, self.L_femur, self.L_tibia, self.L_tarsa, self.L_foot]) d = np.array([0,0,0,0,0]) self.dh = np.array([alpha, a, d]) ''' GA params ''' #self.amp = self.t0s = [0,0,0,0] self.tas = [0,0,0,0] self.tTs = [0,0,0,0] self.popsize = 40 self.population = np.zeros([self.popsize,3,4]) self.parents = np.zeros([2,3,4]) self.seed = rd.randint(0,10000) self.fitnesses = np.zeros([self.popsize,1]) self.fittotal = 0 self.fitinhand = -99999 self.inhand = 0 self.generate_population() self.SL = 0 ''' pyBullet params ''' self.T_fixed = 1./240 ''' Hold last angle for numerical differentiation ''' ''' First is last held angle, second is ang velocity ''' self.w1 = [0, 0]; self.w1 = [0, 0]; self.w3 = [0, 0]; self.w4 = [0, 0] self.dyn() # Keep me last! self.leg_l = leg(); self.leg_l.test(3) self.leg_r = leg(); self.leg_r.test(3)
"H_star": "charged scalar", "S1": "charged scalar", "S1_star": "charged scalar", "S2": "charged scalar", "S2_star": "charged scalar" } GRAPHS = ET.parse(INPUT) DIAGRAMS = GRAPHS.find("diagrams") file = open("diagrams.tex", "w+") for diagram in list(DIAGRAMS): DiagID = diagram.find("id").text print("Doing diagram: " + DiagID) file.write(DiagID + "~\\feynmandiagram[]{\n") NOpropagators = list(diagram.find("propagators")) LegsSort = itemSort(diagram.find("legs"), "vertex") NOlegs = list(LegsSort) propagators = [] for p in NOpropagators: propagators.append(propagator(p)) for p in propagators: p.texprint(file, pt) legs = [] for l in NOlegs: legs.append(leg(l)) for l in legs: l.texprint(file, pt) file.write("};\n") file.write("\n")