feat: Sul-Tee GPS live tracking dashboard (Issue #709) #710

Merged
sl-jetson merged 3 commits from sl-webui/issue-709-gps-tracker into main 2026-04-03 22:43:55 -04:00
Showing only changes of commit 811a2ccc5c - Show all commits

View File

@ -723,17 +723,15 @@ function connectRos(url) {
} }
function setupRobotTopics() { function setupRobotTopics() {
// saltybot/gps/fix — {lat, lon, alt, stat, t} // /gps/fix — sensor_msgs/NavSatFix (SIM7600X / Pixel 5 GPS)
new ROSLIB.Topic({ new ROSLIB.Topic({
ros, name: 'saltybot/gps/fix', ros, name: '/gps/fix',
messageType: 'std_msgs/String', throttle_rate: 500, messageType: 'sensor_msgs/NavSatFix', throttle_rate: 500,
}).subscribe(msg => { }).subscribe(msg => {
try { robot.lat = msg.latitude ?? robot.lat;
const d = JSON.parse(msg.data); robot.lon = msg.longitude ?? robot.lon;
robot.lat = d.lat ?? robot.lat; robot.alt = msg.altitude ?? robot.alt;
robot.lon = d.lon ?? robot.lon; robot.stat = msg.status ? msg.status.status : robot.stat;
robot.alt = d.alt ?? robot.alt;
robot.stat = d.stat ?? robot.stat;
robot.fixes++; robot.fixes++;
robot.tsfix = Date.now(); robot.tsfix = Date.now();
@ -742,24 +740,24 @@ function setupRobotTopics() {
} }
$('last-msg').textContent = 'Robot: ' + new Date().toLocaleTimeString('en-US', { hour12: false }); $('last-msg').textContent = 'Robot: ' + new Date().toLocaleTimeString('en-US', { hour12: false });
render(); render();
} catch(_) {}
}); });
// saltybot/gps/vel — {spd, hdg, t} // /gps/vel — geometry_msgs/TwistStamped (east/north m/s + heading in radians)
new ROSLIB.Topic({ new ROSLIB.Topic({
ros, name: 'saltybot/gps/vel', ros, name: '/gps/vel',
messageType: 'std_msgs/String', throttle_rate: 500, messageType: 'geometry_msgs/TwistStamped', throttle_rate: 500,
}).subscribe(msg => { }).subscribe(msg => {
try { const vx = msg.twist.linear.x; // east m/s
const d = JSON.parse(msg.data); const vy = msg.twist.linear.y; // north m/s
robot.spd = d.spd ?? robot.spd; const spd = Math.sqrt(vx * vx + vy * vy) * 3.6; // → km/h
robot.hdg = d.hdg ?? robot.hdg; const hdg = (msg.twist.angular.z * 180 / Math.PI + 360) % 360; // radians → degrees
robot.spd = spd;
robot.hdg = hdg;
robot.tsvel = Date.now(); robot.tsvel = Date.now();
if (robotMarker && robot.lat != null) { if (robotMarker && robot.lat != null) {
robotMarker.setIcon(makeRobotIcon(robot.hdg)); robotMarker.setIcon(makeRobotIcon(robot.hdg));
} }
render(); render();
} catch(_) {}
}); });
} }