The spaceship class describes the parameters of the spaceship and handle the position calculation. It posesses the real position x, y and z and the velocity vx, vy and vz. It also has the boardcomputer, which manages the Kalman Filter model. It uses the numpy-library of python and Kinematic Library.
- Spaceship class
- 1. Variables
- 2. Methods
- def init(self, position: list = [0, 0, 0], mass: int = 1000, boosterforce: list = [[100, 100], [100, 100], [100, 100]], velocity: list = [0, 0, 0], boosterforceDev: list = [10.3, 10.3, 10.3], nPredict: int = 10, deltaT: float = 0.1):
- Getter/Setter
- def setPosition(self, position):
- def getPositionList(self):
- def getPosition(self):
- def setVelocity(self, velocity):
- def getVelocityList(self):
- def getVelocity(self):
- def setMass(self, mass):
- def getMass(self):
- def setBoosterforce(self, boosterforce):
- def getBoosterforce(self):
- def getAcceleration(self, dims):
- def setBoosterforceDeviation(self, var):
- def getBoosterforceDeviation(self):
- def getBoosterforceDeviationList(self):
- def setDeltaT(self, var):
- def getDeltaT(self):
- def setNPrediction(self, val):
- def getNPrediction(self):
- def getMeasurePoint(self):
- def getMeasurePointList(self):
- def getPrediction(self):
- def getDeviation(self):
- Calculation methods
- 3. Tests
Position
Velocity
The parameters for the boosterforce are split into the positive and negative direction of of a dimension. Their values are absolute values!
Boosterforce
Boosterforce deviation
It will be soon changed to
to make it dimension direction dependend
Mass
The acceleration can by calculated by
For input purposes:
boardcomputer is a own class for managing the predictions, its deviations and also the Kalman Filter update and prediction process.
def init(self, position: list = [0, 0, 0], mass: int = 1000, boosterforce: list = [[100, 100], [100, 100], [100, 100]], velocity: list = [0, 0, 0], boosterforceDev: list = [10.3, 10.3, 10.3], nPredict: int = 10, deltaT: float = 0.1):
Initilize the variables of the spaceship. nPredict and deltaT are for the boardcomputer.
Set/Returns the position of the spaceship. Input: 2d python list [[val], [val], [val]]. Returns either as numpy array of as python list.
Set/Returns the position of the spaceship. Input: 2d python list [[val], [val], [val]]. Returns either as numpy array of python list.
Set/Returns the mass of the spaceship.
Set/Returns the position of the spaceship. Input: 2d python list [[val, val], [val, val], [val, val]]. Returns either as numpy array.
Returns the acceleration for each dimension(x/y/z) dependen from the entry (+/-/else) in dims.
Set/Returns vector of deviation of boosterforce. Input: 2d python list [[val], [val], [val]]. Returns either as python list of numpy array.
Set/returns the time step for the predictions from boardcomputer.
Set and returns the number of predictions. Transmitt it to boardcomputer. See doc to boardcomputer.
Returns the transmitted position to the boardcomputer for the update step either as numpy array or python list.
Returns the list of predictions or their deviation to each prediction from the boardcomputer.
Calculate and update spaceship position and velocity for each dimenstion x, y and z. Inputs: time as float and dim as 1d python list [val, val, val]. It uses the Kinematic Library for it.
Send command to boardcomputer to calculate next prediction or recalculate all predictions.
Send update command to boardcomputer. Updates Kalman Filter and state space model. Inputs: dims as 1d python list [val, val, val] and measurment deviation as 1d python list [val, val, val]. Applies the deviation with gauss function of numpy to real position and send it with the deviation and the current acceleration and its deviation to the boardcomputer to update and predict.
Tests are appended but outdated. Focus of the tests was the boardcomputer and its Kalman Filter and state space model.