Skip to content

Commit

Permalink
Release 0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
emily0undrgrnd committed Mar 25, 2024
1 parent afc1112 commit a5c0551
Show file tree
Hide file tree
Showing 117 changed files with 5,919 additions and 3,344 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

*.user
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "QJoysticks"]
path = QJoysticks
url = https://github.com/alex-spataru/QJoysticks
56 changes: 34 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,28 @@ set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_REQUIRED_FLAGS -std=c++17)

set(OpenCV_DIR C:/Libraries/LibOpenCV)


find_package(SDL2 REQUIRED)
find_package(OpenCV REQUIRED)
find_package(Threads)

find_package(Qt5 REQUIRED COMPONENTS
find_package(Qt6 REQUIRED COMPONENTS
Core
Widgets
SerialPort
WebSockets
WebEngine
WebEngineQuick
PrintSupport
Qml
Quick
QuickControls2
Gui
Gamepad
Concurrent)


add_executable(${PROJECT_NAME} WIN32 resources/icon.rc)
#add_executable(${PROJECT_NAME} resources/icon.rc)

file(GLOB QJoystick "${QJoy}/src/*.cpp" "${QJoy}/src/*.h"
"${QJoy}/src/QJoysticks/*.cpp" "${QJoy}/src/QJoysticks/*.h"
)

target_sources(${PROJECT_NAME}
PRIVATE sources/main.cpp
Expand Down Expand Up @@ -67,8 +68,6 @@ target_sources(${PROJECT_NAME}
PRIVATE sources/RemoteController.hxx
PRIVATE sources/QmlImageItem.cpp
PRIVATE sources/QmlImageItem.hxx
PRIVATE sources/Gamepad.cpp
PRIVATE sources/Gamepad.hxx
PRIVATE sources/EditorIndenter.cpp
PRIVATE sources/EditorIndenter.hxx
PRIVATE sources/SettingsController.cpp
Expand All @@ -80,7 +79,11 @@ target_sources(${PROJECT_NAME}
PRIVATE sources/HintBase.cpp
PRIVATE sources/HintBase.hxx
PRIVATE sources/ApiTokenDialog.cpp
PRIVATE sources/ApiTokenDialog.hxx)
PRIVATE sources/ApiTokenDialog.hxx
PRIVATE sources/Joystick.cpp
PRIVATE sources/Joystick.hxx
PRIVATE ${QJoystick}
)

if (WIN32)
target_sources(${PROJECT_NAME}
Expand All @@ -93,18 +96,27 @@ endif()
target_compile_features(${PROJECT_NAME}
PRIVATE cxx_std_17)

target_include_directories(${PROJECT_NAME} PRIVATE
${SDL2_DIR}/include
${QJoy}/src
)

target_compile_definitions(${PROJECT_NAME} PRIVATE
SDL_SUPPORTED
)

target_link_libraries(${PROJECT_NAME}
PRIVATE Qt5::SerialPort
PRIVATE Qt5::Core
PRIVATE Qt5::Widgets
PRIVATE Qt5::WebSockets
PRIVATE Qt5::PrintSupport
PRIVATE Qt5::WebEngine
PRIVATE Qt5::Qml
PRIVATE Qt5::Quick
PRIVATE Qt5::Gui
PRIVATE Qt5::Gamepad
PRIVATE Qt5::Concurrent
PRIVATE Qt6::Core
PRIVATE Qt6::Widgets
PRIVATE Qt6::WebSockets
PRIVATE Qt6::PrintSupport
PRIVATE Qt6::WebEngineQuick
PRIVATE Qt6::Qml
PRIVATE Qt6::Quick
PRIVATE Qt6::QuickControls2
PRIVATE Qt6::Gui
PRIVATE Qt6::Concurrent
PRIVATE ${OpenCV_LIBS}
${SDL2_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT})

1 change: 1 addition & 0 deletions QJoysticks
Submodule QJoysticks added at ccc0f5
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ __[Загрузить (для Windows)](https://murproject.com/documents/17/murI

## Сборка

Инструкции по сборке представлены [на данной странице](https://murproject.github.io/pages/building-mur-ide).
Инструкции по сборке представлены [на данной странице](https://murproject.github.io/pages/building-mur-ide).
61 changes: 61 additions & 0 deletions resources/config/schemes/py.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"scheme": {
"comment": "Python",
"suffixes": ["py"],
"highlight": [{
"comment": "numbers",
"match": "\\b\\d+(\\.\\d*)?\\b",
"color": "#AF601A",
"bold": true
}, {
"comment": "functions",
"match": "\\b[\\w_]+\\s*(?=\\()",
"color": "#1ABC9C",
"bold": true
}, {
"comment": "keywords",
"match": "(?:\\b|\\s+)(?:(with|yield|del|import|as|global|pass|raise|in|from|try|except|pass))\\b",
"color": "#C678DD",
"bold": true
}, {
"comment": "units",
"match": "(?:\\b|\\s+)(?:(def|class|lambda))\\b",
"color": "#F1948A",
"bold": true
}, {
"comment": "logic",
"match": "(?:\\b|\\s+)(?:(is|not|if|elif|and|or|else|nonlocal))\\b",
"color": "#FFCD02",
"bold": true
}, {
"comment": "boolean",
"match": "(?:\\b|\\s+)(?:(True|False|None|assert))\\b",
"color": "#FC6E51",
"bold": true
}, {
"comment": "controll",
"match": "(?:\\b|\\s+)(?:(finally|return|break|continue|for|while))\\b",
"color": "#5D9CCE",
"bold": true
}, {
"comment": "strings",
"match": "\".*\"",
"color": "#9DA5B4"
}, {
"comment": "single quoted string",
"match": "\'.*\'",
"color": "#9DA5B4"
}, {
"comment": "inline comments",
"match": "#.*$",
"color": "#888",
"italic": true
},
{
"comment": "multiline comments",
"match": "\"\"\".*\"\"\"",
"color": "#888",
"italic": true
}]
}
}
2 changes: 1 addition & 1 deletion resources/examples/auv_depth_preg.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Данный пример предназначен для работы на аппарате!

# В данном примере реализован простой пропорциональный регулятор по глубине.
# Аппарат убет удерживать заданную глубину 10 секунд.
# Аппарат будет удерживать заданную глубину 10 секунд.


import pymurapi as mur
Expand Down
2 changes: 1 addition & 1 deletion resources/examples/auv_led.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
auv.set_rgb_color(0, 50, 0)
time.sleep(3)
# Красный
auv.set_rgb_color(0, 50, 0)
auv.set_rgb_color(50, 0, 0)
time.sleep(3)

57 changes: 57 additions & 0 deletions resources/examples/auv_moving_average.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# В данном примере реализовано сглаживание тяги методом "простое скользящее среднее"
# Простое скользящее среднее представляет собой сумму последних чисел деленную на их количество.
# Использование скользящего среднего необходимо для плавного увеличения тяги на движителях.

import pymurapi as mur
import time

auv = mur.mur_init()

class MovingAverage:
_storage_size = 50

def __init__(self):
self._storage = [0] * self._storage_size
self._counter = 0

# Добавление элементов в список
def add(self, value):
self._storage[self._counter] = value

if(self._counter < (self._storage_size - 1)):
self._counter += 1
else:
self._counter = 0

# Получение среднего арифметического из списка
def get(self):
result = sum(self._storage) / self._storage_size
return result

# Приравнивание элементов списка нулю
def clean(self):
for i in range(self._storage_size):
self._storage[i] = 0


power1 = MovingAverage()
power2 = MovingAverage()
now = time.time()

while True:
if (time.time() - now) < 7:
power1.add(-50)
power2.add(100)
elif 7 < (time.time() - now) < 15:
power1.add(50)
power2.add(-100)
else:
power1.add(0)
power2.add(0)

p1 = power1.get()
p2 = power2.get()
auv.set_motor_power(1, p1)
auv.set_motor_power(2, p2)

time.sleep(0.1)
52 changes: 52 additions & 0 deletions resources/examples/auv_stream.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Пример для версии аппаратов MiddleAUV-CM4
# Здесь реализована трансляция видео из скрипта
# Данный пример лучше использовать только для тестирования и отладки

import cv2 as cv
import numpy as np
import pymurapi as mur
from time import sleep

auv = mur.mur_init()
mur_view = auv.get_videoserver()

cap0 = cv.VideoCapture(0)
cap1 = cv.VideoCapture(1)

def find_contours(image, color, approx = cv.CHAIN_APPROX_SIMPLE):
hsv_image = cv.cvtColor(image, cv.COLOR_BGR2HSV)
mask = cv.inRange(hsv_image, color[0], color[1])
contours, _ = cv.findContours(mask, cv.RETR_CCOMP, approx)
return contours, mask

def img_process(img, num=0):
font = cv.FONT_HERSHEY_PLAIN
contours, mask = find_contours(img, ((0, 0, 220), (180, 255, 255)))

if contours:

for contour in contours:
if cv.contourArea(contour) > 50:
rectangle = cv.minAreaRect(contour)
box = np.int0(cv.boxPoints(rectangle))
cv.drawContours(img,[box],0,(0,0,250),2)

cv.putText(img,'Camera {}'.format(num),(5,25),font,2,(255,255,255),2,cv.LINE_AA)

return img, mask

while True:
ok, frame0 = cap0.read()
# ok, frame1 = cap1.read()

frame0 = cv.resize(frame0, (320, 240))
# frame1 = cv.resize(frame1, (320, 240))

result0, mask0 = img_process(frame0, 0)
# result1, mask1 = img_process(frame1, 1)

mur_view.show(result0, 0)
mur_view.show(mask0, 1)

mur_view.stop()
print("done")
4 changes: 2 additions & 2 deletions resources/examples/sim_depth_preg.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Данный пример предназначен для работы в симуляторе!

# В данном примере реализован простой пропорциональный регулятор по глубине.
# Аппарат убет удерживать заданную глубину 10 секунд.
# Аппарат будет удерживать заданную глубину 10 секунд.


import pymurapi as mur
Expand Down Expand Up @@ -32,4 +32,4 @@ def keep_depth(depth_to_set):
keep_depth(depth)
if (time.time() - now) > 15:
break


2 changes: 1 addition & 1 deletion resources/examples/sim_hsv.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Функции get_image_front и get_image_bottom работают только в симуляторе.
# Для получения видео на аппарате используйте cv2.VideoCapture из OpenCV!
# (https://docs.opencv.org/4.1.1/dd/d43/tutorial_py_video_display.html)
# (https://docs.opencv.org/4.7.0/dd/d43/tutorial_py_video_display.html)


import pymurapi as mur
Expand Down
2 changes: 1 addition & 1 deletion resources/examples/sim_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Функции get_image_front и get_image_bottom работают только в симуляторе.
# Для получения видео на аппарате используйте cv2.VideoCapture из OpenCV!
# (https://docs.opencv.org/4.1.1/dd/d43/tutorial_py_video_display.html)
# (https://docs.opencv.org/4.7.0/dd/d43/tutorial_py_video_display.html)


import pymurapi as mur
Expand Down
25 changes: 0 additions & 25 deletions resources/examples/usv_led.py

This file was deleted.

16 changes: 0 additions & 16 deletions resources/examples/usv_motors_test .py

This file was deleted.

Loading

0 comments on commit a5c0551

Please sign in to comment.