mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/SPATZ.git
synced 2025-06-10 01:55:59 +00:00
Current state of the simulation
This commit is contained in:
parent
828af75fe3
commit
dedd445470
2
setup.py
2
setup.py
@ -8,7 +8,7 @@ with open('README.md', 'r') as f:
|
||||
setup(
|
||||
name='spatz',
|
||||
version='0.0.10',
|
||||
packages=find_packages(exclude=["_tests"]),
|
||||
packages=['spatz'],
|
||||
long_description=longdescription,
|
||||
long_description_content_type='text/markdown',
|
||||
)
|
@ -1,10 +1,12 @@
|
||||
import numpy as np
|
||||
|
||||
from typing import List, AnyStr
|
||||
|
||||
from numpy.typing import ArrayLike
|
||||
from spatz.dataset import ArrayLike, Dataset
|
||||
from spatz.logger import ArrayLike, Logger
|
||||
from spatz.sensors import IMU, Accelerometer, Gyroscope
|
||||
from spatz.transforms import Transform
|
||||
from spatz.transforms import Transform, GaussianNoise
|
||||
|
||||
|
||||
class BHI160Gyro(Gyroscope):
|
||||
@ -27,8 +29,10 @@ class BHI160Acc(Accelerometer):
|
||||
def __init__(self, dataset: Dataset, logger: Logger, offset: float = 0, transforms: List[Transform] = []):
|
||||
super().__init__(dataset, logger, offset, transforms)
|
||||
|
||||
self.__noise = GaussianNoise(0, 0.05)
|
||||
|
||||
def _get_name(self) -> AnyStr:
|
||||
return 'BHI160'
|
||||
|
||||
def _sensor_specific_effects(self, x: ArrayLike) -> ArrayLike:
|
||||
return x
|
||||
return self.__noise(0, x)
|
@ -13,15 +13,25 @@ class GaussianNoise(Transform):
|
||||
self.__mu = mu
|
||||
self.__sigma = sigma
|
||||
|
||||
def __call__(self, t: float, x: ArrayLike) -> ArrayLike:
|
||||
assert np.shape(self.__mu) == np.shape(x), "Mu and x have to match in shape."
|
||||
|
||||
def __call__(self, _: float, x: ArrayLike) -> ArrayLike:
|
||||
if np.isscalar(x):
|
||||
noise = np.random.normal(0, 1)
|
||||
x += self.__sigma * noise + self.__mu
|
||||
else:
|
||||
dim = len(x)
|
||||
|
||||
if np.isscalar(self.__sigma):
|
||||
sigma = np.identity(dim) * self.__sigma
|
||||
else:
|
||||
sigma = self.__sigma
|
||||
|
||||
if np.isscalar(self.__mu):
|
||||
mu = np.ones(dim)
|
||||
else:
|
||||
mu = self.__mu
|
||||
|
||||
noise = np.random.normal(0, 1, np.shape(x))
|
||||
x += self.__sigma @ noise + self.__mu
|
||||
x += sigma @ noise + mu
|
||||
|
||||
return x
|
||||
|
||||
|
36
tests.ipynb
36
tests.ipynb
@ -631,7 +631,7 @@
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"[<matplotlib.lines.Line2D at 0x24cf15adfa0>]"
|
||||
"[<matplotlib.lines.Line2D at 0x28b3b18fc20>]"
|
||||
]
|
||||
},
|
||||
"execution_count": 13,
|
||||
@ -819,7 +819,27 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"execution_count": 22,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"7.767031884916352"
|
||||
]
|
||||
},
|
||||
"execution_count": 22,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"max(np.array(acc_total) / g)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -839,7 +859,7 @@
|
||||
"Name: altitude, Length: 1721, dtype: float64"
|
||||
]
|
||||
},
|
||||
"execution_count": 16,
|
||||
"execution_count": 17,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@ -850,7 +870,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"execution_count": 18,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -859,7 +879,7 @@
|
||||
"19335.3982925117"
|
||||
]
|
||||
},
|
||||
"execution_count": 17,
|
||||
"execution_count": 18,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@ -870,7 +890,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 18,
|
||||
"execution_count": 19,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -890,7 +910,7 @@
|
||||
"Name: Time, Length: 1721, dtype: float64"
|
||||
]
|
||||
},
|
||||
"execution_count": 18,
|
||||
"execution_count": 19,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@ -901,7 +921,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 19,
|
||||
"execution_count": 20,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
|
Loading…
x
Reference in New Issue
Block a user