diff --git a/package-lock.json b/package-lock.json index 4f5c1ff..2c416e6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -616,7 +616,6 @@ "integrity": "sha512-zx0EIq78WlY/lBb1uXlziZmDZI4ubcCXIMJ4uGjXzZW0nS19TjSPeXPAjzzTmKQlJUZm0SbmZhPKP7tuQ1SsEw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "chalk": "^4.1.1", "fs-extra": "^9.0.1", @@ -1753,7 +1752,6 @@ "integrity": "sha512-yl43JD/86CIj3Mz5mvvLJqAOfIup7ncxfJ0Btnl0/v5TouVUyeEdcpknfgc+yMevS/48oH9WAkkw93m7otLb/A==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@inquirer/checkbox": "^3.0.1", "@inquirer/confirm": "^4.0.1", @@ -2912,7 +2910,6 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -2979,7 +2976,6 @@ "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", @@ -3197,7 +3193,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", @@ -4504,6 +4499,17 @@ "dev": true, "license": "MIT" }, + "node_modules/encoding": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz", + "integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "iconv-lite": "^0.6.2" + } + }, "node_modules/end-of-stream": { "version": "1.4.5", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz", @@ -8024,7 +8030,6 @@ "integrity": "sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "esbuild": "^0.21.3", "postcss": "^8.4.43", @@ -8084,7 +8089,6 @@ "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.28.tgz", "integrity": "sha512-BRdrNfeoccSoIZeIhyPBfvWSLFP4q8J3u8Ju8Ug5vu3LdD+yTM13Sg4sKtljxozbnuMu1NB1X5HBHRYUzFocKg==", "license": "MIT", - "peer": true, "dependencies": { "@vue/compiler-dom": "3.5.28", "@vue/compiler-sfc": "3.5.28", @@ -8138,7 +8142,6 @@ "integrity": "sha512-gX/dMkRQc7QOMzgTe6KsYFM7DxeIONQSui1s0n/0xht36HvrgbxtM1xBlgx596NbpHuQU8P7QpKwrZYwUX48nw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@types/eslint-scope": "^3.7.7", "@types/estree": "^1.0.8", diff --git a/public/images/qr.jpg b/public/images/qr.jpg new file mode 100644 index 0000000..61474b1 Binary files /dev/null and b/public/images/qr.jpg differ diff --git a/public/shablons/qr.txt b/public/shablons/qr.txt index 32220f8..c877557 100644 --- a/public/shablons/qr.txt +++ b/public/shablons/qr.txt @@ -4,4 +4,9 @@ def qr_detection(data): if barcodes: qr_data = barcodes[0].data.decode('utf-8') - return qr_data \ No newline at end of file + return qr_data + +<> + qr_sub = rospy.Subscriber('main_camera/image_raw', Image, qr_detection, queue_size=1) + rospy.sleep(2) + qr_sub.unregister() \ No newline at end of file diff --git a/src/App.vue b/src/App.vue index 0c2713a..64395fb 100644 --- a/src/App.vue +++ b/src/App.vue @@ -12,12 +12,6 @@ const clickCount = ref(1); // Счетчик нажатий const listOfTrips = ref([]); const isModalVisible = ref(false); let finallyText = ref(""); -const qr_sub_text = ` - \tqr_sub = rospy.Subscriber('main_camera/image_raw',Image, qr_detection,queue_size=1)\n - \trospy.sleep(2)\n - \tqr_sub.unregister()\n -` -let is_qr__head_used = 0; onMounted(() => { for (let i = 0; i < 100; i++) { @@ -27,6 +21,7 @@ onMounted(() => { y: 9 - Math.floor(i / 10), index: i, isPlatform: false, + isQR: false, BgImg: 'images/ArUco-marker.jpg' }); } @@ -58,8 +53,11 @@ async function saveResult() { finallyText.value = ""; const mainCode = ref(""); const colorDetectClass = ref(""); + const QRDetectClass = ref(""); const colorDetectCode = ref(""); + const QRDetectCode = ref(""); const isUsedPlatform = listOfTrips.value.some(item => item.isPlatform); + const isUsedQR = listOfTrips.value.some(item => item.isQR); if (isUsedPlatform) { const response = await fetch("/shablons/color.txt") @@ -69,11 +67,22 @@ async function saveResult() { colorDetectCode.value += `\t${textOfCode[1].trim()}\n`; } + if (isUsedQR) { + const response = await fetch("/shablons/qr.txt") + let textOfCode = await response.text() + textOfCode = textOfCode.split('<>') + QRDetectClass.value = textOfCode[0] + QRDetectCode.value += `\t${textOfCode[1].trim()}\n`; + } + for (const item of listOfTrips.value) { mainCode.value += `\tnavigate_wait(${item.x}, ${item.y})\n`; - if (isUsedPlatform) { + if (item.isPlatform) { mainCode.value += colorDetectCode.value + '\n' } + if (item.isQR) { + mainCode.value += QRDetectCode.value + '\n' + } } const response = await fetch("/shablons/emergency_and_navigate.txt") let textOfCode = await response.text() @@ -81,20 +90,11 @@ async function saveResult() { if (isUsedPlatform) { finallyText.value = finallyText.value.replace("<>", colorDetectClass.value); } - isModalVisible.value = true; - if (is_qr__head_used === 1) { - Qr_head() - is_qr__head_used +=1 + if (isUsedQR) { + finallyText.value = finallyText.value.replace("<>", QRDetectClass.value); } -} - -function Qr_head() { - fetch("/shablons/qr.txt") - .then((response) => response.text()) - .then((textOfCode) => { - finallyText = finallyText.replace("<>", textOfCode); - }) -} + isModalVisible.value = true;} + function cancel() { @@ -177,6 +177,26 @@ function deletePlatform(item) { clickCount.value-- } +function createQR(item) { + if (!item.isQR) { + listOfTrips.value.push(item) + numbers.value[item.index].variable.push(clickCount.value); + } + item['isQR'] = true + numbers.value[item.index].BgImg = `images/qr.jpg` + clickCount.value++ +} + +function deleteQR(item) { + item['isQR'] = false + const index = listOfTrips.value.indexOf(item); + if (index !== -1) { + listOfTrips.value.splice(index, 1); + } + numbers.value[item.index].BgImg = 'images/ArUco-marker.jpg' + clickCount.value-- +} + function onContextMenu(e, item) { ContextMenu.showContextMenu({ theme: 'mac dark', @@ -209,11 +229,11 @@ function onContextMenu(e, item) { children: [ { label: "Добавить", - onClick: () => alert('Здесь ещё предстоит написать код') + onClick: () => createQR(item) }, { label: "Удалить", - onClick: () => alert('Здесь ещё предстоит написать код') + onClick: () => deleteQR(item) }, ], },