Plot ellipsoids properly

This commit is contained in:
30hours 2024-03-03 13:22:49 +00:00
parent 5b22ccdebd
commit 56439cbaf0
3 changed files with 31 additions and 29 deletions

View file

@ -11,11 +11,20 @@ function event_ellipsoid() {
return response.json();
})
.then(data => {
if (Object.keys(data["ellipsoids"]).length !== 0) {
console.log('remove');
removeEntitiesByType("ellipsoids");
}
else {
removeEntitiesOlderThanAndFade("ellipsoids", 30, 0.2);
console.log('fade');
}
for (const key in data["ellipsoids"]) {
if (data["ellipsoids"].hasOwnProperty(key)) {
const points = data["ellipsoids"][key];
removeEntitiesOlderThanAndFade("ellipsoids", 30, 0.2);
console.log(key);
console.log(points);
for (const point in points) {
addPoint(
@ -39,13 +48,13 @@ function event_ellipsoid() {
})
.finally(() => {
// Schedule the next fetch after a delay (e.g., 5 seconds)
setTimeout(event_radar, 1000);
setTimeout(event_ellipsoid, 1000);
});
}
var style_ellipsoid = {};
style_ellipsoid.color = 'rgba(0, 0, 255, 0.2)';
style_ellipsoid.color = 'rgba(0, 0, 255, 0.5)';
style_ellipsoid.pointSize = 16;
style_ellipsoid.type = "ellipsoids";
style_ellipsoid.timestamp = Date.now();

View file

@ -75,13 +75,13 @@ class EllipsoidParametric:
radar["radar"]
)
samples = self.sample(ellipsoid, radar["delay"], 20)
samples = self.sample(ellipsoid, radar["delay"]*1000, 20)
target_samples[target][radar["radar"]] = samples
# find close points
radar_keys = list(target_samples[target].keys())
samples_intersect = {key: [] for key in radar_keys}
threshold = 1500
threshold = 200
for i in range(0, len(target_samples[target])-1):
for j in range(i+1, len(target_samples[target])):

View file

@ -108,45 +108,38 @@ async def event():
if associated_dets:
print(associated_dets, flush=True)
if localised_dets:
print(localised_dets, flush=True)
# show ellipsoids of associated detections for 1 target
ellipsoids = {}
for radar in radar_dict.keys():
if associated_dets:
# get first target key
key = next(iter(associated_dets))
ellipsoid_radars = []
for radar in associated_dets[key]:
ellipsoid_radars.append(radar["radar"])
x_tx, y_tx, z_tx = Geometry.lla2ecef(
radar_dict_item[radar]["config"]['location']['tx']['latitude'],
radar_dict_item[radar]["config"]['location']['tx']['longitude'],
radar_dict_item[radar]["config"]['location']['tx']['altitude']
radar_dict_item[radar["radar"]]["config"]['location']['tx']['latitude'],
radar_dict_item[radar["radar"]]["config"]['location']['tx']['longitude'],
radar_dict_item[radar["radar"]]["config"]['location']['tx']['altitude']
)
x_rx, y_rx, z_rx = Geometry.lla2ecef(
radar_dict_item[radar]["config"]['location']['rx']['latitude'],
radar_dict_item[radar]["config"]['location']['rx']['longitude'],
radar_dict_item[radar]["config"]['location']['rx']['altitude']
radar_dict_item[radar["radar"]]["config"]['location']['rx']['latitude'],
radar_dict_item[radar["radar"]]["config"]['location']['rx']['longitude'],
radar_dict_item[radar["radar"]]["config"]['location']['rx']['altitude']
)
ellipsoid = Ellipsoid(
[x_tx, y_tx, z_tx],
[x_rx, y_rx, z_rx],
radar
radar["radar"]
)
bsr = 0
if radar == 'radar4.30hours.dev':
bsr = 12470
if radar == 'radar5.30hours.dev':
bsr = 1870
if radar == 'radar6.30hours.dev':
bsr = 5210
points = ellipsoidParametric.sample(ellipsoid, bsr, 50)
points = ellipsoidParametric.sample(ellipsoid, radar["delay"]*1000, 50)
for i in range(len(points)):
lat, lon, alt = Geometry.ecef2lla(points[i][0], points[i][1], points[i][2])
points[i] = ([round(lat, 3), round(lon, 3), round(alt)])
ellipsoids[radar] = points
ellipsoids[radar["radar"]] = points
# output data to API
item["detections_associated"] = associated_dets
item["detections_localised"] = localised_dets
if ellipsoids:
item["ellipsoids"] = ellipsoids
# delete old API requests