chore: use 1s STEP
This commit is contained in:
parent
acf9d132f7
commit
0ce7faaa07
5 changed files with 1304 additions and 1348 deletions
|
|
@ -83,7 +83,8 @@
|
||||||
return new Date(earliest).toISOString().slice(0, 16);
|
return new Date(earliest).toISOString().slice(0, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
startTime = deriveStartTime(defaultDispatch) || new Date().toISOString().slice(0, 16);
|
// Set to current time
|
||||||
|
startTime = new Date().toISOString().slice(0, 16);
|
||||||
desiredTime = startTime;
|
desiredTime = startTime;
|
||||||
|
|
||||||
function jumpToTime(timeValue) {
|
function jumpToTime(timeValue) {
|
||||||
|
|
@ -186,49 +187,6 @@
|
||||||
stopPlaying();
|
stopPlaying();
|
||||||
});
|
});
|
||||||
|
|
||||||
async function requestPath() {
|
|
||||||
let payload;
|
|
||||||
try {
|
|
||||||
payload = JSON.parse(dispatchBody);
|
|
||||||
} catch (err) {
|
|
||||||
status = "Error: Invalid JSON format.";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!Array.isArray(payload)) {
|
|
||||||
status = "Error: Payload must be an array.";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const derivedStart = deriveStartTime(payload);
|
|
||||||
if (derivedStart) {
|
|
||||||
startTime = derivedStart;
|
|
||||||
desiredTime = derivedStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
loading = true;
|
|
||||||
status = "Transmitting dispatch to API...";
|
|
||||||
stopPlaying();
|
|
||||||
|
|
||||||
try {
|
|
||||||
const res = await fetch(`${apiBase}/calcDeliveryPath`, {
|
|
||||||
method: "POST",
|
|
||||||
headers: { "Content-Type": "application/json" },
|
|
||||||
body: JSON.stringify(payload),
|
|
||||||
});
|
|
||||||
if (!res.ok) throw new Error(`${res.status} ${res.statusText}`);
|
|
||||||
|
|
||||||
plannedPath = await res.json();
|
|
||||||
tick = 0;
|
|
||||||
fitMapToBounds();
|
|
||||||
status = "Flight path received. Ready for simulation.";
|
|
||||||
} catch (err) {
|
|
||||||
plannedPath = samplePathResponse;
|
|
||||||
status = `API Link Failed. Using offline sample data. (${err.message})`;
|
|
||||||
} finally {
|
|
||||||
loading = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadSample() {
|
function loadSample() {
|
||||||
plannedPath = samplePathResponse;
|
plannedPath = samplePathResponse;
|
||||||
status = "Loaded sample simulation data.";
|
status = "Loaded sample simulation data.";
|
||||||
|
|
@ -386,10 +344,6 @@
|
||||||
<div class="text-[10px] space-y-0.5 font-mono opacity-80">
|
<div class="text-[10px] space-y-0.5 font-mono opacity-80">
|
||||||
<div class="flex justify-between"><span>Lat:</span> <span>${drone.current.lat.toFixed(4)}</span></div>
|
<div class="flex justify-between"><span>Lat:</span> <span>${drone.current.lat.toFixed(4)}</span></div>
|
||||||
<div class="flex justify-between"><span>Lng:</span> <span>${drone.current.lng.toFixed(4)}</span></div>
|
<div class="flex justify-between"><span>Lng:</span> <span>${drone.current.lng.toFixed(4)}</span></div>
|
||||||
<div class="flex justify-between mt-1 pt-1 border-t border-white/10">
|
|
||||||
<span>Status:</span>
|
|
||||||
<span class="${isMoving ? "text-green-400" : "text-slate-400"}">${isMoving ? "MOVING" : "IDLE"}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
@ -514,7 +468,6 @@
|
||||||
{status}
|
{status}
|
||||||
{loading}
|
{loading}
|
||||||
on:close={() => (sidebarOpen = false)}
|
on:close={() => (sidebarOpen = false)}
|
||||||
on:request={requestPath}
|
|
||||||
on:loadSample={loadSample}
|
on:loadSample={loadSample}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,11 @@
|
||||||
@apply bg-gray-800 text-white p-2 rounded-md border-gray-700 border;
|
@apply bg-gray-800 text-white p-2 rounded-md border-gray-700 border;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Arrow should be the same color as the tooltip background */
|
||||||
|
.drone-tooltip.leaflet-tooltip-top::before {
|
||||||
|
border-top-color: theme('colors.gray.800');
|
||||||
|
}
|
||||||
|
|
||||||
/* Custom Scrollbar */
|
/* Custom Scrollbar */
|
||||||
.custom-scrollbar::-webkit-scrollbar {
|
.custom-scrollbar::-webkit-scrollbar {
|
||||||
width: 6px;
|
width: 6px;
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@
|
||||||
<label
|
<label
|
||||||
for="api"
|
for="api"
|
||||||
class="block text-xs text-slate-600 dark:text-slate-400 mb-1"
|
class="block text-xs text-slate-600 dark:text-slate-400 mb-1"
|
||||||
>Planner API Endpoint</label
|
>Planner API Endpoint (Debug Only)</label
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
id="api"
|
id="api"
|
||||||
|
|
@ -189,7 +189,6 @@
|
||||||
spellcheck="false"
|
spellcheck="false"
|
||||||
></textarea>
|
></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex gap-2 mt-auto pt-4 border-t border-slate-200 dark:border-slate-800">
|
<div class="flex gap-2 mt-auto pt-4 border-t border-slate-200 dark:border-slate-800">
|
||||||
<button
|
<button
|
||||||
|
|
@ -199,11 +198,7 @@
|
||||||
>
|
>
|
||||||
{loading ? "CALCULATING..." : "REQUEST PATH"}
|
{loading ? "CALCULATING..." : "REQUEST PATH"}
|
||||||
</button>
|
</button>
|
||||||
<button
|
|
||||||
class="flex-1 p-2.5 rounded-lg font-semibold text-sm transition-all disabled:opacity-50 disabled:cursor-not-allowed text-slate-800 dark:text-slate-100 bg-slate-500/20 hover:bg-slate-500/30"
|
|
||||||
on:click={() => dispatch('loadSample')}
|
|
||||||
>
|
|
||||||
LOAD SAMPLE
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</aside>
|
</aside>
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
// Data from Bruno Test Query
|
// Data from Bruno Test Query
|
||||||
export const STEP_SECONDS = 30;
|
export const STEP_SECONDS = 1;
|
||||||
|
|
||||||
export const fallbackBounds = {
|
export const fallbackBounds = {
|
||||||
minLng: -3.19,
|
minLng: -3.19,
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,10 @@ public record DroneEvent(
|
||||||
double latitude,
|
double latitude,
|
||||||
double longitude,
|
double longitude,
|
||||||
String timestamp) {
|
String timestamp) {
|
||||||
|
|
||||||
|
final static int STEP = 1; // seconds between events
|
||||||
// Helper method that converts from DeliveryPathResponse to List<DroneEvent>
|
// Helper method that converts from DeliveryPathResponse to List<DroneEvent>
|
||||||
|
|
||||||
public static List<DroneEvent> fromPathResponse(DeliveryPathResponse resp) {
|
public static List<DroneEvent> fromPathResponse(DeliveryPathResponse resp) {
|
||||||
List<DroneEvent> events = new java.util.ArrayList<>();
|
List<DroneEvent> events = new java.util.ArrayList<>();
|
||||||
for (var p : resp.dronePaths()) {
|
for (var p : resp.dronePaths()) {
|
||||||
|
|
@ -57,7 +60,7 @@ public record DroneEvent(
|
||||||
coord.lat(),
|
coord.lat(),
|
||||||
coord.lng(),
|
coord.lng(),
|
||||||
timestamp.toString()));
|
timestamp.toString()));
|
||||||
timestamp = timestamp.plusSeconds(1); // Increment timestamp for each event
|
timestamp = timestamp.plusSeconds(STEP); // Increment timestamp for each event
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -80,7 +83,7 @@ public record DroneEvent(
|
||||||
coord.lat(),
|
coord.lat(),
|
||||||
coord.lng(),
|
coord.lng(),
|
||||||
current.toString()));
|
current.toString()));
|
||||||
current = current.plusSeconds(1);
|
current = current.plusSeconds(STEP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue