飞行控制测试

main
刘妍 3 months ago
parent d87f7aa4d1
commit 2175a797d7

@ -10,24 +10,24 @@ export const return_home_status = {
sent: '已下发',
timeout: '超时',
};
export const eventsTopic = (data) => {
export const eventsTopicReize = (data) => {
// 发送消息
clientReizePublish('thing/product/8UUXN5400A079H/events', data);
};
export const events_replyTopic = () => {
export const events_replyTopicReize = () => {
// 订阅消息
clientReizeSubscribe('thing/product/8UUXN5400A079H/events_reply');
};
export const servicesTopic = (data) => {
export const servicesTopicReize = (data) => {
// 发送消息
clientReizePublish('thing/product/8UUXN5400A079H/services', data);
};
export const services_replyTopic = () => {
export const services_replyTopicReize = () => {
// 订阅消息
clientReizeSubscribe('thing/product/8UUXN5400A079H/services_reply');
};
export const drcDownTopic = (data) => {
export const drcDownTopicReize = (data) => {
// 发送消息thing/product/{gateway_sn}/drc/down
clientReizePublish('thing/product/8UUXN5400A079H/drc/down', data);
};

@ -49,16 +49,16 @@ const createConnection = (callback?) => {
const connectUrl = `${protocol}://${host}:${port}${endpoint}`;
client = mqtt.connect(connectUrl, options);
client.on('connect', () => {
console.log('✅ 已连接');
// console.log('✅ 已连接');
if(callback){
callback()
}
});
client.on('close', () => {
console.log('❌ 连接已关闭');
// console.log('❌ 连接已关闭');
});
client.on('error', (err) => {
console.error('❌ 出错了:', err);
// console.error('❌ 出错了:', err);
});
if (client.on) {
}
@ -127,7 +127,7 @@ const getConnectStatus = () => {
// unsubscribe 事件 取消订阅
// 抢夺负载权、飞行控制权的时候使用
const client_seize: any = {
let client_seize: any = {
connected: false,
};
const createSeizeConnection = () => {
@ -145,7 +145,7 @@ const createSeizeConnection = () => {
};
const getReizeClient = () => {
if (!client_seize || !client_seize.connected) {
getReizeClient();
createSeizeConnection();
}
return client_seize;
};

@ -8,11 +8,13 @@
</div>
<div class="content">
<div class="content-button">
<a-button @click="obtain"></a-button>
<a-button @click="emits('clickTakeOff')"></a-button>
<a-button>指点飞行</a-button>
<!-- <a-button>智能环绕</a-button> -->
<a-button @click="returnVoyage"></a-button>
<a-button @click="obtain"></a-button>
<a-button @click="enterDRC"></a-button>
<a-button @click="exitDRC">退</a-button>
</div>
<div class="content-info">
<div class="info-item">
@ -40,12 +42,14 @@
import { vDrag } from '@/utils/drag';
import { getReizeClient, createSeizeConnection, clientReizePublish } from '@/utils/mqtt';
import {
eventsTopic,
events_replyTopic,
drcDownTopic,
servicesTopic,
eventsTopicReize,
events_replyTopicReize,
drcDownTopicReize,
servicesTopicReize,
services_replyTopicReize,
return_home_status,
} from '@/utils/debugging/events';
import { servicesTopic } from '@/utils/debugging/remote';
import { buildGUID } from '@/utils/uuid';
import { useMessage } from '@/hooks/web/useMessage';
@ -90,7 +94,7 @@
}
setTimeout(() => {
//
eventsTopic({
servicesTopicReize({
bid: buildGUID(),
method: 'flight_authority_grab',
tid: buildGUID(),
@ -98,7 +102,7 @@
data: {},
});
//
eventsTopic({
servicesTopicReize({
bid: buildGUID(),
method: 'payload_authority_grab',
tid: buildGUID(),
@ -107,20 +111,33 @@
payload_index: '99-0-0',
},
});
events_replyTopic();
events_replyTopicReize();
services_replyTopicReize();
// //
getReizeClient().on('message', (topic, message) => {
const rs = JSON.parse(message);
console.log(rs);
//
if (rs.method === 'return_home') {
createMessage.info(return_home_status[rs.data.output.status]);
if (rs.data.result == 0) {
createMessage.success('一键返航成功');
} else {
createMessage.error('一键返航失败,状态码' + rs.data.result);
}
}
if (rs.method === 'takeoff_to_point') {
if (rs.data.result == 0) {
createMessage.success('一键起飞成功');
} else {
createMessage.error('一键起飞失败,状态码' + rs.data.result);
}
}
});
}, 1000);
};
//
const returnVoyage = () => {
//
servicesTopic({
bid: buildGUID(),
method: 'return_home',
@ -128,21 +145,79 @@
timestamp: new Date().getTime(),
data: {},
});
// servicesTopicReize
};
const seq = ref(1);
const changeDRC = (type, value) => {
seq.value = seq.value + 1;
if (value == 'up') {
data[type] = data[type] + 20;
} else {
data[type] = data[type] - 20;
}
const querys = {
seq: 1,
seq: seq.value,
method: 'stick_control',
data: data,
};
drcDownTopic(querys);
console.log(querys);
drcDownTopicReize(querys);
};
onMounted(() => {});
const enterDRC = () => {
// http://175.27.168.120:6012/players/srs_player.html?schema=http&port=6012&api=6012
const querys = {
bid: buildGUID(),
data: {
hsi_frequency: 10,
mqtt_broker: {
address: 'http://175.27.168.120:6010',
client_id: 'mqtt_client_1581F8HGX254V00A0BUY_seize',
enable_tls: false,
expire_time: 3600,
password: '',
username: 'sdhc',
},
osd_frequency: 5,
},
tid: buildGUID(),
timestamp: new Date().getTime(),
method: 'drc_mode_enter',
};
console.log(querys);
servicesTopicReize(querys);
};
const exitDRC = () => {
const querys = {
bid: buildGUID(),
data: {},
tid: buildGUID(),
timestamp: new Date().getTime(),
method: 'drc_mode_exit',
};
servicesTopicReize(querys);
};
onMounted(() => {
// //
getReizeClient().on('message', (topic, message) => {
const rs = JSON.parse(message);
if (rs.method == 'drc_mode_enter') {
console.log(rs);
if (rs.data.result == 0) {
createMessage.success('进入指令飞行控制模式成功');
} else {
createMessage.error('进入指令飞行控制模式失败,状态码' + rs.data.result);
}
}
if (rs.method == 'drc_mode_exit') {
console.log(rs);
if (rs.data.result == 0) {
createMessage.success('退出指令飞行控制模式成功');
} else {
createMessage.error('退出指令飞行控制模式失败,状态码' + rs.data.result);
}
}
});
});
</script>
<style lang="less" scoped>
.flight-control {

@ -47,7 +47,12 @@
import { CloseOutlined } from '@ant-design/icons-vue';
import { vDrag } from '@/utils/drag';
import { buildGUID } from '@/utils/uuid';
import { eventsTopic, events_replyTopic, drcDownTopic } from '@/utils/debugging/events';
import {
eventsTopicReize,
events_replyTopicReize,
drcDownTopicReize,
servicesTopicReize,
} from '@/utils/debugging/events';
const emits = defineEmits(['changeLoadControl']);
const props = defineProps({
@ -90,7 +95,7 @@
}
setTimeout(() => {
//
eventsTopic({
servicesTopicReize({
bid: buildGUID(),
method: 'flight_authority_grab',
tid: buildGUID(),
@ -98,7 +103,7 @@
data: {},
});
//
eventsTopic({
servicesTopicReize({
bid: buildGUID(),
method: 'payload_authority_grab',
tid: buildGUID(),
@ -107,13 +112,13 @@
payload_index: '99-0-0',
},
});
events_replyTopic();
events_replyTopicReize();
}, 1000);
};
//
const singleShot = () => {
//
eventsTopic({
eventsTopicReize({
bid: buildGUID(),
method: 'camera_photo_take',
tid: buildGUID(),
@ -135,14 +140,16 @@
method: 'stick_control',
data: drcVal,
};
drcDownTopic(querys);
drcDownTopicReize(querys);
};
onMounted(() => {
// //
// getReizeClient().on('message', (topic, message) => {
// const rs = JSON.parse(message);
// console.log(rs);
// });
getReizeClient().on('message', (topic, message) => {
const rs = JSON.parse(message);
if (rs.method == 'takeoff_to_point') {
console.log(rs);
}
});
});
</script>
<style lang="less" scoped>

@ -93,7 +93,8 @@
import { CopyOutlined, EditOutlined } from '@ant-design/icons-vue';
import { timestampToFormattedDate } from '@/utils/index';
import { buildGUID, uuid } from '@/utils/uuid';
import { servicesTopic, services_replyTopic } from '@/utils/debugging/events';
import { servicesTopicReize, services_replyTopicReize } from '@/utils/debugging/events';
import { servicesTopic, services_replyTopic } from '@/utils/debugging/remote';
import { vDrag } from '@/utils/drag';
import { CloseOutlined } from '@ant-design/icons-vue';
@ -115,11 +116,11 @@
commander_mode_lost_action: 1,
commander_flight_height: 115.0,
flight_safety_advance_check: 1,
simulate_mission: {
is_enable: 1, // {"0":"","1":""}
latitude: 35.143567, //
longitude: 118.305623, //
},
// simulate_mission: {
// is_enable: 1, // {"0":"","1":""}
// latitude: 35.143567, //
// longitude: 118.305623, //
// },
});
const uavInformation = ref({
sub_device: {
@ -185,7 +186,12 @@
method: 'takeoff_to_point',
};
console.log(querys);
//
// servicesTopicReize(querys);
// services_replyTopicReize();
//
servicesTopic(querys);
services_replyTopic();
setTimeout(() => {
emits('changeTakeOffForm');
}, 1000);

Loading…
Cancel
Save