Skip to content

Commit

Permalink
Merge pull request #54 from alireza787b/real-test-1
Browse files Browse the repository at this point in the history
Real test 1
  • Loading branch information
alireza787b authored Nov 2, 2024
2 parents f44c333 + dc47c3f commit e3a8f92
Show file tree
Hide file tree
Showing 308 changed files with 900,681 additions and 17,832 deletions.
7 changes: 7 additions & 0 deletions app/dashboard/drone-dashboard/.env.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# .env file
# REACT_APP_SERVER_URL=http://<SERVER_IP_OR_HOSTNAME>
REACT_APP_SERVER_URL=http://100.84.222.4
REACT_APP_FLASK_PORT=5000
DRONE_APP_FLASK_PORT=7070

GENERATE_SOURCEMAP=false
46 changes: 40 additions & 6 deletions app/dashboard/drone-dashboard/src/components/DronePositionMap.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// app/dashboard/drone-dashboard/src/components/DronePositionMap.js
import React, { useEffect, useState } from 'react';
import '../styles/DronePositionMap.css';
import { MapContainer, TileLayer, Marker, Popup, LayersControl } from 'react-leaflet';
Expand All @@ -22,23 +21,58 @@ const DronePositionMap = ({ originLat, originLon, drones }) => {
const [dronePositions, setDronePositions] = useState([]);

useEffect(() => {
// Helper function to check if a value is a valid number
const isValidNumber = (value) => !isNaN(value) && isFinite(value);

if (originLat && originLon && drones.length > 0) {
const origin = new LatLon(parseFloat(originLat), parseFloat(originLon));
const parsedOriginLat = parseFloat(originLat);
const parsedOriginLon = parseFloat(originLon);

if (!isValidNumber(parsedOriginLat) || !isValidNumber(parsedOriginLon)) {
console.error('Invalid origin coordinates:', { originLat, originLon });
return;
}

const origin = new LatLon(parsedOriginLat, parsedOriginLon);

const positions = drones.map((drone) => {
const x = parseFloat(drone.x);
const y = parseFloat(drone.y);
const distance = Math.sqrt(x * x + y * y);

if (!isValidNumber(x) || !isValidNumber(y)) {
console.error(`Invalid drone coordinates for drone ${drone.hw_id}:`, { x, y });
return null; // Skip this drone
}

const distance = Math.sqrt(x * x + y * y); // Ensure distance is in meters
const bearing = (Math.atan2(y, x) * 180) / Math.PI;
const destination = origin.destinationPoint(distance, bearing);

// Validate distance and bearing
if (!isValidNumber(distance) || !isValidNumber(bearing)) {
console.error(`Invalid distance or bearing for drone ${drone.hw_id}:`, { distance, bearing });
return null; // Skip this drone
}

let destination;
try {
destination = origin.destinationPoint(distance, bearing);
} catch (error) {
console.error(`Error calculating destination for drone ${drone.hw_id}:`, error);
return null; // Skip this drone
}

if (!destination || !isValidNumber(destination.lat) || !isValidNumber(destination.lon)) {
console.error(`Invalid destination coordinates for drone ${drone.hw_id}:`, destination);
return null; // Skip this drone
}

return {
hw_id: drone.hw_id,
pos_id: drone.pos_id,
lat: destination.lat,
lon: destination.lon,
};
});
}).filter(position => position !== null); // Remove any null entries

setDronePositions(positions);
}
Expand Down Expand Up @@ -109,4 +143,4 @@ const DronePositionMap = ({ originLat, originLon, drones }) => {
);
};

export default DronePositionMap;
export default DronePositionMap;
112 changes: 100 additions & 12 deletions config_sitl.csv
Original file line number Diff line number Diff line change
@@ -1,13 +1,101 @@
hw_id,pos_id,x,y,ip,mavlink_port,debug_port,gcs_ip
1,1,-17.5,0.0,172.17.0.3,14551,13541,172.17.0.1
2,2,-10.5,0.0,172.17.0.4,14552,13542,172.17.0.1
3,3,-3.5,0.0,172.17.0.5,14553,13543,172.17.0.1
4,4,3.5,0.0,172.17.0.6,14554,13544,172.17.0.1
5,5,10.5,0.0,172.17.0.7,14555,13545,172.17.0.1
6,6,17.5,0.0,172.17.0.8,14556,13546,172.17.0.1
7,7,7.0,-0.5,172.17.0.9,14557,13547,172.17.0.1
8,8,8.5,-0.5,172.17.0.10,14558,13548,172.17.0.1
9,9,10.0,-0.5,172.17.0.11,14559,13549,172.17.0.1
10,10,11.5,-0.5,172.17.0.12,14560,13550,172.17.0.1
11,11,13.0,-0.5,172.17.0.13,14561,13551,172.17.0.1
12,12,14.5,-0.5,172.17.0.14,14562,13552,172.17.0.1
1,1,-13.5,-13.5,172.18.0.2,14563,13553,172.18.0.1
2,2,-13.5,-10.5,172.18.0.3,14564,13554,172.18.0.1
3,3,-13.5,-7.5,172.18.0.4,14565,13555,172.18.0.1
4,4,-13.5,-4.5,172.18.0.5,14566,13556,172.18.0.1
5,5,-13.5,-1.5,172.18.0.6,14567,13557,172.18.0.1
6,6,-13.5,1.5,172.18.0.7,14568,13558,172.18.0.1
7,7,-13.5,4.5,172.18.0.8,14569,13559,172.18.0.1
8,8,-13.5,7.5,172.18.0.9,14570,13560,172.18.0.1
9,9,-13.5,10.5,172.18.0.10,14571,13561,172.18.0.1
10,10,-13.5,13.5,172.18.0.11,14572,13562,172.18.0.1
11,11,-10.5,-13.5,172.18.0.12,14573,13563,172.18.0.1
12,12,-10.5,-10.5,172.18.0.13,14574,13564,172.18.0.1
13,13,-10.5,-7.5,172.18.0.14,14575,13565,172.18.0.1
14,14,-10.5,-4.5,172.18.0.15,14576,13566,172.18.0.1
15,15,-10.5,-1.5,172.18.0.16,14577,13567,172.18.0.1
16,16,-10.5,1.5,172.18.0.17,14578,13568,172.18.0.1
17,17,-10.5,4.5,172.18.0.18,14579,13569,172.18.0.1
18,18,-10.5,7.5,172.18.0.19,14580,13570,172.18.0.1
19,19,-10.5,10.5,172.18.0.20,14581,13571,172.18.0.1
20,20,-10.5,13.5,172.18.0.21,14582,13572,172.18.0.1
21,21,-7.5,-13.5,172.18.0.22,14583,13573,172.18.0.1
22,22,-7.5,-10.5,172.18.0.23,14584,13574,172.18.0.1
23,23,-7.5,-7.5,172.18.0.24,14585,13575,172.18.0.1
24,24,-7.5,-4.5,172.18.0.25,14586,13576,172.18.0.1
25,25,-7.5,-1.5,172.18.0.26,14587,13577,172.18.0.1
26,26,-7.5,1.5,172.18.0.27,14588,13578,172.18.0.1
27,27,-7.5,4.5,172.18.0.28,14589,13579,172.18.0.1
28,28,-7.5,7.5,172.18.0.29,14590,13580,172.18.0.1
29,29,-7.5,10.5,172.18.0.30,14591,13581,172.18.0.1
30,30,-7.5,13.5,172.18.0.31,14592,13582,172.18.0.1
31,31,-4.5,-13.5,172.18.0.32,14593,13583,172.18.0.1
32,32,-4.5,-10.5,172.18.0.33,14594,13584,172.18.0.1
33,33,-4.5,-7.5,172.18.0.34,14595,13585,172.18.0.1
34,34,-4.5,-4.5,172.18.0.35,14596,13586,172.18.0.1
35,35,-4.5,-1.5,172.18.0.36,14597,13587,172.18.0.1
36,36,-4.5,1.5,172.18.0.37,14598,13588,172.18.0.1
37,37,-4.5,4.5,172.18.0.38,14599,13589,172.18.0.1
38,38,-4.5,7.5,172.18.0.39,14600,13590,172.18.0.1
39,39,-4.5,10.5,172.18.0.40,14601,13591,172.18.0.1
40,40,-4.5,13.5,172.18.0.41,14602,13592,172.18.0.1
41,41,-1.5,-13.5,172.18.0.42,14603,13593,172.18.0.1
42,42,-1.5,-10.5,172.18.0.43,14604,13594,172.18.0.1
43,43,-1.5,-7.5,172.18.0.44,14605,13595,172.18.0.1
44,44,-1.5,-4.5,172.18.0.45,14606,13596,172.18.0.1
45,45,-1.5,-1.5,172.18.0.46,14607,13597,172.18.0.1
46,46,-1.5,1.5,172.18.0.47,14608,13598,172.18.0.1
47,47,-1.5,4.5,172.18.0.48,14609,13599,172.18.0.1
48,48,-1.5,7.5,172.18.0.49,14610,13600,172.18.0.1
49,49,-1.5,10.5,172.18.0.50,14611,13601,172.18.0.1
50,50,-1.5,13.5,172.18.0.51,14612,13602,172.18.0.1
51,51,1.5,-13.5,172.18.0.52,14613,13603,172.18.0.1
52,52,1.5,-10.5,172.18.0.53,14614,13604,172.18.0.1
53,53,1.5,-7.5,172.18.0.54,14615,13605,172.18.0.1
54,54,1.5,-4.5,172.18.0.55,14616,13606,172.18.0.1
55,55,1.5,-1.5,172.18.0.56,14617,13607,172.18.0.1
56,56,1.5,1.5,172.18.0.57,14618,13608,172.18.0.1
57,57,1.5,4.5,172.18.0.58,14619,13609,172.18.0.1
58,58,1.5,7.5,172.18.0.59,14620,13610,172.18.0.1
59,59,1.5,10.5,172.18.0.60,14621,13611,172.18.0.1
60,60,1.5,13.5,172.18.0.61,14622,13612,172.18.0.1
61,61,4.5,-13.5,172.18.0.62,14623,13613,172.18.0.1
62,62,4.5,-10.5,172.18.0.63,14624,13614,172.18.0.1
63,63,4.5,-7.5,172.18.0.64,14625,13615,172.18.0.1
64,64,4.5,-4.5,172.18.0.65,14626,13616,172.18.0.1
65,65,4.5,-1.5,172.18.0.66,14627,13617,172.18.0.1
66,66,4.5,1.5,172.18.0.67,14628,13618,172.18.0.1
67,67,4.5,4.5,172.18.0.68,14629,13619,172.18.0.1
68,68,4.5,7.5,172.18.0.69,14630,13620,172.18.0.1
69,69,4.5,10.5,172.18.0.70,14631,13621,172.18.0.1
70,70,4.5,13.5,172.18.0.71,14632,13622,172.18.0.1
71,71,7.5,-13.5,172.18.0.72,14633,13623,172.18.0.1
72,72,7.5,-10.5,172.18.0.73,14634,13624,172.18.0.1
73,73,7.5,-7.5,172.18.0.74,14635,13625,172.18.0.1
74,74,7.5,-4.5,172.18.0.75,14636,13626,172.18.0.1
75,75,7.5,-1.5,172.18.0.76,14637,13627,172.18.0.1
76,76,7.5,1.5,172.18.0.77,14638,13628,172.18.0.1
77,77,7.5,4.5,172.18.0.78,14639,13629,172.18.0.1
78,78,7.5,7.5,172.18.0.79,14640,13630,172.18.0.1
79,79,7.5,10.5,172.18.0.80,14641,13631,172.18.0.1
80,80,7.5,13.5,172.18.0.81,14642,13632,172.18.0.1
81,81,10.5,-13.5,172.18.0.82,14643,13633,172.18.0.1
82,82,10.5,-10.5,172.18.0.83,14644,13634,172.18.0.1
83,83,10.5,-7.5,172.18.0.84,14645,13635,172.18.0.1
84,84,10.5,-4.5,172.18.0.85,14646,13636,172.18.0.1
85,85,10.5,-1.5,172.18.0.86,14647,13637,172.18.0.1
86,86,10.5,1.5,172.18.0.87,14648,13638,172.18.0.1
87,87,10.5,4.5,172.18.0.88,14649,13639,172.18.0.1
88,88,10.5,7.5,172.18.0.89,14650,13640,172.18.0.1
89,89,10.5,10.5,172.18.0.90,14651,13641,172.18.0.1
90,90,10.5,13.5,172.18.0.91,14652,13642,172.18.0.1
91,91,13.5,-13.5,172.18.0.92,14653,13643,172.18.0.1
92,92,13.5,-10.5,172.18.0.93,14654,13644,172.18.0.1
93,93,13.5,-7.5,172.18.0.94,14655,13645,172.18.0.1
94,94,13.5,-4.5,172.18.0.95,14656,13646,172.18.0.1
95,95,13.5,-1.5,172.18.0.96,14657,13647,172.18.0.1
96,96,13.5,1.5,172.18.0.97,14658,13648,172.18.0.1
97,97,13.5,4.5,172.18.0.98,14659,13649,172.18.0.1
98,98,13.5,7.5,172.18.0.99,14660,13650,172.18.0.1
99,99,13.5,10.5,172.18.0.100,14661,13651,172.18.0.1
100,100,13.5,13.5,172.18.0.101,14662,13652,172.18.0.1
2 changes: 1 addition & 1 deletion data/origin.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"lat": 35.76818929514965, "lon": 51.64093371089346}
{"lat": 35.724425, "lon": 51.275589}
Loading

0 comments on commit e3a8f92

Please sign in to comment.