From 1d42dff46de4556ccd5dcb3564259652e8338a8e Mon Sep 17 00:00:00 2001 From: logbasem Date: Wed, 28 May 2025 23:19:46 -0600 Subject: [PATCH 1/3] fix: recentered map and moved icons to public --- .gitignore | 2 +- frontend/main.js | 18 ++++++++++-------- .../{ => public/rover-icon}/rover-shadow.png | Bin frontend/{ => public/rover-icon}/rover.png | Bin 4 files changed, 11 insertions(+), 9 deletions(-) rename frontend/{ => public/rover-icon}/rover-shadow.png (100%) rename frontend/{ => public/rover-icon}/rover.png (100%) diff --git a/.gitignore b/.gitignore index b894980..0771773 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,6 @@ tiles/ tiles.tar node_modules map_tiles -public/ +public/utah-tiles-2/ dist/ gps_webtransport_server/target/ \ No newline at end of file diff --git a/frontend/main.js b/frontend/main.js index f1db07f..47b85da 100644 --- a/frontend/main.js +++ b/frontend/main.js @@ -35,14 +35,14 @@ let currentPositionMarker = null; window.onload = () => { // Initialize rover icon var roverIcon = L.icon({ - iconUrl: 'rover.png', - shadowUrl: 'rover-shadow.png', - - iconSize: [30, 30], // size of the icon - shadowSize: [30, 30], // size of the shadow - iconAnchor: [0, 0], // point of the icon which will correspond to marker's location + iconUrl: '/rover-icon/rover.png', + shadowUrl: '/rover-icon/rover-shadow.png', + + iconSize: [30, 30], // size of the icon + shadowSize: [30, 30], // size of the shadow + iconAnchor: [0, 0], // point of the icon which will correspond to marker's location shadowAnchor: [-2, 1], // the same for the shadow - popupAnchor: [50, 50] // point from which the popup should open relative to the iconAnchor + popupAnchor: [50, 50] // point from which the popup should open relative to the iconAnchor }); window.addWayPoint = () => { @@ -58,7 +58,9 @@ window.onload = () => { if (currentPositionMarker) { currentPositionMarker.setLatLng([lat, lon]); } else { - currentPositionMarker = L.marker([lat, lon], {icon: roverIcon}).addTo(map); + currentPositionMarker = L.marker([lat, lon], { icon: roverIcon }).addTo(map); + + map.setView([lat, lon], 15); } }); diff --git a/frontend/rover-shadow.png b/frontend/public/rover-icon/rover-shadow.png similarity index 100% rename from frontend/rover-shadow.png rename to frontend/public/rover-icon/rover-shadow.png diff --git a/frontend/rover.png b/frontend/public/rover-icon/rover.png similarity index 100% rename from frontend/rover.png rename to frontend/public/rover-icon/rover.png From a782e56ad910185c25ed3e95e8eb5d52447f5b50 Mon Sep 17 00:00:00 2001 From: logbasem Date: Wed, 28 May 2025 23:21:00 -0600 Subject: [PATCH 2/3] fix: moved placeholder image to public --- frontend/map.js | 2 +- frontend/{ => public}/map-placeholder.png | Bin 2 files changed, 1 insertion(+), 1 deletion(-) rename frontend/{ => public}/map-placeholder.png (100%) diff --git a/frontend/map.js b/frontend/map.js index 3a7837f..3e666ed 100644 --- a/frontend/map.js +++ b/frontend/map.js @@ -13,7 +13,7 @@ const tileLayer = L.tileLayer('/utah-tiles-2/{z}/{x}/{y}.png', { tileLayer.on('tileerror', function (e) { const img = e.tile; - img.src = '../map-placeholder.png'; // placeholder image for if tiles don't load + img.src = '/map-placeholder.png'; // placeholder image for if tiles don't load }); tileLayer.addTo(map); diff --git a/frontend/map-placeholder.png b/frontend/public/map-placeholder.png similarity index 100% rename from frontend/map-placeholder.png rename to frontend/public/map-placeholder.png From 44a701aa96d1adcbc2f52f92bdf331405ec03b19 Mon Sep 17 00:00:00 2001 From: logbasem Date: Thu, 29 May 2025 21:04:41 -0600 Subject: [PATCH 3/3] fix: changed to correct port for rover and made fixes --- frontend/gps-client.js | 8 +++++--- frontend/index.html | 1 + frontend/main.js | 6 ++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/frontend/gps-client.js b/frontend/gps-client.js index 718e042..d0b12e9 100644 --- a/frontend/gps-client.js +++ b/frontend/gps-client.js @@ -1,13 +1,15 @@ export function startGPSClient() { - const socket = new WebSocket('ws://localhost:9001'); // make sure port matches server port - + console.log("Creating websocket...") + const socket = new WebSocket('ws://192.168.1.68:9001'); // make sure port matches server port + console.log("WebSocket created!") socket.onopen = () => { console.log('🔌 WebSocket connection established'); - } + }; socket.onmessage = (event) => { try { const data = JSON.parse(event.data); + console.log(data); const gpsEvent = new CustomEvent('gps-update', { detail: data }); window.dispatchEvent(gpsEvent); } catch (e) { diff --git a/frontend/index.html b/frontend/index.html index dc0c823..3122c00 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -16,6 +16,7 @@
+

Rover's current position

Tools

Click a tool's button to enable it.

diff --git a/frontend/main.js b/frontend/main.js index 47b85da..55eaac2 100644 --- a/frontend/main.js +++ b/frontend/main.js @@ -51,8 +51,10 @@ window.onload = () => { // Listen for GPS data window.addEventListener('gps-update', (e) => { + console.log("GPS updated"); const { lat, lon } = e.detail; - // FOR TESTING: console.log(`📡 GPS Update: Latitude ${lat}, Longitude ${lon}`); + console.log(`📡 GPS Update: Latitude ${lat}, Longitude ${lon}`); + document.getElementById("rover-pos").innerHTML = `Rover Position: ${lat.toFixed(6)}, ${lon.toFixed(6)}`; // Add or update the current position marker if (currentPositionMarker) { @@ -60,7 +62,7 @@ window.onload = () => { } else { currentPositionMarker = L.marker([lat, lon], { icon: roverIcon }).addTo(map); - map.setView([lat, lon], 15); + map.setView([lat, lon], 13); } });