diff --git a/package-lock.json b/package-lock.json index 97674a5..2c416e6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "1.0.0", "license": "MIT", "dependencies": { + "@imengyu/vue3-context-menu": "^1.5.4", "@vueuse/core": "^14.2.1", "copy-to-clipboard": "^3.3.3", "electron-squirrel-startup": "^1.0.1", @@ -615,7 +616,6 @@ "integrity": "sha512-zx0EIq78WlY/lBb1uXlziZmDZI4ubcCXIMJ4uGjXzZW0nS19TjSPeXPAjzzTmKQlJUZm0SbmZhPKP7tuQ1SsEw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "chalk": "^4.1.1", "fs-extra": "^9.0.1", @@ -1406,6 +1406,21 @@ "dev": true, "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": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/@inquirer/checkbox/-/checkbox-3.0.1.tgz", @@ -1737,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", @@ -2896,7 +2910,6 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -2963,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", @@ -3181,7 +3193,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", @@ -4488,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", @@ -8008,7 +8030,6 @@ "integrity": "sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "esbuild": "^0.21.3", "postcss": "^8.4.43", @@ -8068,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", @@ -8122,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/package.json b/package.json index f0de7b3..dceac85 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "vite": "^5.4.21" }, "dependencies": { + "@imengyu/vue3-context-menu": "^1.5.4", "@vueuse/core": "^14.2.1", "copy-to-clipboard": "^3.3.3", "electron-squirrel-startup": "^1.0.1", diff --git a/public/icons/base_square.webp b/public/icons/base_square.webp new file mode 100644 index 0000000..bcac844 Binary files /dev/null and b/public/icons/base_square.webp differ diff --git a/public/icons/blue_square.webp b/public/icons/blue_square.webp new file mode 100644 index 0000000..88110a5 Binary files /dev/null and b/public/icons/blue_square.webp differ diff --git a/public/icons/plus.webp b/public/icons/plus.webp new file mode 100644 index 0000000..6b62406 Binary files /dev/null and b/public/icons/plus.webp differ diff --git a/public/icons/qr_code.png b/public/icons/qr_code.png new file mode 100644 index 0000000..7234130 Binary files /dev/null and b/public/icons/qr_code.png differ diff --git a/public/icons/red_square.webp b/public/icons/red_square.webp new file mode 100644 index 0000000..56eaad9 Binary files /dev/null and b/public/icons/red_square.webp differ diff --git a/public/icons/trash.webp b/public/icons/trash.webp new file mode 100644 index 0000000..b4d66e4 Binary files /dev/null and b/public/icons/trash.webp differ diff --git a/public/icons/white_square.webp b/public/icons/white_square.webp new file mode 100644 index 0000000..09d7e5e Binary files /dev/null and b/public/icons/white_square.webp differ diff --git a/src/Images/image.jpg b/public/images/ArUco-marker.jpg similarity index 100% rename from src/Images/image.jpg rename to public/images/ArUco-marker.jpg diff --git a/public/images/blue-platform.jpg b/public/images/blue-platform.jpg new file mode 100644 index 0000000..bff4e73 Binary files /dev/null and b/public/images/blue-platform.jpg differ 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/images/red-platform.jpg b/public/images/red-platform.jpg new file mode 100644 index 0000000..6a7e75a Binary files /dev/null and b/public/images/red-platform.jpg differ diff --git a/public/images/white-platform.jpg b/public/images/white-platform.jpg new file mode 100644 index 0000000..3fac667 Binary files /dev/null and b/public/images/white-platform.jpg differ diff --git a/public/shablons/color.txt b/public/shablons/color.txt index 6571542..b61e0f9 100644 --- a/public/shablons/color.txt +++ b/public/shablons/color.txt @@ -1,54 +1,45 @@ -class ColorDetect(): - def __init__(self): - self.color = None +def color_detection(data, print_type='str'): + '''определение цвета''' - def getColor(self): - return self.color + frame = bridge.imgmsg_to_cv2(data, 'bgr8') + 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] + + if cropped_frame.size == 0: + return + - frame = bridge.imgmsg_to_cv2(data, 'bgr8') - 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) + if print_type == 'rgb': - cropped_frame = frame[y_start:y_end, x_start:x_end] + mean_bgr = cv2.mean(cropped_frame)[:3] + mean_rgb = (int(mean_bgr[2]), int(mean_bgr[1]), int(mean_bgr[0])) + color = str(mean_rgb) + + + elif print_type == 'str': + + # Получаем средние значения BGR + mean_bgr = cv2.mean(cropped_frame)[:3] + b, g, r = int(mean_bgr[0]), int(mean_bgr[1]), int(mean_bgr[2]) - if cropped_frame.size == 0: - return + if b > g + 20 and b > r + 20 and b > 100 + 20: + color = 'blue' + elif g > b + 20 and g > r + 20 and g > 100: + color = 'green' + elif r > b + 20 and r > g + 20 and r > 100: + color = 'red' + elif r > 150 and g > 150 and g > 150: + color= 'white' + else: + color = None - if print_type == 'rgb': - - mean_bgr = cv2.mean(cropped_frame)[:3] - mean_rgb = (int(mean_bgr[2]), int(mean_bgr[1]), int(mean_bgr[0])) - self.color = str(mean_rgb) - - - elif print_type == 'str': - - # Получаем средние значения BGR - mean_bgr = cv2.mean(cropped_frame)[:3] - b, g, r = int(mean_bgr[0]), int(mean_bgr[1]), int(mean_bgr[2]) - - - if b > g and b > r and b > 100: - self.color = 'blue' - elif g > b and g > r and g > 100: - self.color = 'green' - elif r > b and r > g and r > 100: - self.color = 'red' - else: - self.color = None - -#в MAIN для вызова функции должно быть: -# cd = ColorDetect() - #color_sub = rospy.Subscriber('main_camera/image_raw', Image, - #lambda img: cd.detect_color_callback(img, print_type='rgb'), - #queue_size=1) - # print(cd.getColor()) - #rospy.sleep(2) - #color_sub.unregister() +<> + color_sub = rospy.Subscriber('main_camera/image_raw', Image, lambda img: color_detection(img, print_type='rgb'), queue_size=1) + rospy.sleep(2) + color_sub.unregister() \ No newline at end of file diff --git a/public/shablons/emergency_and_navigate.txt b/public/shablons/emergency_and_navigate.txt index 5889c07..b989f3e 100644 --- a/public/shablons/emergency_and_navigate.txt +++ b/public/shablons/emergency_and_navigate.txt @@ -17,6 +17,9 @@ get_telemetry = rospy.ServiceProxy('get_telemetry', srv.GetTelemetry) #сеов navigate = rospy.ServiceProxy('navigate', srv.Navigate) #сервис для полета по указаным координатам 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): """ @@ -37,7 +40,7 @@ def navigate_wait(x=0, y=0, z=1, speed=0.5, frame_id='aruco_map', auto_arm=False def emergency_stop(): """Функция экстренной остановки, срабатывает при нажатии Ctrl + C""" - + print("\n" + "="*50) print("EMERGENCY STOP ACTIVATED!") print("="*50) @@ -85,14 +88,16 @@ def signal_handler(sig, frame): signal.signal(signal.SIGINT, signal_handler) +<> +<> def main(): navigate_wait(z=1,frame_id='body',auto_arm=True) #должно быть. включает моторы и поднимает дрон на метр вверх #в дальнейшем не передавать переменной auto_arm значение True -<> - +<
> + land() #посадка diff --git a/public/shablons/qr.txt b/public/shablons/qr.txt index b31ddde..c877557 100644 --- a/public/shablons/qr.txt +++ b/public/shablons/qr.txt @@ -1,26 +1,12 @@ -class QrDetect(): - def __init__(self): - self.qr_data = '' - - def getQrData(self): - return self.qr_data +def qr_detection(data): + cv_image = bridge.imgmsg_to_cv2(data, 'bgr8') + barcodes = pyzbar.decode(cv_image) - def qr_detection(self,data): - '''сканирование qr кода''' - if self.qr_data!= '': - return - cv_image = bridge.imgmsg_to_cv2(data, 'bgr8') - barcodes = pyzbar.decode(cv_image) + if barcodes: + qr_data = barcodes[0].data.decode('utf-8') + return qr_data - 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() +<> + 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 6f5d21d..8650d0d 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,16 +1,17 @@