-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
afc1112
commit a5c0551
Showing
117 changed files
with
5,919 additions
and
3,344 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
*.user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule QJoysticks
added at
ccc0f5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.