Traffic - ilabs-kdc/bluesky GitHub Wiki
The traffic folder contains python files which perform all the calculation related to the aircraft. The most important python file is traffic.py. This file contains the Traffic
class, which is a child class of the Entity
class. In this way, it is possible to create arrays and lists that grow and shrink when aircraft are created and deleted. Some important methods are explained below:
__init__(self)
: To create arrays and lists which adjust their length with the number of aircraft, theself.settrafarrays()
method is used:
...
with self.settrafarrays():
self.id = []
...
self.lat = np.array([])
...
reset(self)
: This method is called when the simulation is reset. To reset all the traffic arrays and lists, the statementsuper().reset()
is used.cre(self, ...)
: This method is called when you create an aircraft. The statementsuper().create(n)
is used to expand the traffic arrays and lists withn
.delete(self, idx)
: This method is called when you delete an aircraft. The statementsuper().delete(idx)
is used to take out the elements with indexidx
for all traffic arrays and lists.update(self)
: Every simulation step, this method is called. This updates all the traffic related parameters (e.g. speed, position, ... etc.).