提交 677b1f49 作者: 温凯

fix:摇杆控制更改

上级 fdf72e82
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<img src="./assets/images/auto.svg" /> <img src="./assets/images/auto.svg" />
<span class="dib">自动</span> <span class="dib">自动</span>
</div> </div>
<div v-else-if="controlType === 1" class="control-bottom-item" @click="onModeKeyboard"> <div v-else-if="controlType === 1" :class="manualControlStatus? 'active control-bottom-item':'control-bottom-item'" @click="onModeKeyboard">
<img src="./assets/images/manual.svg" /> <img src="./assets/images/manual.svg" />
<span class="dib">摇杆</span> <span class="dib">摇杆</span>
</div> </div>
...@@ -68,11 +68,33 @@ export default { ...@@ -68,11 +68,33 @@ export default {
}, },
data() { data() {
return { return {
// 摇杆手动控制状态
manualControlStatus:false,
controlType: 0, //控制类型, 0: 自动 1: 摇杆 2: 键盘 controlType: 0, //控制类型, 0: 自动 1: 摇杆 2: 键盘
}; };
}, },
watch: {
// 状态改变时摇杆会切换为手动模式
"onModeManualState":{
handler(val) {
if(val){
this.onModeManual()
}
}
},
"manualControlStatus": {
handler(val) {
this.$store.commit("MMCFlightControlCenter/joystick/setState", {
key: "manualControlStatus",
value: val,
});
},
},
immediate: true,
},
computed: { computed: {
...mapState("MMCFlightControlCenter/uav", ["uav", "airlineData"]), ...mapState("MMCFlightControlCenter/uav", ["uav", "airlineData"]),
...mapState("MMCFlightControlCenter/joystick", ["onModeManualState"]),
}, },
methods: { methods: {
/** /**
...@@ -245,6 +267,9 @@ export default { ...@@ -245,6 +267,9 @@ export default {
transform: scale(1.1); transform: scale(1.1);
} }
} }
.active{
background-color: #0cc81f;
}
} }
.key-control { .key-control {
......
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
<div> <div>
<div class="nset_control_box dialog1027" v-if="show"> <div class="nset_control_box dialog1027" v-if="show">
<div class="dialog-header"> <div class="dialog-header">
<img class="dialog-header__icon" src="../../assets/images/mount_head.png" /> <img
class="dialog-header__icon"
src="../../assets/images/mount_head.png"
/>
<div class="dialog-header__title">操作区域</div> <div class="dialog-header__title">操作区域</div>
<div class="dialog-header__close" @click="$emit('exit')">关闭</div> <div class="dialog-header__close" @click="$emit('exit')">关闭</div>
</div> </div>
...@@ -32,11 +35,19 @@ ...@@ -32,11 +35,19 @@
<SymbolIcon icon="yunhangrizhi2" /> <SymbolIcon icon="yunhangrizhi2" />
<span class="txt">运行日志</span> <span class="txt">运行日志</span>
</div> </div>
<div class="item" @click="guideFlight" v-if="uav && uav.network === 2"> <div
class="item"
@click="guideFlight"
v-if="uav && uav.network === 2"
>
<SymbolIcon icon="tiaozhuandaozuobiao" /> <SymbolIcon icon="tiaozhuandaozuobiao" />
<span class="txt">指点飞行</span> <span class="txt">指点飞行</span>
</div> </div>
<div class="item" @click="onInfieldControl" v-if="uav && uav.network === 2"> <div
class="item"
@click="onInfieldControl"
v-if="uav && uav.network === 2"
>
<img class="dib mt3" src="./assets/images/1.svg" alt /> <img class="dib mt3" src="./assets/images/1.svg" alt />
<span class="txt">内场控制</span> <span class="txt">内场控制</span>
</div> </div>
...@@ -52,7 +63,9 @@ ...@@ -52,7 +63,9 @@
> >
<div class="endrenwu"> <div class="endrenwu">
<div class="tishiyu">紧急迫降</div> <div class="tishiyu">紧急迫降</div>
<div class="queding">无人机即将原地降落,请确认无人机下方是否安全!</div> <div class="queding">
无人机即将原地降落,请确认无人机下方是否安全!
</div>
<div class="btn_kuang"> <div class="btn_kuang">
<div class="btn btn_lan" @click="safetyNotice = false">取消</div> <div class="btn btn_lan" @click="safetyNotice = false">取消</div>
<div style="width: 20px"></div> <div style="width: 20px"></div>
...@@ -66,15 +79,19 @@ ...@@ -66,15 +79,19 @@
:visible.sync="showInfieldControlDialog" :visible.sync="showInfieldControlDialog"
width="30%" width="30%"
:append-to-body="true" :append-to-body="true"
custom-class="mmc"
style="margin-top: 20vh" style="margin-top: 20vh"
> >
<div class="endrenwu"> <div class="endrenwu">
<div class="tishiyu">温馨提示</div> <div class="tishiyu">温馨提示</div>
<div class="queding" v-if="!isAcceleratorMedian"> <div class="queding" v-if="!isAcceleratorMedian">
当前油门值为 当前油门值为
<span style="color:red">{{uavRealTimeData.rcChannelState.toFixed(2)||0}}</span>,请调到中位(470-530) <span style="color: red">{{ throttleValue.toFixed(2) || 0 }}</span
>,请调到中位(470-530)
</div>
<div class="queding" v-if="isAcceleratorMedian">
摇杆已处于中位,即将切换内场权限
</div> </div>
<div class="queding" v-if="isAcceleratorMedian">摇杆已处于中位,即将切换内场权限</div>
</div> </div>
</el-dialog> </el-dialog>
<el-dialog <el-dialog
...@@ -92,8 +109,11 @@ ...@@ -92,8 +109,11 @@
<div class="queding">位置获取成功,请确认是否进行指点模式飞行</div> <div class="queding">位置获取成功,请确认是否进行指点模式飞行</div>
<div class="fleSpeed"> <div class="fleSpeed">
指点飞行速度: 指点飞行速度:
<el-input oninput="value=value.replace(/[^0-9.]/g,'')" v-model="flySpeed"></el-input> <el-input
<span style="opacity: 0;">1</span>(米/秒) oninput="value=value.replace(/[^0-9.]/g,'')"
v-model="flySpeed"
></el-input>
<span style="opacity: 0">1</span>(米/秒)
</div> </div>
<div class="red" v-if="maxSpeed">指点飞行最大速度为8米/秒</div> <div class="red" v-if="maxSpeed">指点飞行最大速度为8米/秒</div>
<div class="btn_kuang"> <div class="btn_kuang">
...@@ -161,9 +181,16 @@ export default { ...@@ -161,9 +181,16 @@ export default {
"uavRealTimeData", "uavRealTimeData",
]), ]),
...mapState("MMCFlightControlCenter", ["userInfo", "cesiumViewer"]), ...mapState("MMCFlightControlCenter", ["userInfo", "cesiumViewer"]),
...mapState("MMCFlightControlCenter/joystick", [
"throttleValue",
"manualControlStatus",
]),
}, },
watch: { watch: {
"uavRealTimeData.rcChannelState"(val) { throttleValue(val) {
if (val == -1) {
this.showInfieldControlDialog = true;
}
// 判断是否为外场权限 // 判断是否为外场权限
if (this.uavRealTimeData.rcState == 0) { if (this.uavRealTimeData.rcState == 0) {
// 判断油门是否处于中位 // 判断油门是否处于中位
...@@ -180,7 +207,14 @@ export default { ...@@ -180,7 +207,14 @@ export default {
); );
setTimeout(() => { setTimeout(() => {
if (this.uavRealTimeData.rcState == 1) { if (this.uavRealTimeData.rcState == 1) {
// 摇杆切换为手动模式
if (!this.manualControlStatus) {
this.$message.success("已切换内场权限,摇杆即将切换为手动模式!");
this.changeModeManualState();
}else{
this.$message.success("已切换内场权限,请使用摇杆控制!"); this.$message.success("已切换内场权限,请使用摇杆控制!");
}
this.showInfieldControlDialog = false; this.showInfieldControlDialog = false;
} else { } else {
// this.$message.error("摇杆权限切换失败"); // this.$message.error("摇杆权限切换失败");
...@@ -208,13 +242,13 @@ export default { ...@@ -208,13 +242,13 @@ export default {
"routeControl", "routeControl",
"isTakeOver", "isTakeOver",
]), ]),
isTakeOverHangar(){ isTakeOverHangar() {
return this.$store.dispatch("MMCFlightControlCenter/hangar/isTakeOver"); return this.$store.dispatch("MMCFlightControlCenter/hangar/isTakeOver");
}, },
async isTake() { async isTake() {
// 判断是否已接管 // 判断是否已接管
let isTakeOver = this.isTakeOver; let isTakeOver = this.isTakeOver;
if(this.isHangar){ if (this.isHangar) {
isTakeOver = this.isTakeOverHangar; isTakeOver = this.isTakeOverHangar;
} }
if (!(await isTakeOver())) { if (!(await isTakeOver())) {
...@@ -229,7 +263,7 @@ export default { ...@@ -229,7 +263,7 @@ export default {
async onSwitchAirline() { async onSwitchAirline() {
// 判断是否已接管 // 判断是否已接管
let isTakeOver = this.isTakeOver; let isTakeOver = this.isTakeOver;
if(this.isHangar){ if (this.isHangar) {
isTakeOver = this.isTakeOverHangar; isTakeOver = this.isTakeOverHangar;
} }
if (!(await isTakeOver())) { if (!(await isTakeOver())) {
...@@ -279,6 +313,12 @@ export default { ...@@ -279,6 +313,12 @@ export default {
this.safetyNotice = false; this.safetyNotice = false;
this.land(); this.land();
}, },
changeModeManualState() {
this.$store.commit("MMCFlightControlCenter/joystick/setState", {
key: "onModeManualState",
value: new Date().getTime(),
});
},
/** /**
* 内场控制 * 内场控制
*/ */
...@@ -293,7 +333,14 @@ export default { ...@@ -293,7 +333,14 @@ export default {
if (this.uavRealTimeData.rcState == 1) { if (this.uavRealTimeData.rcState == 1) {
this.$message.success("当前处于内场模式,请使用摇杆控制!"); this.$message.success("当前处于内场模式,请使用摇杆控制!");
} else { } else {
this.showInfieldControlDialog = true; // 如果摇杆是手动模式,则展示油门弹窗
if (this.manualControlStatus) {
this.showInfieldControlDialog = true;
} else {
this.$message.success("摇杆即将切换为手动模式,请稍等!");
// onModeKeyboard
this.changeModeManualState();
}
} }
}, },
/** /**
...@@ -325,15 +372,15 @@ export default { ...@@ -325,15 +372,15 @@ export default {
* 指点飞行 * 指点飞行
*/ */
async guideFlight() { async guideFlight() {
// 判断是否已接管 // // 判断是否已接管
if (!(await this.isTake())) { // if (!(await this.isTake())) {
return; // return;
} // }
if (this.uav.online === 0) // if (this.uav.online === 0)
return this.$message.warning("处于离线状态,不可操作!"); // return this.$message.warning("处于离线状态,不可操作!");
if (!this.guideFlightDone) { // if (!this.guideFlightDone) {
return this.$message.warning("指点飞行操作中!"); // return this.$message.warning("指点飞行操作中!");
} // }
let viewer = this.cesiumViewer; let viewer = this.cesiumViewer;
// 指点飞行 wgs84 // 指点飞行 wgs84
......
...@@ -2,10 +2,15 @@ ...@@ -2,10 +2,15 @@
<div class="mountBox"> <div class="mountBox">
<div class="main" v-if="show"> <div class="main" v-if="show">
<div v-if="mountList.length > 0" class="list"> <div v-if="mountList.length > 0" class="list">
<div class="mount-item pr mt6" :class="{ <div
active: class="mount-item pr mt6"
(selectMount && selectMount.gimbalName) === item.gimbalName, :class="{
}" v-for="(item, index) in mountList" :key="index"> active:
(selectMount && selectMount.gimbalName) === item.gimbalName,
}"
v-for="(item, index) in mountList"
:key="index"
>
<div class="icon-box" @click="onSelectMount(item)"> <div class="icon-box" @click="onSelectMount(item)">
<img class :src="item.icon" /> <img class :src="item.icon" />
</div> </div>
...@@ -13,15 +18,23 @@ ...@@ -13,15 +18,23 @@
</div> </div>
</div> </div>
<template v-if="selectMount"> <template v-if="selectMount">
<component :is="selectMount.gimbalName" v-if="selectMount" class="mount-panel" :keyFlag="nxNormal" <component
:payload_data="selectMountPayload" @directive="mountDirective" @take_photo="mountTakePhoto" :is="selectMount.gimbalName"
@record="mountRecord" @close="mountClose" /> v-if="selectMount"
class="mount-panel"
:keyFlag="nxNormal"
:payload_data="selectMountPayload"
@directive="mountDirective"
@take_photo="mountTakePhoto"
@record="mountRecord"
@close="mountClose"
/>
</template> </template>
</div> </div>
</template> </template>
<script> <script>
// import API from "@/api"; // import API from "@/api";
import { mapState, mapGetters, mapActions } from "vuex"; import { mapState, mapGetters } from "vuex";
import mount from "../../../../../../../../../MMCMount"; import mount from "../../../../../../../../../MMCMount";
// 所有的挂载组件 // 所有的挂载组件
const mountComponents = {}; const mountComponents = {};
...@@ -35,11 +48,6 @@ export default { ...@@ -35,11 +48,6 @@ export default {
...mountComponents, ...mountComponents,
}, },
props: { props: {
// 是否机库页面使用
isHangar: {
type: Boolean,
default: false,
},
show: { show: {
type: Boolean, type: Boolean,
default: false, default: false,
...@@ -52,10 +60,6 @@ export default { ...@@ -52,10 +60,6 @@ export default {
type: Boolean, type: Boolean,
default: () => false, default: () => false,
}, },
isHangar: {
type: Boolean,
default: false,
},
}, },
data() { data() {
return {}; return {};
...@@ -71,36 +75,18 @@ export default { ...@@ -71,36 +75,18 @@ export default {
]), ]),
...mapGetters("MMCFlightControlCenter/uav", ["selectMountPayload"]), ...mapGetters("MMCFlightControlCenter/uav", ["selectMountPayload"]),
nxNormal() { nxNormal() {
return this.uavRealTimeData?.healthData?.NX?.code === "0x2110000"; return this.uavRealTimeData?.healthData?.NX?.warningLevel === "NORMAL";
}, },
}, },
created() { }, created() {},
mounted() { }, mounted() {},
beforeDestroy() { }, beforeDestroy() {},
methods: { methods: {
...mapActions("MMCFlightControlCenter/uav", ["isTakeOver"]), onSelectMount(item) {
isTakeOverHangar() { this.$store.commit("MMCFlightControlCenter/uav/setState", {
return this.$store.dispatch("MMCFlightControlCenter/hangar/isTakeOver"); key: "selectMount",
}, value: item,
async isTake() { });
// 判断是否已接管
let isTakeOver = this.isTakeOver;
if (this.isHangar) {
isTakeOver = this.isTakeOverHangar;
}
if (!(await isTakeOver())) {
this.$message.warning("请先接管设备");
return false;
}
return true;
},
async onSelectMount(item) {
if (await this.isTake()) {
this.$store.commit("MMCFlightControlCenter/uav/setState", {
key: "selectMount",
value: item,
});
}
}, },
/** /**
* 挂载指令事件 * 挂载指令事件
......
...@@ -32,7 +32,7 @@ export default { ...@@ -32,7 +32,7 @@ export default {
type: 513, type: 513,
data: val, data: val,
}, },
callback() {}, callback() { },
}); });
}, },
}, },
...@@ -50,7 +50,7 @@ export default { ...@@ -50,7 +50,7 @@ export default {
let topic = `${uavCate}/OBTAIN/${this.uav.deviceId}`; let topic = `${uavCate}/OBTAIN/${this.uav.deviceId}`;
this.wsJoystick = new WebSocket("ws://127.0.0.1:8802"); this.wsJoystick = new WebSocket("ws://127.0.0.1:8802");
this.wsJoystick.onopen = () => { this.wsJoystick.onopen = () => {
console.log("joystick.js 连接上 ws://127.0.0.1:8802"); console.log("joystick.js 连接上 ws://127.0.0.1:8802 1112222");
this.wsJoystick.send( this.wsJoystick.send(
JSON.stringify({ JSON.stringify({
type: 2003, type: 2003,
...@@ -72,9 +72,8 @@ export default { ...@@ -72,9 +72,8 @@ export default {
if (obj.type == 518) { if (obj.type == 518) {
} }
let data = JSON.parse(event.currentTarget.result).data; let data = JSON.parse(event.currentTarget.result).data;
window.$log("joystick.js message", data);
let y = data.channel03; //油门值 0-1000 let y = data.channel03; //油门值 0-1000
this.keyboardFlag = true
// console.log(data.channel03,data,"yyyyyyyy"); // console.log(data.channel03,data,"yyyyyyyy");
if (y || y == 0) { if (y || y == 0) {
this.$store.commit("MMCFlightControlCenter/joystick/setState", { this.$store.commit("MMCFlightControlCenter/joystick/setState", {
...@@ -180,6 +179,7 @@ export default { ...@@ -180,6 +179,7 @@ export default {
return; return;
} }
this.cameraMountCtr("stop", this.lastMountCtrl); this.cameraMountCtr("stop", this.lastMountCtrl);
this.keyboardFlag = false
setTimeout(() => { setTimeout(() => {
this.wsJoystick.send(JSON.stringify({ type: 2010, data: {} })); this.wsJoystick.send(JSON.stringify({ type: 2010, data: {} }));
this.wsJoystick && this.wsJoystick.close(); this.wsJoystick && this.wsJoystick.close();
...@@ -248,7 +248,7 @@ export default { ...@@ -248,7 +248,7 @@ export default {
payload: buffer, payload: buffer,
}, },
}, },
callback() {}, callback() { },
}); });
}, },
}, },
......
const state = { const state = {
throttleValue: 0, //油门值 throttleValue: 0, //油门值
manualControlStatus: false, //是否手动控制
onModeManualState:null, //状态改变时摇杆会切换为手动模式
}; };
const mutations = { const mutations = {
...@@ -25,7 +27,7 @@ const getters = { ...@@ -25,7 +27,7 @@ const getters = {
* @param {*} state * @param {*} state
* @returns * @returns
*/ */
isThrottleCenter(state){ isThrottleCenter(state) {
if (state.throttleValue >= 470 && state.throttleValue <= 530) { if (state.throttleValue >= 470 && state.throttleValue <= 530) {
return true; return true;
} else { } else {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论