Start ellipsoid class

This commit is contained in:
30hours 2024-02-19 09:27:05 +00:00
parent 2bc28f18cf
commit 7b7758e3ec
4 changed files with 66 additions and 13 deletions

View file

@ -30,7 +30,7 @@ associators = [
# {"name": "Ellipsoid Parametric (Arc Length)", "id": "ellipsoid-parametric-arc"} # {"name": "Ellipsoid Parametric (Arc Length)", "id": "ellipsoid-parametric-arc"}
# ] # ]
coordregs = [ coordregs = [
{"name": "Ellipse Parametric", "id": "ellipse-parametric"} {"name": "Ellipsoid Parametric", "id": "ellipsoid-parametric"}
] ]
adsbs = [ adsbs = [

View file

@ -1,13 +1,15 @@
""" """
@file EllipseParametric.py @file EllipsoidParametric.py
@author 30hours @author 30hours
""" """
class EllipseParametric: from data.Ellipsoid import Ellipsoid
class EllipsoidParametric:
""" """
@class EllipseParametric @class EllipsoidParametric
@brief A class for intersecting ellipses using a parametric approx. @brief A class for intersecting ellipsoids using a parametric approx.
@details Uses associated detections from multiple radars. @details Uses associated detections from multiple radars.
@see blah2 at https://github.com/30hours/blah2. @see blah2 at https://github.com/30hours/blah2.
""" """
@ -15,14 +17,14 @@ class EllipseParametric:
def __init__(self): def __init__(self):
""" """
@brief Constructor for the EllipseParametric class. @brief Constructor for the EllipsoidParametric class.
""" """
def process(self, assoc_detections, radar_data): def process(self, assoc_detections, radar_data):
""" """
@brief Perform coord registration using the ellipse parametric method. @brief Perform coord registration using the ellipsoid parametric method.
@details Generate a (non arc-length) parametric ellipse for each node. @details Generate a (non arc-length) parametric ellipsoid for each node.
Find Find
@param radar_detections (str): JSON of blah2 radar detections. @param radar_detections (str): JSON of blah2 radar detections.
@param adsb_detections (str): JSON of adsb2dd truth detections. @param adsb_detections (str): JSON of adsb2dd truth detections.
@ -32,5 +34,4 @@ class EllipseParametric:
output = {} output = {}
return output return output

52
event/data/Ellipsoid.py Normal file
View file

@ -0,0 +1,52 @@
"""
@file Ellipsoid.py
@author 30hours
"""
import math
class Ellipsoid:
"""
@class Ellipsoid
@brief A class to store ellipsoid parameters for bistatic radar.
@details Stores foci, midpoint, pitch, yaw and distance.
Able to generate samples through public functions.
"""
def __init__(self, f1, f2, name):
"""
@brief Constructor for the Ellipsoid class.
"""
self.f1 = f1
self.f2 = f2
self.name = name
self.midpoint = [(f1[0]+f2[0])/2,
(f1[1]+f2[1])/2, (f1[2]+f2[2])/2]
vector = (f2[0]-f1[0], f2[1]-f1[1], f2[2]-f1[2])
self.yaw = math.atan2(vector[1], vector[0])
self.pitch = math.atan2(vector[2],
math.sqrt(vector[0]**2 + vector[1]**2))
self.distance = math.sqrt(
(f2[0] - f1[0])**2 +
(f2[1] - f1[1])**2 +
(f2[2] - f1[2])**2)
def process(self, bistatic_range):
"""
@brief Perform coord registration using the ellipsoid parametric method.
@details Generate a (non arc-length) parametric ellipsoid for each node.
Find
@param radar_detections (str): JSON of blah2 radar detections.
@param adsb_detections (str): JSON of adsb2dd truth detections.
@return str: JSON of associated detections.
"""
output = {}
return output

View file

@ -14,7 +14,7 @@ import json
import hashlib import hashlib
from algorithm.associator.AdsbAssociator import AdsbAssociator from algorithm.associator.AdsbAssociator import AdsbAssociator
from algorithm.coordreg.EllipseParametric import EllipseParametric from algorithm.coordreg.EllipsoidParametric import EllipsoidParametric
from common.Message import Message from common.Message import Message
# init event loop # init event loop
@ -23,7 +23,7 @@ api = []
# init config # init config
tDelete = 60 tDelete = 60
adsbAssociator = AdsbAssociator() adsbAssociator = AdsbAssociator()
ellipseParametric = EllipseParametric() ellipsoidParametric = EllipsoidParametric()
async def event(): async def event():
@ -92,8 +92,8 @@ async def event():
return return
# coord reg selection # coord reg selection
if item["coordreg"] == "ellipse-parametric": if item["coordreg"] == "ellipsoid-parametric":
coordreg = ellipseParametric coordreg = ellipsoidParametric
else: else:
print("Error: Coord reg invalid.") print("Error: Coord reg invalid.")
return return