Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import animation
import templates
import agent
import motorPrimitive
class Simulation:
"This is the simulation class. A simulation is an object that specifies parameters for the simulation."
timeLength = 100 # 100
timeStep = 0.1 # 0.1
# INITIALIZE SIMULATION'S TIME-LENGTH,TIME-STEP
def __init__(self,timeLength, timeStep):
self.timeLength = timeLength
self.timeStep = timeStep
# SET PARAMETERS FOR X,Y AND PHI VALUES & POPULATE X,Y,PHI ARRAYS FOR SIMULATION ---------------
def populate_xyphi(MotorPrimitive,f,t):
for i in range(0,len(t)-1):
MotorPrimitive.phi[i+1] = MotorPrimitive.phi[i] + MotorPrimitive.velocity*MotorPrimitive.gain*MotorPrimitive.timeStep*f(t[i], MotorPrimitive.phi[i])
MotorPrimitive.x[i+1] = MotorPrimitive.x[i] + np.sin(MotorPrimitive.phi[i])*MotorPrimitive.timeStep
MotorPrimitive.y[i+1] = MotorPrimitive.y[i] + np.cos(MotorPrimitive.phi[i])*MotorPrimitive.timeStep
return MotorPrimitive.x,MotorPrimitive.y,MotorPrimitive.phi