From 2fef3068587930cb8fd5f862d9c64d8d3ed4b4a5 Mon Sep 17 00:00:00 2001 From: Arthur Golubtsov Date: Wed, 4 Sep 2019 18:31:32 +0300 Subject: [PATCH 1/2] Add separated configurations of chrony for server and client. Updated documentation --- Server/chrony.conf | 5 ----- builder/assets/chrony-client.conf | 4 ++++ builder/assets/chrony-server.conf | 10 ++++++++++ docs/start-tutorial.md | 18 +++++++++++------- 4 files changed, 25 insertions(+), 12 deletions(-) delete mode 100644 Server/chrony.conf create mode 100644 builder/assets/chrony-client.conf create mode 100644 builder/assets/chrony-server.conf diff --git a/Server/chrony.conf b/Server/chrony.conf deleted file mode 100644 index bccbf9e..0000000 --- a/Server/chrony.conf +++ /dev/null @@ -1,5 +0,0 @@ -server master iburst -driftfile /var/lib/chrony/drift -allow 192.168.0.0/16 -makestep 1.0 3 -rtcsync \ No newline at end of file diff --git a/builder/assets/chrony-client.conf b/builder/assets/chrony-client.conf new file mode 100644 index 0000000..ee23ad5 --- /dev/null +++ b/builder/assets/chrony-client.conf @@ -0,0 +1,4 @@ +server 192.168.1.184 iburst minpoll -5 maxpoll -3 +driftfile /var/lib/chrony/drift +makestep 0.1 -1 +rtcsync diff --git a/builder/assets/chrony-server.conf b/builder/assets/chrony-server.conf new file mode 100644 index 0000000..62a656c --- /dev/null +++ b/builder/assets/chrony-server.conf @@ -0,0 +1,10 @@ +pool 0.ru.pool.ntp.org iburst minpoll 10 +pool 1.ru.pool.ntp.org iburst minpoll 10 +pool 2.ru.pool.ntp.org iburst minpoll 10 +pool 3.ru.pool.ntp.org iburst minpoll 10 +driftfile /var/lib/chrony/drift +local stratum 8 +allow 192.168.0.0/16 +makestep 100 3 +smoothtime 50000 0.01 +rtcsync diff --git a/docs/start-tutorial.md b/docs/start-tutorial.md index cf4edb2..033bfc4 100644 --- a/docs/start-tutorial.md +++ b/docs/start-tutorial.md @@ -19,39 +19,43 @@ * Подключитесь к сети коптера, используя пароль `cleverwifi`. * Настройте коптер, чтобы корректно работал режим позиции. По-умолчанию образ сконфигурирован для получения позиции с камеры с помощью aruco-маркеров и optical flow. Камера направлена вниз и вперёд, загружена тестовая карта меток. Если ваш способ позиционирования отличается - можно либо настроить данный образ, либо [собрать образ](image-building.md) со своими настройками. * Перейдите в директорию клиента и запустите скрипт настройки клиента + ```bash cd ~/CleverSwarm/Drone sudo ./client_setup.sh ``` + * Выполните скрипт настройки клиента с указанными параметрами - SSID, пароль точки доступа, имя коптера, ip сервера. * Коптер переключится в режим клиента указанной точки доступа и настроит автозапуск клиента copter_client.py с помощью сервиса clever-show Документация по клиентской части находится [здесь](client.md). ## Настройка и запуск сервера -* Установите [chrony](https://chrony.tuxfamily.org/index.html) и Python 3 на ваш компьютер: + +* Установите [chrony](https://chrony.tuxfamily.org/index.html) и Python 3 на ваш компьютер: + ```bash sudo apt install chrony python3 python3-pip ``` * Установите необходимые python-пакеты с помощью команды (запущенной из директории с исходным кодом) + ```bash pip3 install -r requirements.txt ``` * Подключитесь к wifi сети роутера, к которому подключены коптеры. -* Скопируйте [файл настроек chrony](../Server/chrony.conf) в `/etc/chrony/chrony.conf`. Если ip адрес сети начинается не с `192.168.`, то исправьте адрес после слова allow в скопированном файле настроек. +* Скопируйте [файл настроек chrony](../builder/chrony-server.conf) в `/etc/chrony/chrony.conf`. Если ip адрес сети начинается не с `192.168.`, то исправьте адрес после слова allow в скопированном файле настроек. * Перезапустите сервис chrony + ```bash -cd source-code-dir sudo systemctl restart chrony ``` + * Перейдите в директорию сервера из директории с исходным кодом и запустите сервер + ```bash cd source-code-dir/Server python3 server_qt.py ``` -Документация по серверной части находится [здесь](server.md). - +Документация по серверной части находится [здесь](server.md). \ No newline at end of file From 04f87614e7eb81ece6e1a0fe4a8d2055976a2ed9 Mon Sep 17 00:00:00 2001 From: Arthur Golubtsov Date: Wed, 4 Sep 2019 19:02:04 +0300 Subject: [PATCH 2/2] Make some fixes --- Server/app_routes/selfcheck.py | 7 ++++--- Server/web_server_models.py | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Server/app_routes/selfcheck.py b/Server/app_routes/selfcheck.py index bee341f..7e34300 100644 --- a/Server/app_routes/selfcheck.py +++ b/Server/app_routes/selfcheck.py @@ -1,6 +1,7 @@ from flask import Blueprint, request, jsonify from web_server_models import copters, WebCopter from server import Client +from time import time selfcheck_api = Blueprint('selfcheck_api', __name__, template_folder='templates') @@ -11,13 +12,13 @@ def selfcheck_selected(): ip = request.args.get("ip") for copter in copters: if copter.ip == ip: - time = copter.refresh() + copter.refresh() data = { 'anim_id': copter.anim_id, 'batt_voltage': copter.batt_voltage, 'cell_voltage': copter.cell_voltage, 'selfcheck': copter.selfcheck, - 'time': round(float(copter.time) - time, 3), + 'time': round(float(copter.time) - time(), 3), 'name': copter.name, } # data = {"anim_id": "No animation", "batt_voltage": 3.259999990463257, "cell_voltage": 1.0850000381469727, @@ -29,7 +30,7 @@ def selfcheck_selected(): def selfcheck_all(): data = [] for copter in copters: - time = copter.refresh() + copter.refresh() data.append({ 'anim_id': copter.anim_id, 'batt_voltage': copter.batt_voltage, diff --git a/Server/web_server_models.py b/Server/web_server_models.py index 960d22f..72974bf 100644 --- a/Server/web_server_models.py +++ b/Server/web_server_models.py @@ -1,7 +1,8 @@ +from server import Client + copters = [] delay = 0 - def set_delay_manually(_delay): global delay delay = _delay