mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/SPATZ.git
synced 2025-06-10 18:15:59 +00:00
Added first simple GPS implementation
This commit is contained in:
parent
751887e6d8
commit
33e5eba3a6
18
demo.ipynb
18
demo.ipynb
@ -88,12 +88,16 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"from spatz.sensors.imu.wsen_isds import WSEN_ISDS_ACC, WSEN_ISDS_GYRO\n",
|
"from spatz.sensors.imu.wsen_isds import WSEN_ISDS_ACC, WSEN_ISDS_GYRO\n",
|
||||||
"from spatz.sensors.pressure.ms5611_01ba03 import MS5611_01BA03\n",
|
"from spatz.sensors.pressure.ms5611_01ba03 import MS5611_01BA03\n",
|
||||||
|
"from spatz.sensors.gps.erinome1 import Erinome_I\n",
|
||||||
"\n",
|
"\n",
|
||||||
"press_sensor = simulation.add_sensor(MS5611_01BA03)\n",
|
"press_sensor = simulation.add_sensor(MS5611_01BA03)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# Use the offset argument to change the position of the imu in relation to the rocket's center of gravity.\n",
|
"# Use the offset argument to change the position of the imu in relation to the rocket's center of gravity.\n",
|
||||||
"accelerometer = simulation.add_sensor(WSEN_ISDS_ACC, offset=0)\n",
|
"accelerometer = simulation.add_sensor(WSEN_ISDS_ACC, offset=0)\n",
|
||||||
"gyro = simulation.add_sensor(WSEN_ISDS_GYRO, offset=0)"
|
"gyro = simulation.add_sensor(WSEN_ISDS_GYRO, offset=0)\n",
|
||||||
|
"\n",
|
||||||
|
"# Add a GPS module to the simulation which returns the following data: [latitude, longitude, altitude (km)]\n",
|
||||||
|
"gps_module = simulation.add_sensor(Erinome_I)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -171,10 +175,6 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"from spatz.metrics import Metric\n",
|
|
||||||
"\n",
|
|
||||||
"metric = Metric()\n",
|
|
||||||
"\n",
|
|
||||||
"logger = simulation.get_logger()\n",
|
"logger = simulation.get_logger()\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# Set verbose to False to disable the progress bar\n",
|
"# Set verbose to False to disable the progress bar\n",
|
||||||
@ -183,16 +183,12 @@
|
|||||||
" press = press_sensor()\n",
|
" press = press_sensor()\n",
|
||||||
" acc = accelerometer()\n",
|
" acc = accelerometer()\n",
|
||||||
" rot_rate = gyro()\n",
|
" rot_rate = gyro()\n",
|
||||||
|
" gps = gps_module()\n",
|
||||||
"\n",
|
"\n",
|
||||||
" # Get the correct altitude data.\n",
|
" # Get the correct altitude data.\n",
|
||||||
" alt = altitude()\n",
|
" alt = altitude()\n",
|
||||||
"\n",
|
"\n",
|
||||||
" pred_alt = ...\n",
|
" # TODO: Add your computation here."
|
||||||
" metric(alt, pred_alt)\n",
|
|
||||||
"\n",
|
|
||||||
" # TODO: Add your computation here.\n",
|
|
||||||
"\n",
|
|
||||||
"print('Score was:', metric.get_score())"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
17
spatz/sensors/gps/erinome1.py
Normal file
17
spatz/sensors/gps/erinome1.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
from typing import List
|
||||||
|
|
||||||
|
from numpy.typing import ArrayLike
|
||||||
|
from sensors.gps import GPS
|
||||||
|
from spatz.dataset import ArrayLike, Dataset
|
||||||
|
from spatz.logger import ArrayLike, Logger
|
||||||
|
from spatz.transforms import Transform
|
||||||
|
|
||||||
|
|
||||||
|
class Erinome_I(GPS):
|
||||||
|
def __init__(self, dataset: Dataset, logger: Logger, transforms: List[Transform] = []):
|
||||||
|
super().__init__(dataset, logger, transforms)
|
||||||
|
|
||||||
|
def _sensor_specific_effects(self, x: ArrayLike) -> ArrayLike:
|
||||||
|
# TODO: What's the GPS module's behavior?
|
||||||
|
|
||||||
|
return x
|
33
spatz/sensors/gps/gps.py
Normal file
33
spatz/sensors/gps/gps.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
from typing import Any, List
|
||||||
|
from numpy.linalg import norm
|
||||||
|
|
||||||
|
from numpy.typing import ArrayLike
|
||||||
|
from spatz.dataset import ArrayLike, Dataset
|
||||||
|
from spatz.logger import ArrayLike, Logger
|
||||||
|
from spatz.sensors import Sensor, NA
|
||||||
|
from spatz.transforms import Transform
|
||||||
|
|
||||||
|
# WG84 googlen (world model GPS)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class GPS(Sensor):
|
||||||
|
def __init__(self, dataset: Dataset, logger: Logger, transforms: List[Transform] = []):
|
||||||
|
"""GPS Module which provides the following information:
|
||||||
|
- Longitude (in °)
|
||||||
|
- Latitiude (in °)
|
||||||
|
- Altitude (in °)
|
||||||
|
"""
|
||||||
|
super().__init__(dataset, logger, transforms)
|
||||||
|
|
||||||
|
def _get_data(self) -> ArrayLike:
|
||||||
|
vel = norm(self._dataset.get_velocity())
|
||||||
|
|
||||||
|
# TODO: At which speed do we assume that GPS becomes unreliable?
|
||||||
|
if vel / self._dataset.get_mach_number() > 1:
|
||||||
|
return NA
|
||||||
|
|
||||||
|
x = self._dataset.fetch_values(['latitude', 'longitude', 'altitude'])
|
||||||
|
x = self._sensor_specific_effects(x)
|
||||||
|
|
||||||
|
return x
|
Loading…
x
Reference in New Issue
Block a user