添加了头部姿态数据处理
This commit is contained in:
parent
ba8f13b3ea
commit
c7f96636f3
@ -78,10 +78,26 @@
|
||||
头部姿态
|
||||
</div>
|
||||
</div>
|
||||
<el-button type="primary" class="start-btn" style="background-image: linear-gradient(to right, rgb(236, 50, 166), rgb(160, 5, 216));
|
||||
--el-button-border-color: transparent !important;border-radius: 20px;border:none;width: 150px;">
|
||||
清零
|
||||
<div style="display: flex; gap: 10px;">
|
||||
<el-button
|
||||
type="primary"
|
||||
class="start-btn"
|
||||
@click="clearAndStartTracking"
|
||||
:disabled="isRecording"
|
||||
style="background-image: linear-gradient(to right, rgb(236, 50, 166), rgb(160, 5, 216));
|
||||
--el-button-border-color: transparent !important;border-radius: 20px;border:none;width: 80px;">
|
||||
{{ isTrackingMaxValues ? '跟踪中' : '清零' }}
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
class="start-btn"
|
||||
@click="saveMaxValuesToHistory"
|
||||
:disabled="!isTrackingMaxValues || isRecording"
|
||||
style="background-image: linear-gradient(to right, rgb(64, 158, 255), rgb(64, 158, 255));
|
||||
--el-button-border-color: transparent !important;border-radius: 20px;border:none;width: 80px;">
|
||||
保存
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -91,25 +107,28 @@
|
||||
<div id="headChart1" style="width: 100%;height: 140px;"></div>
|
||||
<!-- <img src="@/assets/test1.png" alt="" style="width: 100%;height: 140px;"> -->
|
||||
<div class="gauge-group-box">
|
||||
<div class="gauge-group-box-text1">左:<span class="gauge-group-box-text2">-55.2°</span></div>
|
||||
<div class="gauge-group-box-text1">旋转</div>
|
||||
<div class="gauge-group-box-text1">左:<span class="gauge-group-box-text2">{{ headPoseMaxValues.rotationLeftMax.toFixed(1) }}°</span></div>
|
||||
<div class="gauge-group-box-text1" style="margin-left: 20px;">右:<span
|
||||
class="gauge-group-box-text2">-55.2°</span></div>
|
||||
class="gauge-group-box-text2">{{ headPoseMaxValues.rotationRightMax.toFixed(1) }}°</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="width: 33%;">
|
||||
<img src="@/assets/test1.png" alt="" style="width: 100%;height: 140px;">
|
||||
<div class="gauge-group-box">
|
||||
<div class="gauge-group-box-text1">左:<span class="gauge-group-box-text2">-7.7°</span></div>
|
||||
<div class="gauge-group-box-text1">倾斜</div>
|
||||
<div class="gauge-group-box-text1">左:<span class="gauge-group-box-text2">{{ headPoseMaxValues.tiltLeftMax.toFixed(1) }}°</span></div>
|
||||
<div class="gauge-group-box-text1" style="margin-left: 20px;">右:<span
|
||||
class="gauge-group-box-text2">8.7°</span></div>
|
||||
class="gauge-group-box-text2">{{ headPoseMaxValues.tiltRightMax.toFixed(1) }}°</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="width: 33%;">
|
||||
<img src="@/assets/test1.png" alt="" style="width: 100%;height: 140px;">
|
||||
<div class="gauge-group-box">
|
||||
<div class="gauge-group-box-text1">左:<span class="gauge-group-box-text2">-10.5°</span></div>
|
||||
<div class="gauge-group-box-text1" style="margin-left: 20px;">右:<span
|
||||
class="gauge-group-box-text2">11.5°</span></div>
|
||||
<div class="gauge-group-box-text1">俯仰</div>
|
||||
<div class="gauge-group-box-text1">下:<span class="gauge-group-box-text2">{{ headPoseMaxValues.pitchDownMax.toFixed(1) }}°</span></div>
|
||||
<div class="gauge-group-box-text1" style="margin-left: 20px;">上:<span
|
||||
class="gauge-group-box-text2">{{ headPoseMaxValues.pitchUpMax.toFixed(1) }}°</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -642,6 +661,22 @@ function displayDepthCameraFrame(base64Image) {
|
||||
}
|
||||
|
||||
|
||||
// 头部姿态最值跟踪数据
|
||||
const headPoseMaxValues = ref({
|
||||
rotationLeftMax: 0, // 旋转-左旋最大值
|
||||
rotationRightMax: 0, // 旋转-右旋最大值
|
||||
tiltLeftMax: 0, // 倾斜-左倾最大值
|
||||
tiltRightMax: 0, // 倾斜-右倾最大值
|
||||
pitchUpMax: 0, // 俯仰-上仰最大值
|
||||
pitchDownMax: 0 // 俯仰-下俯最大值
|
||||
})
|
||||
|
||||
// 头部姿态历史最值记录数组
|
||||
const headPoseHistory = ref([])
|
||||
|
||||
// 最值跟踪状态
|
||||
const isTrackingMaxValues = ref(false)
|
||||
|
||||
// 处理IMU头部姿态数据
|
||||
function handleIMUData(data) {
|
||||
try {
|
||||
@ -658,6 +693,11 @@ function handleIMUData(data) {
|
||||
// 显示角度值(保留一位小数)
|
||||
console.log(`📐 头部姿态角度 - 旋转: ${headPose.rotation.toFixed(1)}°, 倾斜: ${headPose.tilt.toFixed(1)}°, 俯仰: ${headPose.pitch.toFixed(1)}°`)
|
||||
|
||||
// 如果正在跟踪最值,则更新最值数据
|
||||
if (isTrackingMaxValues.value) {
|
||||
updateHeadPoseMaxValues(headPose)
|
||||
}
|
||||
|
||||
// 这里可以添加数据可视化逻辑
|
||||
// 例如更新图表或显示数值
|
||||
|
||||
@ -673,6 +713,162 @@ function handleIMUData(data) {
|
||||
}
|
||||
}
|
||||
|
||||
// 更新头部姿态最值
|
||||
function updateHeadPoseMaxValues(headPose) {
|
||||
try {
|
||||
// 更新旋转角最值
|
||||
if (headPose.rotation < 0) {
|
||||
// 左旋(负值),取绝对值的最大值
|
||||
headPoseMaxValues.value.rotationLeftMax = Math.min(
|
||||
headPoseMaxValues.value.rotationLeftMax,
|
||||
Math.abs(headPose.rotation)
|
||||
)
|
||||
} else if (headPose.rotation > 0) {
|
||||
// 右旋(正值)
|
||||
headPoseMaxValues.value.rotationRightMax = Math.max(
|
||||
headPoseMaxValues.value.rotationRightMax,
|
||||
headPose.rotation
|
||||
)
|
||||
}
|
||||
|
||||
// 更新倾斜角最值
|
||||
if (headPose.tilt < 0) {
|
||||
// 左倾(负值),取绝对值的最大值
|
||||
headPoseMaxValues.value.tiltLeftMax = Math.min(
|
||||
headPoseMaxValues.value.tiltLeftMax,
|
||||
Math.abs(headPose.tilt)
|
||||
)
|
||||
} else if (headPose.tilt > 0) {
|
||||
// 右倾(正值)
|
||||
headPoseMaxValues.value.tiltRightMax = Math.max(
|
||||
headPoseMaxValues.value.tiltRightMax,
|
||||
headPose.tilt
|
||||
)
|
||||
}
|
||||
|
||||
// 更新俯仰角最值
|
||||
if (headPose.pitch < 0) {
|
||||
// 下俯(负值),取绝对值的最大值
|
||||
headPoseMaxValues.value.pitchDownMax = Math.min(
|
||||
headPoseMaxValues.value.pitchDownMax,
|
||||
Math.abs(headPose.pitch)
|
||||
)
|
||||
} else if (headPose.pitch > 0) {
|
||||
// 上仰(正值)
|
||||
headPoseMaxValues.value.pitchUpMax = Math.max(
|
||||
headPoseMaxValues.value.pitchUpMax,
|
||||
headPose.pitch
|
||||
)
|
||||
}
|
||||
|
||||
// 输出当前最值(用于调试)
|
||||
console.log('📊 当前头部姿态最值:', {
|
||||
rotationLeft: headPoseMaxValues.value.rotationLeftMax.toFixed(1),
|
||||
rotationRight: headPoseMaxValues.value.rotationRightMax.toFixed(1),
|
||||
tiltLeft: headPoseMaxValues.value.tiltLeftMax.toFixed(1),
|
||||
tiltRight: headPoseMaxValues.value.tiltRightMax.toFixed(1),
|
||||
pitchUp: headPoseMaxValues.value.pitchUpMax.toFixed(1),
|
||||
pitchDown: headPoseMaxValues.value.pitchDownMax.toFixed(1)
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('❌ 更新头部姿态最值失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 清零最值并开始跟踪
|
||||
function clearAndStartTracking() {
|
||||
try {
|
||||
saveMaxValuesToHistory()
|
||||
|
||||
// 重置所有最值为0
|
||||
headPoseMaxValues.value = {
|
||||
rotationLeftMax: 0,
|
||||
rotationRightMax: 0,
|
||||
tiltLeftMax: 0,
|
||||
tiltRightMax: 0,
|
||||
pitchUpMax: 0,
|
||||
pitchDownMax: 0
|
||||
}
|
||||
|
||||
// 开始跟踪
|
||||
isTrackingMaxValues.value = true
|
||||
|
||||
console.log('🔄 头部姿态最值已清零,开始跟踪')
|
||||
ElMessage.success('头部姿态最值已清零,开始跟踪')
|
||||
} catch (error) {
|
||||
console.error('❌ 清零最值失败:', error)
|
||||
ElMessage.error('清零最值失败')
|
||||
}
|
||||
}
|
||||
|
||||
// 保存当前最值到历史记录
|
||||
function saveMaxValuesToHistory() {
|
||||
try {
|
||||
if (!isTrackingMaxValues.value) {
|
||||
ElMessage.warning('请先点击清零开始跟踪')
|
||||
return
|
||||
}
|
||||
|
||||
// 创建当前最值的副本
|
||||
const currentMaxValues = {
|
||||
id: headPoseHistory.value.length + 1,
|
||||
rotationLeftMax: Number(headPoseMaxValues.value.rotationLeftMax.toFixed(1)),
|
||||
rotationRightMax: Number(headPoseMaxValues.value.rotationRightMax.toFixed(1)),
|
||||
tiltLeftMax: Number(headPoseMaxValues.value.tiltLeftMax.toFixed(1)),
|
||||
tiltRightMax: Number(headPoseMaxValues.value.tiltRightMax.toFixed(1)),
|
||||
pitchUpMax: Number(headPoseMaxValues.value.pitchUpMax.toFixed(1)),
|
||||
pitchDownMax: Number(headPoseMaxValues.value.pitchDownMax.toFixed(1)),
|
||||
timestamp: new Date().toLocaleString()
|
||||
}
|
||||
|
||||
// 添加到历史记录
|
||||
headPoseHistory.value.push(currentMaxValues)
|
||||
|
||||
// 停止跟踪
|
||||
isTrackingMaxValues.value = false
|
||||
|
||||
console.log('💾 头部姿态最值已保存:', currentMaxValues)
|
||||
ElMessage.success(`头部姿态最值已保存(第${currentMaxValues.id}组)`)
|
||||
|
||||
// 更新历史数据表格(如果存在的话)
|
||||
updateHistoryTable()
|
||||
} catch (error) {
|
||||
console.error('❌ 保存最值失败:', error)
|
||||
ElMessage.error('保存最值失败')
|
||||
}
|
||||
}
|
||||
|
||||
// 更新历史数据表格
|
||||
function updateHistoryTable() {
|
||||
try {
|
||||
// 将头部姿态最值数据合并到现有的历史数据中
|
||||
if (headPoseHistory.value.length > 0) {
|
||||
const latestData = headPoseHistory.value[headPoseHistory.value.length - 1]
|
||||
|
||||
// 更新historyData数组,添加头部姿态最值数据
|
||||
const newHistoryItem = {
|
||||
id: latestData.id,
|
||||
rotLeft: latestData.rotationLeftMax,
|
||||
rotRight: latestData.rotationRightMax,
|
||||
tiltLeft: latestData.tiltLeftMax,
|
||||
tiltRight: latestData.tiltRightMax,
|
||||
pitchDown: latestData.pitchDownMax,
|
||||
pitchUp: latestData.pitchUpMax,
|
||||
timestamp: latestData.timestamp
|
||||
}
|
||||
|
||||
// 如果historyData数组存在,则添加新数据
|
||||
if (historyData.value) {
|
||||
historyData.value.push(newHistoryItem)
|
||||
}
|
||||
|
||||
console.log('📋 历史数据表格已更新')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('❌ 更新历史数据表格失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 处理压力传感器足部压力数据
|
||||
function handlePressureData(data) {
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user