|
|
@@ -12,9 +12,10 @@
|
|
|
:robotPoseData="laserPositionData"
|
|
|
:poseCalibrationIndex="nowCalibId"
|
|
|
:showDefaultControls="false"
|
|
|
+ :mapName="mapName"
|
|
|
/>
|
|
|
</div>
|
|
|
-
|
|
|
+ <MqttComp ref="mqtt" :topics="topics" @message-received="onMessage" />
|
|
|
<!-- 地图工具条 -->
|
|
|
<MapToolbar
|
|
|
class="map-toolbar"
|
|
|
@@ -39,6 +40,7 @@
|
|
|
:calibrationList="calibrationList"
|
|
|
:currentMap="currentMap"
|
|
|
:panelWidth="rightPanelWidth"
|
|
|
+ :mapName="mapName"
|
|
|
@panel-toggle="handlePanelToggle"
|
|
|
@panel-resize="handlePanelResize"
|
|
|
@add-calibration="addCalibration"
|
|
|
@@ -109,31 +111,34 @@
|
|
|
import OlMap from "@/components/OlMap";
|
|
|
import RightPanel from "./components/RightPanel.vue";
|
|
|
import MapToolbar from "./components/MapToolbar.vue";
|
|
|
+import MqttComp from "@/components/Mqtt/mqttComp.vue";
|
|
|
|
|
|
export default {
|
|
|
name: "Calibration",
|
|
|
components: {
|
|
|
OlMap,
|
|
|
RightPanel,
|
|
|
- MapToolbar
|
|
|
+ MapToolbar,
|
|
|
+ MqttComp
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
+ topics:[this.$mqttPrefix + '/localization/pose'],
|
|
|
// 弹出层标题
|
|
|
title: "",
|
|
|
calibrationList: [],
|
|
|
// 激光定位数据
|
|
|
laserPositionData: {
|
|
|
- x: 123.45,
|
|
|
- y: 678.90,
|
|
|
- angle: 45.2
|
|
|
+ x: 0,
|
|
|
+ y: 0,
|
|
|
+ angle: 0
|
|
|
},
|
|
|
// gnss定位数据
|
|
|
gnssPositionData: {
|
|
|
- status: '卫星锁定',
|
|
|
- longitude: 121.473701,
|
|
|
- latitude: 31.230416,
|
|
|
- angle: 45.5
|
|
|
+ status: '0/0',
|
|
|
+ longitude: 0,
|
|
|
+ latitude: 0,
|
|
|
+ angle: 0
|
|
|
},
|
|
|
// 当前地图
|
|
|
currentMap: {
|
|
|
@@ -150,6 +155,8 @@ export default {
|
|
|
windowWidth: window.innerWidth, // 窗口宽度
|
|
|
drawerVisible: false, // 抽屉是否可见
|
|
|
isFullscreen: false, // 是否全屏状态
|
|
|
+ mapName: this.$route.params.mapName || 'Unknown', // 当前地图名称
|
|
|
+ isRobotFollow: false // 是否跟随机器人
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -186,9 +193,8 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
- const mapId = this.$route.params.mapId;
|
|
|
- this.updateOlCss();
|
|
|
-
|
|
|
+ // const mapId = this.$route.params.mapId;
|
|
|
+ // this.updateOlCss();
|
|
|
// 监听窗口大小变化
|
|
|
window.addEventListener('resize', this.handleWindowResize);
|
|
|
|
|
|
@@ -211,6 +217,26 @@ export default {
|
|
|
document.removeEventListener('MSFullscreenChange', this.handleFullscreenChange);
|
|
|
},
|
|
|
methods: {
|
|
|
+ onMessage({ topic, message }) {
|
|
|
+ // console.log("收到消息:");
|
|
|
+ try {
|
|
|
+ const data = message.args[0];
|
|
|
+ const {xyz, rpy, blh, heading} = data.pose;
|
|
|
+ // 激光定位实时数据
|
|
|
+ this.laserPositionData.x = xyz[0];
|
|
|
+ this.laserPositionData.y = xyz[1];
|
|
|
+ this.laserPositionData.angle = rpy[2];
|
|
|
+ // GNSS定位实时数据
|
|
|
+ this.gnssPositionData.longitude = blh[1]; // 经度
|
|
|
+ this.gnssPositionData.latitude = blh[0]; // 纬度
|
|
|
+ this.gnssPositionData.angle = heading; // 航向角
|
|
|
+
|
|
|
+ this.gnssPositionData.status = data.rtk.star+ '/' + data.rtk.status; // RTK状态
|
|
|
+
|
|
|
+ } catch (e) {
|
|
|
+ console.error("解析失败:", e);
|
|
|
+ }
|
|
|
+ },
|
|
|
updateOlCss() {
|
|
|
this.$nextTick(() => {
|
|
|
const mapStage = this.$refs.mapStage;
|
|
|
@@ -414,11 +440,41 @@ export default {
|
|
|
},
|
|
|
|
|
|
// 添加标定
|
|
|
+addCalibration() {
|
|
|
+ // 每次添加前,先根据现有列表重新排一次 id,保证连续
|
|
|
+ this.calibrationList = this.calibrationList.map((item, index) => {
|
|
|
+ return { ...item, id: index + 1 };
|
|
|
+ });
|
|
|
+
|
|
|
+ // 新的 id 就是当前长度+1
|
|
|
+ const newId = this.calibrationList.length + 1;
|
|
|
+ const coordinate = `${this.laserPositionData.x},${this.laserPositionData.y}`;
|
|
|
+ const data = { id: newId, coordinate, angle: this.laserPositionData.angle };
|
|
|
+
|
|
|
+ this.calibrationList.push(data);
|
|
|
+ this.nowCalibId = newId;
|
|
|
+},
|
|
|
+
|
|
|
+// 移除标定
|
|
|
+removeCalibration(id) {
|
|
|
+ if (this.calibrationList.length < 1) return;
|
|
|
+
|
|
|
+ // 过滤掉要删除的
|
|
|
+ this.calibrationList = this.calibrationList.filter(item => item.id !== id);
|
|
|
+
|
|
|
+ // 删除后重新编号,保证 id 连续
|
|
|
+ this.calibrationList = this.calibrationList.map((item, index) => {
|
|
|
+ return { ...item, id: index + 1 };
|
|
|
+ });
|
|
|
+
|
|
|
+ this.nowCalibId = -1; // 标记无选中
|
|
|
+},
|
|
|
+/* // 添加标定
|
|
|
addCalibration() {
|
|
|
// 需要获取无人车实时坐标, 现在先写死
|
|
|
this.nowCalibId = this.calibrationList.length > 0 ? this.calibrationList[this.calibrationList.length - 1].id + 1 : 1;
|
|
|
let coordinate = `${this.laserPositionData.x},${this.laserPositionData.y}`
|
|
|
- let data = { id: this.nowCalibId, coordinate: coordinate, angle: this.laserPositionData.angle }
|
|
|
+ let data = { id: this.nowCalibId, coordinate: coordinate, angle: this.laserPositionData.angle }
|
|
|
this.calibrationList.push(data)
|
|
|
},
|
|
|
|
|
|
@@ -430,7 +486,7 @@ export default {
|
|
|
this.calibrationList = this.calibrationList.filter(item => item.id !== id);
|
|
|
// 删除图标
|
|
|
this.nowCalibId = - id;
|
|
|
- },
|
|
|
+ }, */
|
|
|
|
|
|
// 一键标定
|
|
|
executeCalibration() {
|