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