fix:更新gps数据处理
This commit is contained in:
@@ -19,8 +19,8 @@ VIDEO_TRAILER_ENDIANNESS = "little"
|
|||||||
VIDEO_TRAILER_TIMESTAMP_UNIT = "ms"
|
VIDEO_TRAILER_TIMESTAMP_UNIT = "ms"
|
||||||
VIDEO_TRAILER_TIMESTAMP_MULTIPLIER_NS = 1_000_000
|
VIDEO_TRAILER_TIMESTAMP_MULTIPLIER_NS = 1_000_000
|
||||||
VIDEO_TRAILER_TIMESTAMP_MAX_SKEW_NS = 7 * 24 * 60 * 60 * 1_000_000_000
|
VIDEO_TRAILER_TIMESTAMP_MAX_SKEW_NS = 7 * 24 * 60 * 60 * 1_000_000_000
|
||||||
VIDEO_TRAILER_COORDINATE_FORMAT = "float32 little-endian"
|
VIDEO_TRAILER_COORDINATE_FORMAT = "uint64 timestamp_ms + float64 latitude + float64 longitude (little-endian)"
|
||||||
VIDEO_TRAILER_STRUCT = struct.Struct("<Qff")
|
VIDEO_TRAILER_STRUCT = struct.Struct("<Qdd")
|
||||||
VIDEO_TRAILER_BYTES = VIDEO_TRAILER_STRUCT.size
|
VIDEO_TRAILER_BYTES = VIDEO_TRAILER_STRUCT.size
|
||||||
|
|
||||||
CONTROL_PACKET = struct.Struct("<6f")
|
CONTROL_PACKET = struct.Struct("<6f")
|
||||||
|
|||||||
@@ -80,6 +80,8 @@ class GpsDataService:
|
|||||||
"utc_time": datetime.fromtimestamp(timestamp_seconds, timezone.utc).strftime("%H:%M:%S"),
|
"utc_time": datetime.fromtimestamp(timestamp_seconds, timezone.utc).strftime("%H:%M:%S"),
|
||||||
"latitude": round(metadata.latitude, 6),
|
"latitude": round(metadata.latitude, 6),
|
||||||
"longitude": round(metadata.longitude, 6),
|
"longitude": round(metadata.longitude, 6),
|
||||||
|
"raw_latitude_hex": f"0x{metadata.raw_latitude_hex}",
|
||||||
|
"raw_longitude_hex": f"0x{metadata.raw_longitude_hex}",
|
||||||
"satellites": None,
|
"satellites": None,
|
||||||
"altitude_m": None,
|
"altitude_m": None,
|
||||||
"coordinate_system": "WGS84",
|
"coordinate_system": "WGS84",
|
||||||
|
|||||||
@@ -182,6 +182,8 @@ class OmniSocketVideoReceiver:
|
|||||||
return None
|
return None
|
||||||
if not (-90.0 <= latitude <= 90.0) or not (-180.0 <= longitude <= 180.0):
|
if not (-90.0 <= latitude <= 90.0) or not (-180.0 <= longitude <= 180.0):
|
||||||
return None
|
return None
|
||||||
|
if abs(latitude) < 1e-9 and abs(longitude) < 1e-9:
|
||||||
|
return None
|
||||||
|
|
||||||
timestamp_ns = timestamp_ms * VIDEO_TRAILER_TIMESTAMP_MULTIPLIER_NS
|
timestamp_ns = timestamp_ms * VIDEO_TRAILER_TIMESTAMP_MULTIPLIER_NS
|
||||||
if abs(time.time_ns() - timestamp_ns) > VIDEO_TRAILER_TIMESTAMP_MAX_SKEW_NS:
|
if abs(time.time_ns() - timestamp_ns) > VIDEO_TRAILER_TIMESTAMP_MAX_SKEW_NS:
|
||||||
@@ -191,6 +193,8 @@ class OmniSocketVideoReceiver:
|
|||||||
timestamp_ns=timestamp_ns,
|
timestamp_ns=timestamp_ns,
|
||||||
latitude=latitude,
|
latitude=latitude,
|
||||||
longitude=longitude,
|
longitude=longitude,
|
||||||
|
raw_latitude_hex=trailer[8:16].hex(),
|
||||||
|
raw_longitude_hex=trailer[16:24].hex(),
|
||||||
received_at=received_at if received_at is not None else time.time(),
|
received_at=received_at if received_at is not None else time.time(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,10 @@ function formatNumber(value: number) {
|
|||||||
return value.toFixed(6)
|
return value.toFixed(6)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatHexText(value: string | null | undefined) {
|
||||||
|
return value || '暂无'
|
||||||
|
}
|
||||||
|
|
||||||
async function loadAmapScript(key: string, securityJsCode: string) {
|
async function loadAmapScript(key: string, securityJsCode: string) {
|
||||||
if (window.AMap) {
|
if (window.AMap) {
|
||||||
return window.AMap
|
return window.AMap
|
||||||
@@ -161,8 +165,10 @@ function updateMap(gps: GpsTelemetry | null) {
|
|||||||
[
|
[
|
||||||
'<div style="min-width: 240px; padding: 6px 2px; line-height: 1.75; font-size: 13px; color: #152033;">',
|
'<div style="min-width: 240px; padding: 6px 2px; line-height: 1.75; font-size: 13px; color: #152033;">',
|
||||||
'<div style="margin-bottom: 8px; font-size: 14px; font-weight: 700; color: #0f172a;">Robot GPS 定位</div>',
|
'<div style="margin-bottom: 8px; font-size: 14px; font-weight: 700; color: #0f172a;">Robot GPS 定位</div>',
|
||||||
`<div><span style="color: #667085;">原始 WGS84:</span> <strong style="color: #0f172a;">${formatNumber(rawLatitude)}, ${formatNumber(rawLongitude)}</strong></div>`,
|
`<div><span style="color: #667085;">WGS84:</span> <strong style="color: #0f172a;">${formatNumber(rawLatitude)}, ${formatNumber(rawLongitude)}</strong></div>`,
|
||||||
`<div><span style="color: #667085;">高德 GCJ-02:</span> <strong style="color: #0f172a;">${formatNumber(lat)}, ${formatNumber(lng)}</strong></div>`,
|
`<div><span style="color: #667085;">高德 GCJ-02:</span> <strong style="color: #0f172a;">${formatNumber(lat)}, ${formatNumber(lng)}</strong></div>`,
|
||||||
|
`<div><span style="color: #667085;">纬度原始 8B:</span> <strong style="color: #0f172a;">${formatHexText(gps.raw_latitude_hex)}</strong></div>`,
|
||||||
|
`<div><span style="color: #667085;">经度原始 8B:</span> <strong style="color: #0f172a;">${formatHexText(gps.raw_longitude_hex)}</strong></div>`,
|
||||||
`<div><span style="color: #667085;">UTC 时间:</span> <strong style="color: #0f172a;">${gps.utc_time || '--:--:--'}</strong></div>`,
|
`<div><span style="color: #667085;">UTC 时间:</span> <strong style="color: #0f172a;">${gps.utc_time || '--:--:--'}</strong></div>`,
|
||||||
`<div><span style="color: #667085;">卫星数:</span> <strong style="color: #0f172a;">${gps.satellites ?? '未知'}</strong></div>`,
|
`<div><span style="color: #667085;">卫星数:</span> <strong style="color: #0f172a;">${gps.satellites ?? '未知'}</strong></div>`,
|
||||||
`<div><span style="color: #667085;">海拔:</span> <strong style="color: #0f172a;">${gps.altitude_m ?? '未知'} m</strong></div>`,
|
`<div><span style="color: #667085;">海拔:</span> <strong style="color: #0f172a;">${gps.altitude_m ?? '未知'} m</strong></div>`,
|
||||||
@@ -206,6 +212,17 @@ const rawCoordinateText = computed(() => {
|
|||||||
return `${formatNumber(props.gps.latitude)}, ${formatNumber(props.gps.longitude)}`
|
return `${formatNumber(props.gps.latitude)}, ${formatNumber(props.gps.longitude)}`
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const rawLatitudeHexText = computed(() => formatHexText(props.gps?.raw_latitude_hex))
|
||||||
|
|
||||||
|
const rawLongitudeHexText = computed(() => formatHexText(props.gps?.raw_longitude_hex))
|
||||||
|
|
||||||
|
const coordinateMetaText = computed(() => {
|
||||||
|
if (!props.gps) {
|
||||||
|
return '暂无'
|
||||||
|
}
|
||||||
|
return `${props.gps.coordinate_system} / ${props.gps.raw_coordinate_format}`
|
||||||
|
})
|
||||||
|
|
||||||
const metaText = computed(() => {
|
const metaText = computed(() => {
|
||||||
if (!props.gps) {
|
if (!props.gps) {
|
||||||
return '暂无'
|
return '暂无'
|
||||||
@@ -268,13 +285,21 @@ watch(
|
|||||||
|
|
||||||
<div class="details">
|
<div class="details">
|
||||||
<div class="detail-card">
|
<div class="detail-card">
|
||||||
<span>原始 WGS84</span>
|
<span>WGS84 坐标</span>
|
||||||
<strong>{{ rawCoordinateText }}</strong>
|
<strong>{{ rawCoordinateText }}</strong>
|
||||||
</div>
|
</div>
|
||||||
<div class="detail-card">
|
<div class="detail-card">
|
||||||
<span>高德 GCJ-02</span>
|
<span>高德 GCJ-02</span>
|
||||||
<strong>{{ amapCoordinateText }}</strong>
|
<strong>{{ amapCoordinateText }}</strong>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="detail-card">
|
||||||
|
<span>纬度原始 8 字节</span>
|
||||||
|
<strong class="mono">{{ rawLatitudeHexText }}</strong>
|
||||||
|
</div>
|
||||||
|
<div class="detail-card">
|
||||||
|
<span>经度原始 8 字节</span>
|
||||||
|
<strong class="mono">{{ rawLongitudeHexText }}</strong>
|
||||||
|
</div>
|
||||||
<div class="detail-card">
|
<div class="detail-card">
|
||||||
<span>UTC 时间</span>
|
<span>UTC 时间</span>
|
||||||
<strong>{{ gps?.utc_time ?? '--:--:--' }}</strong>
|
<strong>{{ gps?.utc_time ?? '--:--:--' }}</strong>
|
||||||
@@ -284,8 +309,8 @@ watch(
|
|||||||
<strong>{{ metaText }}</strong>
|
<strong>{{ metaText }}</strong>
|
||||||
</div>
|
</div>
|
||||||
<div class="detail-card">
|
<div class="detail-card">
|
||||||
<span>坐标系</span>
|
<span>坐标系 / 格式</span>
|
||||||
<strong>{{ gps?.coordinate_system ?? 'WGS84' }}</strong>
|
<strong>{{ coordinateMetaText }}</strong>
|
||||||
</div>
|
</div>
|
||||||
<div class="detail-card">
|
<div class="detail-card">
|
||||||
<span>最近刷新</span>
|
<span>最近刷新</span>
|
||||||
@@ -397,6 +422,11 @@ h2 {
|
|||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.detail-card strong.mono {
|
||||||
|
font-family: "JetBrains Mono", "SFMono-Regular", monospace;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
.map-canvas {
|
.map-canvas {
|
||||||
position: relative;
|
position: relative;
|
||||||
min-height: 420px;
|
min-height: 420px;
|
||||||
|
|||||||
Reference in New Issue
Block a user