feat: Sul-Tee GPS live tracking dashboard (Issue #709) #710
@ -723,43 +723,41 @@ 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.fixes++;
|
||||
robot.tsfix = Date.now();
|
||||
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();
|
||||
|
||||
if (robot.lat != null && robot.lon != null) {
|
||||
updateRobotMap(robot.lat, robot.lon, robot.hdg);
|
||||
}
|
||||
$('last-msg').textContent = 'Robot: ' + new Date().toLocaleTimeString('en-US', { hour12: false });
|
||||
render();
|
||||
} catch(_) {}
|
||||
if (robot.lat != null && robot.lon != null) {
|
||||
updateRobotMap(robot.lat, robot.lon, robot.hdg);
|
||||
}
|
||||
$('last-msg').textContent = 'Robot: ' + new Date().toLocaleTimeString('en-US', { hour12: false });
|
||||
render();
|
||||
});
|
||||
|
||||
// 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;
|
||||
robot.tsvel = Date.now();
|
||||
if (robotMarker && robot.lat != null) {
|
||||
robotMarker.setIcon(makeRobotIcon(robot.hdg));
|
||||
}
|
||||
render();
|
||||
} catch(_) {}
|
||||
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();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user