fix(sultee-tracker): subscribe to proper ROS GPS topics for robot marker

Switch robot GPS subscription from custom saltybot/gps/* std_msgs/String
topics to the canonical /gps/fix (sensor_msgs/NavSatFix) and /gps/vel
(geometry_msgs/TwistStamped) published by the SIM7600X GPS driver node.

- /gps/fix: read msg.latitude/longitude/altitude/status.status directly
- /gps/vel: compute speed (sqrt(vx²+vy²) * 3.6 km/h) and heading
  (angular.z radians → degrees) from ENU velocity components

Closes #709

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
sl-webui 2026-04-03 22:41:47 -04:00
parent bb354336c3
commit 811a2ccc5c

View File

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