Merge pull request #3 from IliaMiheev/miheev-dev
Miheev dev
@@ -9,6 +9,7 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@imengyu/vue3-context-menu": "^1.5.4",
|
||||||
"@vueuse/core": "^14.2.1",
|
"@vueuse/core": "^14.2.1",
|
||||||
"copy-to-clipboard": "^3.3.3",
|
"copy-to-clipboard": "^3.3.3",
|
||||||
"electron-squirrel-startup": "^1.0.1",
|
"electron-squirrel-startup": "^1.0.1",
|
||||||
@@ -615,7 +616,6 @@
|
|||||||
"integrity": "sha512-zx0EIq78WlY/lBb1uXlziZmDZI4ubcCXIMJ4uGjXzZW0nS19TjSPeXPAjzzTmKQlJUZm0SbmZhPKP7tuQ1SsEw==",
|
"integrity": "sha512-zx0EIq78WlY/lBb1uXlziZmDZI4ubcCXIMJ4uGjXzZW0nS19TjSPeXPAjzzTmKQlJUZm0SbmZhPKP7tuQ1SsEw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chalk": "^4.1.1",
|
"chalk": "^4.1.1",
|
||||||
"fs-extra": "^9.0.1",
|
"fs-extra": "^9.0.1",
|
||||||
@@ -1406,6 +1406,21 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/@imengyu/vue-scroll-rect": {
|
||||||
|
"version": "0.1.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/@imengyu/vue-scroll-rect/-/vue-scroll-rect-0.1.8.tgz",
|
||||||
|
"integrity": "sha512-Mg7rgHlsGPO0tcMFjp1kB2BZ3oRrRtFN8MoE52jTgQnlc+Y0N6ttFnbIxOh2fc9j82uhdQ8zgZcXlFHUXeGnCA==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/@imengyu/vue3-context-menu": {
|
||||||
|
"version": "1.5.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@imengyu/vue3-context-menu/-/vue3-context-menu-1.5.4.tgz",
|
||||||
|
"integrity": "sha512-/a6Quyn3V320/Mi6UoH+6wSTBYrln70RovT3iyfoXQQpIHpC7ZPWObzS0BXQTRlWtyJB92XmGDT703UxSO8Tvg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@imengyu/vue-scroll-rect": "^0.1.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@inquirer/checkbox": {
|
"node_modules/@inquirer/checkbox": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/@inquirer/checkbox/-/checkbox-3.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/@inquirer/checkbox/-/checkbox-3.0.1.tgz",
|
||||||
@@ -1737,7 +1752,6 @@
|
|||||||
"integrity": "sha512-yl43JD/86CIj3Mz5mvvLJqAOfIup7ncxfJ0Btnl0/v5TouVUyeEdcpknfgc+yMevS/48oH9WAkkw93m7otLb/A==",
|
"integrity": "sha512-yl43JD/86CIj3Mz5mvvLJqAOfIup7ncxfJ0Btnl0/v5TouVUyeEdcpknfgc+yMevS/48oH9WAkkw93m7otLb/A==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@inquirer/checkbox": "^3.0.1",
|
"@inquirer/checkbox": "^3.0.1",
|
||||||
"@inquirer/confirm": "^4.0.1",
|
"@inquirer/confirm": "^4.0.1",
|
||||||
@@ -2896,7 +2910,6 @@
|
|||||||
"integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
|
"integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"bin": {
|
"bin": {
|
||||||
"acorn": "bin/acorn"
|
"acorn": "bin/acorn"
|
||||||
},
|
},
|
||||||
@@ -2963,7 +2976,6 @@
|
|||||||
"integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==",
|
"integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fast-deep-equal": "^3.1.3",
|
"fast-deep-equal": "^3.1.3",
|
||||||
"fast-uri": "^3.0.1",
|
"fast-uri": "^3.0.1",
|
||||||
@@ -3181,7 +3193,6 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"baseline-browser-mapping": "^2.9.0",
|
"baseline-browser-mapping": "^2.9.0",
|
||||||
"caniuse-lite": "^1.0.30001759",
|
"caniuse-lite": "^1.0.30001759",
|
||||||
@@ -4488,6 +4499,17 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"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": {
|
"node_modules/end-of-stream": {
|
||||||
"version": "1.4.5",
|
"version": "1.4.5",
|
||||||
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz",
|
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz",
|
||||||
@@ -8008,7 +8030,6 @@
|
|||||||
"integrity": "sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw==",
|
"integrity": "sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"esbuild": "^0.21.3",
|
"esbuild": "^0.21.3",
|
||||||
"postcss": "^8.4.43",
|
"postcss": "^8.4.43",
|
||||||
@@ -8068,7 +8089,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/vue/-/vue-3.5.28.tgz",
|
"resolved": "https://registry.npmjs.org/vue/-/vue-3.5.28.tgz",
|
||||||
"integrity": "sha512-BRdrNfeoccSoIZeIhyPBfvWSLFP4q8J3u8Ju8Ug5vu3LdD+yTM13Sg4sKtljxozbnuMu1NB1X5HBHRYUzFocKg==",
|
"integrity": "sha512-BRdrNfeoccSoIZeIhyPBfvWSLFP4q8J3u8Ju8Ug5vu3LdD+yTM13Sg4sKtljxozbnuMu1NB1X5HBHRYUzFocKg==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vue/compiler-dom": "3.5.28",
|
"@vue/compiler-dom": "3.5.28",
|
||||||
"@vue/compiler-sfc": "3.5.28",
|
"@vue/compiler-sfc": "3.5.28",
|
||||||
@@ -8122,7 +8142,6 @@
|
|||||||
"integrity": "sha512-gX/dMkRQc7QOMzgTe6KsYFM7DxeIONQSui1s0n/0xht36HvrgbxtM1xBlgx596NbpHuQU8P7QpKwrZYwUX48nw==",
|
"integrity": "sha512-gX/dMkRQc7QOMzgTe6KsYFM7DxeIONQSui1s0n/0xht36HvrgbxtM1xBlgx596NbpHuQU8P7QpKwrZYwUX48nw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/eslint-scope": "^3.7.7",
|
"@types/eslint-scope": "^3.7.7",
|
||||||
"@types/estree": "^1.0.8",
|
"@types/estree": "^1.0.8",
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
"vite": "^5.4.21"
|
"vite": "^5.4.21"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@imengyu/vue3-context-menu": "^1.5.4",
|
||||||
"@vueuse/core": "^14.2.1",
|
"@vueuse/core": "^14.2.1",
|
||||||
"copy-to-clipboard": "^3.3.3",
|
"copy-to-clipboard": "^3.3.3",
|
||||||
"electron-squirrel-startup": "^1.0.1",
|
"electron-squirrel-startup": "^1.0.1",
|
||||||
|
|||||||
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 9.0 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 998 B |
@@ -1,54 +1,45 @@
|
|||||||
class ColorDetect():
|
def color_detection(data, print_type='str'):
|
||||||
def __init__(self):
|
'''определение цвета'''
|
||||||
self.color = None
|
|
||||||
|
|
||||||
def getColor(self):
|
frame = bridge.imgmsg_to_cv2(data, 'bgr8')
|
||||||
return self.color
|
height, width = frame.shape[:2]
|
||||||
|
y_start = int(height * 0.33)
|
||||||
|
y_end = int(height * 0.67)
|
||||||
|
x_start = int(width * 0.31)
|
||||||
|
x_end = int(width * 0.69)
|
||||||
|
|
||||||
def detect_color_callback(self, data, print_type='str'):
|
cropped_frame = frame[y_start:y_end, x_start:x_end]
|
||||||
'''определение цвета'''
|
|
||||||
|
|
||||||
frame = bridge.imgmsg_to_cv2(data, 'bgr8')
|
if cropped_frame.size == 0:
|
||||||
height, width = frame.shape[:2]
|
return
|
||||||
y_start = int(height * 0.33)
|
|
||||||
y_end = int(height * 0.67)
|
|
||||||
x_start = int(width * 0.31)
|
|
||||||
x_end = int(width * 0.69)
|
|
||||||
|
|
||||||
cropped_frame = frame[y_start:y_end, x_start:x_end]
|
|
||||||
|
|
||||||
if cropped_frame.size == 0:
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
if print_type == 'rgb':
|
if print_type == 'rgb':
|
||||||
|
|
||||||
mean_bgr = cv2.mean(cropped_frame)[:3]
|
mean_bgr = cv2.mean(cropped_frame)[:3]
|
||||||
mean_rgb = (int(mean_bgr[2]), int(mean_bgr[1]), int(mean_bgr[0]))
|
mean_rgb = (int(mean_bgr[2]), int(mean_bgr[1]), int(mean_bgr[0]))
|
||||||
self.color = str(mean_rgb)
|
color = str(mean_rgb)
|
||||||
|
|
||||||
|
|
||||||
elif print_type == 'str':
|
elif print_type == 'str':
|
||||||
|
|
||||||
# Получаем средние значения BGR
|
# Получаем средние значения BGR
|
||||||
mean_bgr = cv2.mean(cropped_frame)[:3]
|
mean_bgr = cv2.mean(cropped_frame)[:3]
|
||||||
b, g, r = int(mean_bgr[0]), int(mean_bgr[1]), int(mean_bgr[2])
|
b, g, r = int(mean_bgr[0]), int(mean_bgr[1]), int(mean_bgr[2])
|
||||||
|
|
||||||
|
|
||||||
if b > g and b > r and b > 100:
|
if b > g + 20 and b > r + 20 and b > 100 + 20:
|
||||||
self.color = 'blue'
|
color = 'blue'
|
||||||
elif g > b and g > r and g > 100:
|
elif g > b + 20 and g > r + 20 and g > 100:
|
||||||
self.color = 'green'
|
color = 'green'
|
||||||
elif r > b and r > g and r > 100:
|
elif r > b + 20 and r > g + 20 and r > 100:
|
||||||
self.color = 'red'
|
color = 'red'
|
||||||
else:
|
elif r > 150 and g > 150 and g > 150:
|
||||||
self.color = None
|
color= 'white'
|
||||||
|
else:
|
||||||
|
color = None
|
||||||
|
|
||||||
#в MAIN для вызова функции должно быть:
|
<<separator>>
|
||||||
# cd = ColorDetect()
|
color_sub = rospy.Subscriber('main_camera/image_raw', Image, lambda img: color_detection(img, print_type='rgb'), queue_size=1)
|
||||||
#color_sub = rospy.Subscriber('main_camera/image_raw', Image,
|
rospy.sleep(2)
|
||||||
#lambda img: cd.detect_color_callback(img, print_type='rgb'),
|
color_sub.unregister()
|
||||||
#queue_size=1)
|
|
||||||
# print(cd.getColor())
|
|
||||||
#rospy.sleep(2)
|
|
||||||
#color_sub.unregister()
|
|
||||||
@@ -17,6 +17,9 @@ get_telemetry = rospy.ServiceProxy('get_telemetry', srv.GetTelemetry) #сеов
|
|||||||
navigate = rospy.ServiceProxy('navigate', srv.Navigate) #сервис для полета по указаным координатам
|
navigate = rospy.ServiceProxy('navigate', srv.Navigate) #сервис для полета по указаным координатам
|
||||||
land = rospy.ServiceProxy('land', Trigger) #сервис для посадки
|
land = rospy.ServiceProxy('land', Trigger) #сервис для посадки
|
||||||
|
|
||||||
|
rospy.init_node('flight')
|
||||||
|
bridge = CvBridge()
|
||||||
|
|
||||||
|
|
||||||
def navigate_wait(x=0, y=0, z=1, speed=0.5, frame_id='aruco_map', auto_arm=False, tolerance=0.2,sleep=2):
|
def navigate_wait(x=0, y=0, z=1, speed=0.5, frame_id='aruco_map', auto_arm=False, tolerance=0.2,sleep=2):
|
||||||
"""
|
"""
|
||||||
@@ -85,13 +88,15 @@ def signal_handler(sig, frame):
|
|||||||
|
|
||||||
signal.signal(signal.SIGINT, signal_handler)
|
signal.signal(signal.SIGINT, signal_handler)
|
||||||
|
|
||||||
|
<<qr_function>>
|
||||||
|
<<ColorDetect>>
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
navigate_wait(z=1,frame_id='body',auto_arm=True) #должно быть. включает моторы и поднимает дрон на метр вверх
|
navigate_wait(z=1,frame_id='body',auto_arm=True) #должно быть. включает моторы и поднимает дрон на метр вверх
|
||||||
#в дальнейшем не передавать переменной auto_arm значение True
|
#в дальнейшем не передавать переменной auto_arm значение True
|
||||||
|
|
||||||
|
|
||||||
<<navigate_wait>>
|
<<main>>
|
||||||
|
|
||||||
|
|
||||||
land() #посадка
|
land() #посадка
|
||||||
|
|||||||
@@ -1,26 +1,12 @@
|
|||||||
class QrDetect():
|
def qr_detection(data):
|
||||||
def __init__(self):
|
cv_image = bridge.imgmsg_to_cv2(data, 'bgr8')
|
||||||
self.qr_data = ''
|
barcodes = pyzbar.decode(cv_image)
|
||||||
|
|
||||||
def getQrData(self):
|
if barcodes:
|
||||||
return self.qr_data
|
qr_data = barcodes[0].data.decode('utf-8')
|
||||||
|
return qr_data
|
||||||
|
|
||||||
def qr_detection(self,data):
|
<<separator>>
|
||||||
'''сканирование qr кода'''
|
qr_sub = rospy.Subscriber('main_camera/image_raw', Image, qr_detection, queue_size=1)
|
||||||
if self.qr_data!= '':
|
rospy.sleep(2)
|
||||||
return
|
qr_sub.unregister()
|
||||||
cv_image = bridge.imgmsg_to_cv2(data, 'bgr8')
|
|
||||||
barcodes = pyzbar.decode(cv_image)
|
|
||||||
|
|
||||||
if barcodes:
|
|
||||||
self.qr_data = barcodes[0].data.decode('utf-8')
|
|
||||||
|
|
||||||
|
|
||||||
#в MAIN для вызова функции необходимо следующее:
|
|
||||||
#1. создаём и вызываем подписчика, который вызывает функцию чтения кьюаркода
|
|
||||||
qd = QrDetect()
|
|
||||||
qr_sub = rospy.Subscriber('main_camera/image_raw',Image, qd.qr_detection,queue_size=1)
|
|
||||||
#2. задаём время работы подписчика (за 1 секунду примерно 20 раз вызывается функция)
|
|
||||||
rospy.sleep(2)
|
|
||||||
#3. выключаем подписчика
|
|
||||||
qr_sub.unregister()
|
|
||||||
@@ -1,16 +1,17 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import {ref, onMounted} from "vue";
|
import {ref, onMounted, h} from "vue";
|
||||||
import izitoast from "./izitoast";
|
import izitoast from "./shared/izitoast";
|
||||||
import {useEventListener} from "@vueuse/core";
|
import {useEventListener} from "@vueuse/core";
|
||||||
import MyDialog from "./components/MyDialog.vue";
|
import MyDialog from "./components/MyDialog.vue";
|
||||||
import MyDropMenu from "./components/MyDropMenu.vue";
|
import MyDropMenu from "./components/MyDropMenu.vue";
|
||||||
import copyToclipboard from "./copyToclipboard";
|
import copyToclipboard from "./shared/copyToclipboard";
|
||||||
|
import ContextMenu from "@imengyu/vue3-context-menu";
|
||||||
|
|
||||||
const numbers = ref([]); // Инициализируем массив с пустыми строками
|
const numbers = ref([]); // Инициализируем массив с пустыми строками
|
||||||
const clickCount = ref(1); // Счетчик нажатий
|
const clickCount = ref(1); // Счетчик нажатий
|
||||||
const listOfTrips = ref([]);
|
const listOfTrips = ref([]);
|
||||||
const isModalVisible = ref(false);
|
const isModalVisible = ref(false);
|
||||||
let finallyText = "";
|
let finallyText = ref("");
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
for (let i = 0; i < 100; i++) {
|
for (let i = 0; i < 100; i++) {
|
||||||
@@ -19,6 +20,9 @@ onMounted(() => {
|
|||||||
x: i % 10,
|
x: i % 10,
|
||||||
y: 9 - Math.floor(i / 10),
|
y: 9 - Math.floor(i / 10),
|
||||||
index: i,
|
index: i,
|
||||||
|
isPlatform: false,
|
||||||
|
isQR: false,
|
||||||
|
BgImg: 'images/ArUco-marker.jpg'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -31,56 +35,89 @@ function setNumber(item) {
|
|||||||
listOfTrips.value.push(item);
|
listOfTrips.value.push(item);
|
||||||
clickCount.value++;
|
clickCount.value++;
|
||||||
} else {
|
} else {
|
||||||
//если нажимаем на ранее отмеченную клетку (не последнюю), то выводится ошибка
|
//если нажимаем на ранее отмеченную клетку, то выводится ошибка
|
||||||
listOfTrips.value.push(item);
|
if (item.variable.at(-1) === clickCount.value - 1) {
|
||||||
if (numbers.value[item.index].variable.at(-1) === clickCount.value - 1) {
|
|
||||||
izitoast.error({
|
izitoast.error({
|
||||||
title: "Ошибка",
|
title: "Ошибка",
|
||||||
message: "Нельзя выбирать один и тот же aruco маркер 2 раза подряд",
|
message: "Нельзя выбирать один и тот же aruco маркер 2 раза подряд",
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
numbers.value[item.index].variable.push(clickCount.value);
|
listOfTrips.value.push(item);
|
||||||
|
item.variable.push(clickCount.value);
|
||||||
clickCount.value++;
|
clickCount.value++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveResult() {
|
async function saveResult() {
|
||||||
let navigate_waites = "";
|
finallyText.value = "";
|
||||||
for (const item of listOfTrips.value) {
|
const mainCode = ref("");
|
||||||
navigate_waites += `\tnavigate_wait(${item.x}, ${item.y})\n`;
|
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")
|
||||||
|
let textOfCode = await response.text()
|
||||||
|
textOfCode = textOfCode.split('<<separator>>')
|
||||||
|
colorDetectClass.value = textOfCode[0]
|
||||||
|
colorDetectCode.value += `\t${textOfCode[1].trim()}\n`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isUsedQR) {
|
||||||
|
const response = await fetch("/shablons/qr.txt")
|
||||||
|
let textOfCode = await response.text()
|
||||||
|
textOfCode = textOfCode.split('<<separator>>')
|
||||||
|
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 (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()
|
||||||
|
finallyText.value = textOfCode.replace("<<main>>", mainCode.value);
|
||||||
|
if (isUsedPlatform) {
|
||||||
|
finallyText.value = finallyText.value.replace("<<ColorDetect>>", colorDetectClass.value);
|
||||||
|
} else {
|
||||||
|
finallyText.value = finallyText.value.replace("<<ColorDetect>>", '');
|
||||||
|
}
|
||||||
|
if (isUsedQR) {
|
||||||
|
finallyText.value = finallyText.value.replace("<<qr_function>>", QRDetectClass.value);
|
||||||
|
} else {
|
||||||
|
finallyText.value = finallyText.value.replace("<<qr_function>>", '');
|
||||||
}
|
}
|
||||||
fetch("/shablons/emergency_and_navigate.txt")
|
|
||||||
.then((response) => response.text())
|
|
||||||
.then((textOfCode) => {
|
|
||||||
finallyText = textOfCode.replace("<<navigate_wait>>", navigate_waites);
|
|
||||||
});
|
|
||||||
isModalVisible.value = true;
|
isModalVisible.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function cancel() {
|
function cancel() {
|
||||||
numbers.value[listOfTrips.value.at(-1).index].variable.pop();
|
|
||||||
listOfTrips.value.pop();
|
|
||||||
|
|
||||||
if (clickCount.value === 1) {
|
if (clickCount.value === 1) {
|
||||||
return;
|
return;
|
||||||
} else {
|
|
||||||
clickCount.value--;
|
|
||||||
}
|
}
|
||||||
|
listOfTrips.value.at(-1).variable.pop();
|
||||||
|
listOfTrips.value.pop();
|
||||||
|
clickCount.value--;
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanResult() {
|
function cleanResult() {
|
||||||
clickCount.value = 1;
|
clickCount.value = 1;
|
||||||
numbers.value = [];
|
listOfTrips.value.forEach(item => {
|
||||||
|
item.isPlatform = false;
|
||||||
|
item.isQR = false;
|
||||||
|
item.variable = [];
|
||||||
|
item.BgImg = 'images/ArUco-marker.jpg'
|
||||||
|
})
|
||||||
listOfTrips.value = [];
|
listOfTrips.value = [];
|
||||||
for (let i = 0; i < 100; i++) {
|
|
||||||
numbers.value.push({
|
|
||||||
variable: [],
|
|
||||||
x: i % 10,
|
|
||||||
y: 9 - Math.floor(i / 10),
|
|
||||||
index: i,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Обрабатываем нажатие Ctrl + Z
|
// Обрабатываем нажатие Ctrl + Z
|
||||||
@@ -102,10 +139,9 @@ function copyAndToast(text) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleDownloadBtn() {
|
function handleDownloadBtn() {
|
||||||
console.log(finallyText)
|
|
||||||
// Создание файла
|
// Создание файла
|
||||||
const downloadUrl = ref('');
|
const downloadUrl = ref('');
|
||||||
const blob = new Blob([finallyText], {type: 'text/plain'});
|
const blob = new Blob([finallyText.value], {type: 'text/plain'});
|
||||||
downloadUrl.value = URL.createObjectURL(blob);
|
downloadUrl.value = URL.createObjectURL(blob);
|
||||||
// Задержка для избежания ошибок в некоторых браузерах
|
// Задержка для избежания ошибок в некоторых браузерах
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -124,18 +160,134 @@ function handleDownloadBtn() {
|
|||||||
})
|
})
|
||||||
isModalVisible.value = false
|
isModalVisible.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createPlatform(item, color) {
|
||||||
|
if (!item.variable.length) {
|
||||||
|
item.variable.push(clickCount.value);
|
||||||
|
listOfTrips.value.push(item)
|
||||||
|
clickCount.value++
|
||||||
|
}
|
||||||
|
item.isPlatform = true;
|
||||||
|
item.isQR = false;
|
||||||
|
item.BgImg = `images/${color}-platform.jpg`
|
||||||
|
}
|
||||||
|
|
||||||
|
function deletePlatform(item) {
|
||||||
|
item.BgImg = 'images/ArUco-marker.jpg'
|
||||||
|
item.isPlatform = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function createQR(item) {
|
||||||
|
if (!item.variable.length) {
|
||||||
|
item.variable.push(clickCount.value);
|
||||||
|
listOfTrips.value.push(item)
|
||||||
|
clickCount.value++
|
||||||
|
}
|
||||||
|
item.isPlatform = false;
|
||||||
|
item.isQR = true;
|
||||||
|
item.BgImg = `images/qr.jpg`
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteQR(item) {
|
||||||
|
item.BgImg = 'images/ArUco-marker.jpg'
|
||||||
|
item.isQR = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function deletePointMap(item) {
|
||||||
|
const index = listOfTrips.value.indexOf(item);
|
||||||
|
if (index !== -1) {
|
||||||
|
const deletedIndex = item.variable.at(-1)
|
||||||
|
listOfTrips.value.forEach(square => {
|
||||||
|
square.variable.map(itemVariable => {
|
||||||
|
if (itemVariable === deletedIndex) {
|
||||||
|
square.variable = []
|
||||||
|
}
|
||||||
|
if (itemVariable > deletedIndex) {
|
||||||
|
square.variable[square.variable.indexOf(itemVariable)]--
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
listOfTrips.value.splice(index, 1);
|
||||||
|
clickCount.value--
|
||||||
|
item.isQR = false
|
||||||
|
item.isPlatform = false
|
||||||
|
item.BgImg = 'images/ArUco-marker.jpg'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function createIcon(src) {
|
||||||
|
return h('img', {
|
||||||
|
src: src,
|
||||||
|
style: {
|
||||||
|
width: '20px',
|
||||||
|
height: '20px',
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
function onContextMenu(e, item) {
|
||||||
|
ContextMenu.showContextMenu({
|
||||||
|
theme: 'mac dark',
|
||||||
|
x: e.x,
|
||||||
|
y: e.y,
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
label: "Платформа",
|
||||||
|
icon: createIcon('icons/base_square.webp'),
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
label: "Белая",
|
||||||
|
onClick: () => createPlatform(item, 'white'),
|
||||||
|
icon: createIcon('icons/white_square.webp'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Синяя",
|
||||||
|
onClick: () => createPlatform(item, 'blue'),
|
||||||
|
icon: createIcon('icons/blue_square.webp'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Красная",
|
||||||
|
onClick: () => createPlatform(item, 'red'),
|
||||||
|
icon: createIcon('icons/red_square.webp'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Удалить",
|
||||||
|
onClick: () => deletePlatform(item),
|
||||||
|
icon: createIcon('icons/trash.webp'),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "QR код",
|
||||||
|
icon: createIcon('icons/qr_code.png'),
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
label: "Добавить",
|
||||||
|
onClick: () => createQR(item),
|
||||||
|
icon: createIcon('icons/plus.webp')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Удалить",
|
||||||
|
onClick: () => deleteQR(item),
|
||||||
|
icon: createIcon('icons/trash.webp')
|
||||||
|
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Удалить",
|
||||||
|
icon: createIcon('icons/trash.webp'),
|
||||||
|
onClick: () => deletePointMap(item),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="wraper">
|
<div class="wraper">
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
<div
|
<div class="square" v-for="(item, index) in numbers" :data-key="index" :key="index"
|
||||||
class="square"
|
@click="setNumber(item)" @contextmenu.prevent="onContextMenu($event, item)"
|
||||||
v-for="(item, index) in numbers"
|
:style="{backgroundImage: `url(${item.BgImg})`}">
|
||||||
:data-key="index"
|
|
||||||
:key="index"
|
|
||||||
@click="setNumber(item)"
|
|
||||||
>
|
|
||||||
{{ numbers[index].variable.join(", ") }}
|
{{ numbers[index].variable.join(", ") }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -149,12 +301,8 @@ function handleDownloadBtn() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<MyDialog
|
<MyDialog v-show="isModalVisible" @close="isModalVisible = false" class="dialogWindow"
|
||||||
v-show="isModalVisible"
|
:is-success=Boolean(listOfTrips.length)>
|
||||||
@close="isModalVisible = false"
|
|
||||||
class="dialogWindow"
|
|
||||||
:is-success=listOfTrips.length
|
|
||||||
>
|
|
||||||
<template #header>
|
<template #header>
|
||||||
<strong v-if="listOfTrips.length">Код готов!</strong>
|
<strong v-if="listOfTrips.length">Код готов!</strong>
|
||||||
<strong v-else>Код не готов!</strong>
|
<strong v-else>Код не готов!</strong>
|
||||||
@@ -165,9 +313,9 @@ function handleDownloadBtn() {
|
|||||||
</template>
|
</template>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<div v-if="listOfTrips.length">
|
<div v-if="listOfTrips.length">
|
||||||
<button type="button" @click="handleDownloadBtn">Скачать код</button>
|
<button @click="handleDownloadBtn">Скачать код</button>
|
||||||
<button type="button" @click="copyAndToast(finallyText)">Скопировать код</button>
|
<button @click="copyAndToast(finallyText)">Скопировать код</button>
|
||||||
<button type="button" @click="isModalVisible = false">ОК</button>
|
<button @click="isModalVisible = false">ОК</button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</MyDialog>
|
</MyDialog>
|
||||||
@@ -196,14 +344,11 @@ html {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.square {
|
.square {
|
||||||
width: var(--side); /* Ширина квадрата */
|
width: var(--side);
|
||||||
height: var(--side); /* Высота квадрата */
|
height: var(--side);
|
||||||
background-image: url("images/image.jpg");
|
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
border: 3px solid rgb(251, 251, 251);
|
border: 3px solid rgb(251, 251, 251);
|
||||||
background-color: #e0e0e0;
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: background-color 0.3s;
|
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
|
|
||||||
background-blend-mode: multiply;
|
background-blend-mode: multiply;
|
||||||
@@ -211,6 +356,7 @@ html {
|
|||||||
transition: background-color 0.3s ease;
|
transition: background-color 0.3s ease;
|
||||||
|
|
||||||
color: white;
|
color: white;
|
||||||
|
font-size: 18px;
|
||||||
text-shadow: -1px -1px 0 black,
|
text-shadow: -1px -1px 0 black,
|
||||||
1px -1px 0 black,
|
1px -1px 0 black,
|
||||||
-1px 1px 0 black,
|
-1px 1px 0 black,
|
||||||
|
|||||||
@@ -1,36 +1,37 @@
|
|||||||
<template>
|
<template>
|
||||||
<transition name="modal-fade">
|
<transition name="modal-fade">
|
||||||
<div class="modal-backdrop" @click="closeModal">
|
<div class="modal-backdrop" @click="closeModal">
|
||||||
<div class="modal" @click.stop>
|
<div class="modal" @click.stop>
|
||||||
<header :class="['modal-header', isSuccess ? 'modal-header-success': 'modal-header-error']">
|
<header :class="['modal-header', isSuccess ? 'modal-header-success': 'modal-header-error']">
|
||||||
<slot name="header">
|
<slot name="header">
|
||||||
<strong>Заголовок по умолчанию</strong>
|
<strong>Заголовок по умолчанию</strong>
|
||||||
</slot>
|
</slot>
|
||||||
<button class="modal-btn-close" @click="closeModal" aria-label="Закрыть модальное окно">
|
<button class="modal-btn-close" @click="closeModal" aria-label="Закрыть модальное окно">
|
||||||
×
|
×
|
||||||
</button>
|
</button>
|
||||||
</header>
|
</header>
|
||||||
<section class="modal-body">
|
<section class="modal-body">
|
||||||
<slot name="body">Тело по умолчанию</slot>
|
<slot name="body">Тело по умолчанию</slot>
|
||||||
</section>
|
</section>
|
||||||
<footer :class="['modal-footer', isSuccess ? 'modal-footer-success': 'modal-footer-error']">
|
<footer :class="['modal-footer', isSuccess ? 'modal-footer-success': 'modal-footer-error']">
|
||||||
<slot name="footer">
|
<slot name="footer">
|
||||||
<button @click="closeModal">Закрыть</button>
|
<button @click="closeModal">Закрыть</button>
|
||||||
</slot>
|
</slot>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</transition>
|
</transition>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
const emit = defineEmits(['close'])
|
const emit = defineEmits(['close'])
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
isSuccess: {
|
isSuccess: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: true
|
required: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
function closeModal() {
|
function closeModal() {
|
||||||
emit('close');
|
emit('close');
|
||||||
}
|
}
|
||||||
@@ -38,82 +39,88 @@ function closeModal() {
|
|||||||
|
|
||||||
<style>
|
<style>
|
||||||
.modal-backdrop {
|
.modal-backdrop {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
background-color: rgba(0, 0, 0, 0.3);
|
background-color: rgba(0, 0, 0, 0.3);
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal {
|
.modal {
|
||||||
background: #2f2f2f;
|
background: #2f2f2f;
|
||||||
box-shadow: 2px 2px 20px 1px;
|
box-shadow: 2px 2px 20px 1px;
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
max-width: 500px;
|
max-width: 500px;
|
||||||
width: 90%;
|
width: 90%;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-header,
|
.modal-header,
|
||||||
.modal-footer {
|
.modal-footer {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-header {
|
.modal-header {
|
||||||
border-bottom: 1px solid #eeeeee;
|
border-bottom: 1px solid #eeeeee;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
|
||||||
.modal-header-success {
|
|
||||||
color: #4AAE9B;
|
|
||||||
}
|
|
||||||
.modal-header-error {
|
|
||||||
color: red;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-header [type = 'button'] {
|
.modal-header-success {
|
||||||
color: red;
|
color: #4AAE9B;
|
||||||
font-size: 25px;
|
}
|
||||||
|
|
||||||
|
.modal-header-error {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-header button {
|
||||||
|
color: red;
|
||||||
|
font-size: 25px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-footer {
|
.modal-footer {
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
border-top: 1px solid white;
|
border-top: 1px solid white;
|
||||||
}
|
}
|
||||||
.modal-footer [type = 'button'] {
|
|
||||||
justify-content: flex-end;
|
.modal-footer button {
|
||||||
border-top: 1px solid white;
|
justify-content: flex-end;
|
||||||
padding: 5px;
|
border-top: 1px solid white;
|
||||||
|
padding: 5px;
|
||||||
|
color: white;
|
||||||
}
|
}
|
||||||
.modal-footer-success [type = 'button'] {
|
|
||||||
background-color: #4AAE9B;
|
.modal-footer-success button {
|
||||||
border: none;
|
background-color: #4AAE9B;
|
||||||
margin: 3px;
|
border: none;
|
||||||
|
margin: 3px;
|
||||||
}
|
}
|
||||||
.modal-footer-error [type = 'button'] {
|
|
||||||
background: red;
|
.modal-footer-error button {
|
||||||
border: none;
|
background: red;
|
||||||
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-body {
|
.modal-body {
|
||||||
position: relative;
|
position: relative;
|
||||||
padding: 20px 10px;
|
padding: 20px 10px;
|
||||||
color: white
|
color: white
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-btn-close {
|
.modal-btn-close {
|
||||||
border: none;
|
border: none;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: red;
|
color: red;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -28,5 +28,6 @@
|
|||||||
|
|
||||||
import { createApp } from 'vue';
|
import { createApp } from 'vue';
|
||||||
import App from './App.vue';
|
import App from './App.vue';
|
||||||
|
import '@imengyu/vue3-context-menu/lib/vue3-context-menu.css'
|
||||||
createApp(App).mount('#app');
|
import ContextMenu from '@imengyu/vue3-context-menu'
|
||||||
|
createApp(App).use(ContextMenu).mount('#app');
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import copy from 'copy-to-clipboard';
|
import copy from 'copy-to-clipboard';
|
||||||
import iziToast from '@/iziToast.js';
|
import iziToast from '@/shared/iziToast.js';
|
||||||
|
|
||||||
function copyToclipboard(text) {
|
function copyToclipboard(text) {
|
||||||
try {
|
try {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import iziToast from "izitoast"
|
import iziToast from 'iziToast';
|
||||||
|
|
||||||
iziToast.settings({
|
iziToast.settings({
|
||||||
timeout: 3000,
|
timeout: 3000,
|
||||||