Esempio n. 1
0
	def __init__(self,name, sim,G,driver=None, pos=[0,0], mass=None, direction=pi/2., shape=None):
		"""
		initializes the machine.
		If the shape parameter is given it has information about the nodes in relation to the center (pos) of the machine.
		Convenient way of handling the colission detection, but not really needed.
		"""
		Process.__init__(self, name, sim)
		self.pos=pos
		self.G=G
		self.mass=21000
		self.direction=direction #the direction of the machine.
		self.color='y'
		self.velocities={'machine':1} #implement in subclass
		self.times={} # implement in subclass
		self.visited=[]
		self.sim.machines.append(self) #adds to global list of machines..
		self.moveEvent=None #could be signaled if needed, nbut omit as default to save time
		if isinstance(self, UsesDriver): #if machine inherits from driver, default is no.
			if not driver: raise Exception('Error: Machine %s uses driver, but no driver was given to MAchine.__init__.'%self.name)
			UsesDriver.__init__(self,driver)
		#the shape of the machine:
		if not shape: #default.. 
			x=1.5
			y=1.5
			self.shape=[[-x, y], [-x, -y], [x, -y], [x, y]]
		else:
			self.shape=shape
		#find the bounding radius
		self.radius=0
		for node in self.shape:
			c=self.getCartesian(node, fromLocalCart=True)
			d=getDistance(c, self.pos)
			if d>self.radius:
				self.radius=d
		Obstacle.__init__(self,pos, isSpherical=False, radius=self.radius)
Esempio n. 2
0
 def __init__(self, name, sim, PD):
     PlantHead.__init__(self, name, sim, PD)
     self.length = 0.4  # i.e length of "tracks"
     if self.p.G.PMbladeWidth:
         self.width = self.p.G.PMbladeWidth
     else:
         self.width = 0.4  # default
     self.depth = 0.2
     Obstacle.__init__(
         self,
         [0, 0],
         isSpherical=False,
         radius=sqrt((self.width / 2.0) ** 2 + (self.length / 2.0) ** 2),
         terrain=PD.G.terrain,
     )
Esempio n. 3
0
	def __init__(self, name, sim, belongToMachine,G):
		Process.__init__(self, name, sim)
		UsesDriver.__init__(self, belongToMachine.driver)
		Obstacle.__init__(self, [0,0], isSpherical=False, terrain=G.terrain)
		self.m=belongToMachine
		self.G=G
		#cylindrical coordinates in relation to machine:
		#crane starts in its minimum position to the left of the driver.
		#algorithms for planting:
		self.noMoreSpots=False #used to cancel the search for new spots
		self.idealSpots=[]
		self.pSpots=[]
		self.plantHeads=[]
		self.otherDevice = None #defined later if 2a
		self.struckLastTime=False
		self.timeConsumption={'crane movement':0}
		self.moveEvent=SimEvent(name='planthead moves', sim=self.sim)
		if len(self.m.pDevs)==0: #first arm, right, could also be 1a
			self.mountPoint='right'	
		elif len(self.m.pDevs)==1:
			self.mountPoint='left'
		else:
			raise Exception("ERROR: cannot mount more than two planting devices to machine.%f"%len(self.m.pDevs))
		if self.m.headType=='Mplanter':
			self.plantSepDist=self.G.PMplantSepDist
			for lr in ["left", "right"]:
				h=Mplanter(self.name+"_"+lr+"_head", self.sim, PD=self,leftRight=lr)
				self.sim.activate(h,h.run())
				self.plantHeads.append(h)
				self.plantAreaW=self.plantSepDist+h.width
		elif self.m.headType=='Bracke':
			h=Bracke(self.name+"_"+"brackeHead", self.sim, PD=self)
			self.sim.activate(h, h.run())
			self.plantHeads.append(h)
			self.plantAreaW=h.width
		else:
			raise Exception('Headtype not supported: %s'%str(self.headType))
		self.plantAreaL=2*h.length
		self.radius=0.5*sqrt(self.plantAreaW**2+self.plantAreaL**2) #needed for plantingdevice to be regarded as obst.
		#define the optimal nodes:
		self.initOpt()
		self.setPos(self.optNodes[0])
		self.optNode=0
		self.autoMoved=True
		self.sim.machines.append(self)
		self.pSpots.append(self.pos)
		self.plantSignals=0
Esempio n. 4
0
	def __init__(self, name, sim, belongToMachine,G):
		Process.__init__(self, name, sim)
		UsesDriver.__init__(self, belongToMachine.driver)
		Obstacle.__init__(self, [0,0], isSpherical=False, terrain=G.terrain)
		self.m=belongToMachine
		self.G=G
		#cylindrical coordinates in relation to machine:
		#crane starts in its minimum position to the left of the driver.
		#algorithms for planting:
		self.noMoreSpots=False #used to cancel the search for new spots
		self.idealSpots=[]
		self.pSpots=[]
		self.plantHeads=[]
		self.otherDevice = None #defined later if 2a
		self.struckLastTime=False
		self.timeConsumption={'crane movement':0}
		self.moveEvent=SimEvent(name='planthead moves', sim=self.sim)
		if len(self.m.pDevs)==0: #first arm, right, could also be 1a
			self.mountPoint='right'	
		elif len(self.m.pDevs)==1:
			self.mountPoint='left'
		else:
			raise Exception("ERROR: cannot mount more than two planting devices to machine.%f"%len(self.m.pDevs))
		if self.m.headType=='Mplanter':
			self.plantSepDist=2.01 #existing machine, constant parameter
			for no in [0,1]:
				#h=Mplanter(self.name+"_"+str(no)+"_head", self.sim, PD=self,leftRight=lr)
				h=Mplanter(self.name+"_"+str(no)+"_head", self.sim, PD=self,number=no)
				self.sim.activate(h,h.run())
				self.plantHeads.append(h)
			self.plantAreaW=self.plantSepDist+h.width
		elif self.m.headType=='MultiHead':
			self.plantSepDist=self.G.simParam['dibbleDist'] #1m by default
			if '3h' in self.m.type:
				no=3
			elif '4h' in self.m.type:
				no=4
			else:
				raise Exception('3 or 4 heads are supported, not more or less, %s'%str(self.m.type))
			for i in range(no):
				h=MultiHead(self.name+"_"+str(i+1)+"_head", self.sim, PD=self,number=i)
				self.sim.activate(h,h.run())
				self.plantHeads.append(h)
			self.plantAreaW=(no-1)*self.plantSepDist+h.width #2*h.width/2..both sides..
		elif self.m.headType=='Bracke':
			h=Bracke(self.name+"_"+"brackeHead", self.sim, PD=self)
			self.sim.activate(h, h.run())
			self.plantHeads.append(h)
			self.plantAreaW=h.width
		else:
			raise Exception('Headtype not supported: %s'%str(self.m.headType))
		self.plantAreaL=2*h.length
		self.radius=0.5*sqrt(self.plantAreaW**2+self.plantAreaL**2) #needed for plantingdevice to be regarded as obst.
		#define the optimal nodes:
		self.initOpt()
		self.setPos(self.optNodes[0])
		self.optNode=0
		self.autoMoved=True
		self.sim.machines.append(self)
		self.pSpots.append(self.pos)
		self.plantSignals=0
Esempio n. 5
0
	def __init__(self, name, sim, PD, number,width=0.4):
		PlantHead.__init__(self,name, sim, PD, width)
		self.number=number
		Obstacle.__init__(self, [0,0], isSpherical=False, radius=sqrt((self.width/2.)**2+(self.length/2.)**2), terrain=PD.G.terrain)
		self.color=['y','r','g','b'][self.number]