mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-05 12:54:57 +00:00
Compare commits
33 Commits
OpenCV
...
22-als-dev
Author | SHA1 | Date | |
---|---|---|---|
|
466a8659d0 | ||
|
523ccd87e3 | ||
|
c905bda662 | ||
|
d865a50951 | ||
|
d7a643460c | ||
|
f021ebebcb | ||
|
32e0583c1b | ||
|
c0cf6f1360 | ||
|
730d2b47b8 | ||
|
4c5cea71b2 | ||
|
dcd3f1006d | ||
|
4f79695d9c | ||
|
b2d233386c | ||
|
160b43f49e | ||
|
afe8ae3357 | ||
|
66d5444488 | ||
|
bcbd6743fb | ||
|
9997bf2319 | ||
|
0ae0b83e4b | ||
|
db8758e1e5 | ||
|
08dff8bbc1 | ||
|
f0260c1a91 | ||
|
40d601a35b | ||
|
3525479b17 | ||
|
2e08bf7e74 | ||
|
12c25b33a7 | ||
|
5b27974d5a | ||
|
f4ce50db18 | ||
|
9bd9b6c4b2 | ||
|
c08f1e434c | ||
|
fb35d2a84d | ||
|
b67c51e56b | ||
|
8b03438d47 |
15
.gitignore
vendored
15
.gitignore
vendored
@@ -13,22 +13,9 @@ src/Socket/a.out
|
||||
src/C++/Driver/cmake_install.cmake
|
||||
src/C++/Socket/a.out
|
||||
src/C++/Driver/Makefile
|
||||
vgcore*
|
||||
src/C++/Driver/vgcore*
|
||||
src/C++/Driver/cmake_install.cmake
|
||||
src/C++/Driver/Makefile
|
||||
src/C++/Driver/log
|
||||
build/
|
||||
venv
|
||||
src/C++/MQTT/CMakeFiles
|
||||
src/C++/MQTT/Makefile
|
||||
src/C++/MQTT/CMakeCache.txt
|
||||
src/C++/MQTT/cmake_install.cmake
|
||||
src/Python/flask/web/_pycache_
|
||||
venv
|
||||
build/
|
||||
log
|
||||
CMakeFiles/
|
||||
Makefile
|
||||
CMakeCache.txt
|
||||
cmake_install.cmake
|
||||
src/C++/OpenCV/main
|
||||
|
@@ -19,9 +19,14 @@ Acceptatie criteria zijn specifieke eisen waaraan de User Story moet voldoen. De
|
||||
- [ ] Acceptatiecriterium 2
|
||||
- [ ] ...
|
||||
|
||||
**Definition of Done: Hardware**
|
||||
**Definition of Done**
|
||||
|
||||
- [ ] Alle acceptatiecriteria van de user story zijn afgevinkt.
|
||||
- [ ] Je werk is gedocumenteerd.
|
||||
- [ ] Je hebt testen uitgevoerd.
|
||||
- [ ]
|
||||
- [ ] Je hebt volgens de HBO-ICT werkstandaarden gewerkt (Agile, GitLab, sprint boards, sprint planning, HBO-ICT conventions etc.)
|
||||
- [ ] Het werk is technisch gedocumenteerd in het Engels en relevant voor collega-ontwikkelaars. Denk o.a. aan ERD, UML, testen en testresultaten.
|
||||
- [ ] Het leerproces is beschreven in Standaardnederlands.
|
||||
- [ ] Het werk is gereviewd door een peer.
|
||||
- [ ] Het UX/UI gedeelte van de applicatie voldoet aan het Think-Make-Check (TMC) principe.
|
||||
- [ ] De code is functioneel getest op fouten.
|
||||
- [ ] De code werkt zonder fouten bij normaal gebruik.
|
||||
- [ ] De webapplicatie dient zowel op mobiele- als desktop-apparaten gebruikt te kunnen worden.
|
@@ -1,20 +0,0 @@
|
||||
# OpenCV
|
||||
## Requirements
|
||||
For the camera we want it to detect what is happening on the video feed and identify it so it can identify dangers.
|
||||
|
||||
|
||||
## Issues
|
||||
|
||||
* OpenCL not grabbing gpu
|
||||
* Solution: https://github.com/Smorodov/Multitarget-tracker/issues/93
|
||||
|
||||
## Installation
|
||||
### Dependencies
|
||||
* glew
|
||||
* opencv
|
||||
|
||||
|
||||
|
||||
|
||||
## Sources
|
||||
* https://github.com/UnaNancyOwen/OpenCVDNNSample/tree/master
|
@@ -1,10 +0,0 @@
|
||||
# Requirements
|
||||
|
||||
1. Het compileerd op x86 en ARM architechturen
|
||||
2. Geen dubbele code
|
||||
3. commentaar bij lastige code
|
||||
4. Doxygen comments bij elke functie, behalve als het duidelijk is in de functienaam
|
||||
5. Hou je code leesbaar
|
||||
6. Geen dode code
|
||||
7. Gebruik TODO comments (TODO TREE)
|
||||
8.
|
28
docs/explanation/Sensorbehuizing.md
Normal file
28
docs/explanation/Sensorbehuizing.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# Sensor behuizing
|
||||
|
||||
Voor de sensoren op onze Kobuki wouden wij graag een behuizing zodat deze sensoren niet los liggen op de Kobuki.
|
||||
|
||||
Deze behuizing had een paar eisen en die eisen waren als volgt
|
||||
- Hij moet klein zijn zodat hij niet veel ruimte in neemt op de Kobuki.
|
||||
- De behuizing moet makkelijk vast te maken zijn aan de Kobuki.
|
||||
- In de behuizing moet een esp32 passen en de 3 sensoren.
|
||||
- De behuizing moet makkelijk uit elkaar te halen zijn zodat als we onderhoud moeten plegen dit makkelijk kan.
|
||||
|
||||
Met deze eisen zijn we uiteindelijk een behuizing gaan maken in onshape.
|
||||
Onshape is gratis ontwerp software wat te gebruiken is via je browser.
|
||||
Hierdoor hoef je dus geen applicatie te runnen op je computer en kan je op elk apparaat inloggen om zo gemakkelijk door te gaan aan je ontwerp.
|
||||
Ik (Yannick) heb voor deze software gekozen omdat ik deze software al veel vaker heb gebruikt en hier dus al bekend mee ben.
|
||||
|
||||
Uiteindelijk zijn we op het volgende design uitgekomen.
|
||||

|
||||

|
||||
|
||||
Wij hebben gekozen voor dit design omdat dit de breedte en lengte heeft van een esp32 dus de esp past precies waardoor wij hem niet nog extra vast hoeven te zetten.
|
||||
Er zitten gaten in de zijkant van het bakje voor de kabel en voor een 5 volt kabel voor de MQ5 sensor.
|
||||
De dht11 sensor past er precies in en deze blijft daardoor precies vast zitten.
|
||||
Voor de M5stack sensor is er een gat gemaakt zodat deze kabel erdoorheen past en vervolgens wordt deze sensor op de bovenkant van de behuizing vastgeplakt.
|
||||
Voor de MQ5 sensor is een gat gemaakt waar de sensor door heen kan en het printplaatje wordt aan de onderkant vast gemaakt met stevige M3 tape.
|
||||
|
||||
In de onderkant van de behuizing zitten 2 gaten hiermee kan de behuizing goed vastgemaakt worden aan de kobuki.
|
||||
De onderkant en de bovenkant van de behuizing zijn makkelijk uit elkaar te halen omdat deze doormiddel van 4 sterke magneten aan elkaar vast zitten.
|
||||
Hierdoor is het ook makkelijk om onderhoud te plegen omdat het bakje door de magneten makkelijk uit elkaar te halen is maar niet zo makkelijk dat hij door trillingen los kan komen.
|
79
docs/explanation/Sensoronderzoek.md
Normal file
79
docs/explanation/Sensoronderzoek.md
Normal file
@@ -0,0 +1,79 @@
|
||||
# Sensor onderzoek
|
||||
|
||||
In dit bestand gaan we onderzoek doen naar de sensoren die we willen gebruiken op de Kobuki.
|
||||
Hierin gaan we meerdere sensoren vergelijken met elkaar en kijken welke wij het beste kunnen gebruiken voor ons project.
|
||||
|
||||
## Probleem
|
||||
Voor ons project moeten wij een manier vinden om gassen/stoffen te detecteren zodat je in een gebouw weet waar je niet veilig naartoe kan.
|
||||
|
||||
## De vraag
|
||||
> Welke sensoren kunnen wij het beste gebruiken om schadelijke gassen/stoffen te vinden in een gebouw ?
|
||||
|
||||
## Voorwaarden
|
||||
De voorwaarden waar de sensors aan moeten voldoen zijn:
|
||||
|
||||
- De sensoren moeten op de kobuki passen.
|
||||
- We moeten zo weining mogelijk sensoren gebruiken zodat we genoeg plek over houden voor andere onderdelen van de Kobuki.
|
||||
|
||||
## Hoe aansluiten
|
||||
Wij gaan deze sensoren aansluiten op een esp32 en deze laten wij via MQTT de gegevens doorsturen naar de raspberry pi.
|
||||
|
||||
## De sensoren.
|
||||
Wij zijn uitgekomen op 3 sensoren.
|
||||
|
||||
- De dht11 sensor
|
||||
- De tvoc/eC02 Gas Unit.
|
||||
- Gravity: Elektrochemische zuurstof-/O2-sensor (0-25%Vol, I2C) SEN0322
|
||||
- Gassensor MQ-5 module (OT2018-D55)
|
||||
|
||||
Wij hebben voor de Dht11 en de tvoc/eC02 gas unit gekozen omdat wij deze bij james konden lenen. En wij hebben gekozen voor de Gassensor MQ-5 module (OT2018-D55) Omdat dit een mooie kleine sensor is die wij makkelijk kwijt kunnen op de kobuki.
|
||||
Voor de o2 sensor hebben wij gekozen voor de Gravity: Elektrochemische zuurstof-/O2-sensor (0-25%Vol, I2C) SEN0322. Deze sensor is helaas op het moment van schrijven (29-10-2024) niet op voorraad dus deze sensor kunnen wij helaas nog niet toevoegen. Zodra deze sensor op voorraad is zal ik deze bestellen en aan de esp toevoegen.
|
||||
|
||||
## Sensor uitleg
|
||||
#### Dht11
|
||||
De dht11 is een eenvoudige en goedkope sensor die wordt gebruikt om de temperatuur en luchtvochtigheid te meten.
|
||||
|
||||
De sensor bevat de volgende onderdelen om te werken:
|
||||
- Een thermistor : Dit is een component die temperatuur meet door variaties in elektronische weerstand.
|
||||
- Een capacitieve vochtigheidssensor : Deze meet de relatieve luchtvochtigheid door de verandering in het materiaal tussen de condensatorplaten te meten. Deze verandering gebeurt door de waterdamp in de lucht.
|
||||
- Een geïntegreerde microcontroller : Deze microcontroller verwerkt de gegevens van de sensoren en zet deze om in een digitaal signaal.
|
||||
|
||||
Het meetbereik van de sensor is 0 tot 50 graden voor temperatuur en voor de luchtvochtigheid is het 20 tot 90%
|
||||
Hierbij is de temperatuur tot ±2 graden nauwkeurig en de luchtvochtigheid ±5 procent.
|
||||
|
||||
De DHT11 kan aangesloten worden op een 3.3 of 5 volt voeding.
|
||||
Wij kunnen deze sensor dus zonder problemen compleet aansluiten op de esp32s3
|
||||
|
||||
#### Tvoc/eC02 Gas Unit
|
||||
De M5Stack TVOC/eCO2-Gassensensor-eenheid (SGP30) is een compacte sensor ontwikkeld om vluchtige organische stoffen (TVOC) en schijnbare CO₂-concentraties (eCO2) te meten.
|
||||
Deze component maakt gebruik van de SGP30-sensor van Adafruit
|
||||
|
||||
De SGP30 is gebaseerd op een metal-oxide (MOX) halfgeleidertechnologie.
|
||||
Deze technologie detecteert veranderingen in elektrische weerstand bij blootstelling aan vluchtige organische stoffen (VOC's),
|
||||
zoals ethanol en aceton.
|
||||
|
||||
De sensor bevat ingebouwde algoritmes om de gemeten VOC waarden om te zetten in tvoc en eco2.
|
||||
- TVOC : Dit is de totale concentratie vluchtige organische stoffen.
|
||||
- ECO2 : Dit is een geschatte koolstofdioxideconcentratie.
|
||||
Dit is een schatting op basis van de VOC metingen.
|
||||
|
||||
Deze sensor werkt op 3.3 en 5 volt dus ook voor deze sensor kunnen wij de esp32s3 gebruiken.
|
||||
|
||||
#### MQ5 Gassensor
|
||||
|
||||
De MQ5-gassensor is een veelgebruikte sensor voor het detecteren van brandbare gassen, zoals aardgas (methaan), vloeibaar petroleumgas (LPG), waterstof en koolmonoxide. Het werkt op basis van veranderingen in elektrische weerstand van het sensorelement wanneer het wordt blootgesteld aan specifieke gassen.
|
||||
|
||||
De kern van de MQ5 sensor is een chemisch gecoat metalen oxide (meestal tinoxide).
|
||||
Dit materiaal reageert op de aanwezigheid van brandbare gassen.
|
||||
Wanneer de sensor gasdeeltjes detecteert, reageren deze met zuurstofionen op het oppervlak van het tinoxide. Deze reactie veroorzaakt een verandering in de elektrische geleidbaarheid (weerstand) van het materiaal.
|
||||
De verandering in weerstand wordt door een elektronisch circuit omgezet in een elektrisch signaal dat de concentratie van gas vertegenwoordigt.
|
||||
|
||||
De MQ5 sensor heeft ook een ingebouwde verwarmingsspiraal die het sensorelement op een hoge temperatuur houdt (ongeveer 300-500°C). Deze temperatuur zorgt ervoor dat gassen efficiënt reageren met het tinoxide-oppervlak.
|
||||
|
||||
Het enige nadeel van deze sensor is dat hij niet selectief is dus de sensor kan geen onderscheid maken tussen bijvoorbeeld methaan en lpg.
|
||||
|
||||
## Aansluitschema
|
||||

|
||||
|
||||
Hierboven is te zien hoe wij de sensoren hebben aangesloten op de esp32.
|
||||
|
BIN
docs/explanation/image.png
Normal file
BIN
docs/explanation/image.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 54 KiB |
BIN
docs/explanation/images/Aansluitschema_sensors.png
Normal file
BIN
docs/explanation/images/Aansluitschema_sensors.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 123 KiB |
BIN
docs/explanation/images/Behuizingfoto1.png
Normal file
BIN
docs/explanation/images/Behuizingfoto1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 68 KiB |
BIN
docs/explanation/images/Behuizingfoto2.png
Normal file
BIN
docs/explanation/images/Behuizingfoto2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 49 KiB |
@@ -1,9 +1,10 @@
|
||||
# **Projectplan - robot voor Gevaarlijke Omgevingen**
|
||||
|
||||
### Projectbeschrijving
|
||||
### Projectbescrhijving
|
||||
|
||||
Het project betreft de ontwikkeling van een robot voor gevaarlijke omgevingen. De robot is bedoeld om gevaarlijke situaties te verkennen en in kaart te brengen. De robot is uitgerust met verschillende sensoren en daar gaan we zelf nog een camera en andere sensoren op zetten om de omgeving te verkennen. De data wordt verzameld en geanalyseerd om een beeld te krijgen van de situatie. De robot kan worden ingezet in verschillende situaties, zoals branden, instortingen en andere gevaarlijke situaties.
|
||||
|
||||
|
||||
### 1. Organisatorische Context
|
||||
|
||||
Bij de ontwikkeling van de robot zijn verschillende factoren van belang. Maatschappelijke veranderingen zoals duurzaamheid en de toenemende vraag naar technologische oplossingen voor gevaarlijke werkomgevingen spelen een grote rol. De robot kan worden ingezet voor gevaarlijke situaties waar bijvoorbeeld geen mensen naar binnen kunnen.
|
||||
@@ -26,6 +27,7 @@ Ethische vragen staan centraal bij de ontwikkeling van de robot. Er moet rekenin
|
||||
|
||||
Het project wordt uitgevoerd vanuit een duidelijk plan waar elke sprint een deel van het project centraal staat. Driver bouwen, testen en verbindingen leggen tussen elk gedeelte van het project. We gebruiken de Agile methodiek dus alles kan nog veranderen. Hierbij moeten wij dus ook rekening houden met de etische en organisatorische aspecten, zoals duurzaamheid en veiligheid.
|
||||
|
||||
|
||||
### Aanpak
|
||||
|
||||
**Werk methode:** Gebruik van Agile projectmanagement voor flexibiliteit.
|
||||
|
@@ -1,7 +1,6 @@
|
||||
# Wat gaan we maken
|
||||
|
||||
## Sensoren
|
||||
|
||||
* Camera
|
||||
* GPS module
|
||||
* Temparatuur sensor
|
||||
@@ -13,27 +12,21 @@
|
||||
## Wat gaan we met de sensoren doen?
|
||||
|
||||
### Camera
|
||||
|
||||
De camera word gebruikt om foto's te maken in de omgeving in het geval van informatie verkrijgen voor als de robot bijvoorbeeld vast zit, geeft ook optie om informatie te krijgen zonder op de plek zelf te zijn.
|
||||
|
||||
### GPS module
|
||||
|
||||
De GPS module word gebruikt om de locatie van de robot te bepalen en aan te geven waar bijzonderheden bevinden.
|
||||
|
||||
### Temparatuur, TVOC en ECO2 sensor
|
||||
|
||||
Deze sensoren zijn bedoeld om de omgeving te meten en te kijken of de omgeving veilig is voor mensen om in te gaan.
|
||||
|
||||
### LDR sensor
|
||||
|
||||
De LDR sensor word gebruikt om de lichtsterkte te meten en te kijken of er een lamp op de robot aan moet gaan voor de camera.
|
||||
|
||||
### Time of Flight sensor
|
||||
|
||||
De Time of Flight sensor word gebruikt om de afstand te meten tussen de robot en de muur, zodat de robot niet tegen de muur aan botst.
|
||||
|
||||
## Het project
|
||||
|
||||
Bij brand of op fabrieksterreinen met gevaarlijke stoffen kan het nodig zijn om een verkenning te
|
||||
doen van een verdachte omgeving. Het is dan niet verstandig om mensen naar binnen te sturen, in
|
||||
die gevallen vallen de hulpdiensten terug om een verkenningsrobot. Het doel van het project is het
|
||||
|
1
docs/home/home.md
Normal file
1
docs/home/home.md
Normal file
@@ -0,0 +1 @@
|
||||
# home
|
5
docs/home/stappenplan.md
Normal file
5
docs/home/stappenplan.md
Normal file
@@ -0,0 +1,5 @@
|
||||
- [x] Kobuki werkt met driver.
|
||||
- [x] Ik kan de data uitlezen.
|
||||
- [ ] Data wordt correct weergegeven.
|
||||
- [ ] Ik kan de data laten zien in op de website.
|
||||
- [ ] Ik kan de kobuki besturen vanaf de website.
|
@@ -1,20 +0,0 @@
|
||||
# Daily stand ups
|
||||
|
||||
??? note "Daily Stand-ups Sprint 4"
|
||||
| Day | Submitted by | What did you do yesterday | What will you do today | Any blockers? |
|
||||
| ---------- | ------------ | ----------------------------- | -------------------------------------------------- | ------------------------------------ |
|
||||
| 18/11/2024 | Ishak | --- | Engels, Repo fixen, beginnen met nieuwe user story | --- |
|
||||
| 18/11/2024 | Sam | --- | Engels, Feedback verwerken medium stake | None |
|
||||
| 18/11/2024 | Yannick | --- | Engels, Documentatie, Code samenvoegen | None |
|
||||
| 18/11/2024 | Mees | --- | Engels, Onderzoek | None |
|
||||
| 19/11/2024 | Ishak | Engels, Repo fixen | workshop | --- |
|
||||
| 19/11/2024 | Sam | Engels, Feedback verwerken | workshop | None |
|
||||
| 19/11/2024 | Yannick | code samenvoegen,schema maken | workshop, documentatie | None |
|
||||
| 19/11/2024 | Mees | niks | workshop, fixen include path | include path werkt niet |
|
||||
| 26/11/2024 | Ishak | Workshop | database, engels video opnemen | phpmyadmin werkt niet(weet probleem) |
|
||||
| 26/11/2024 | Sam | opencv | opencv | --- |
|
||||
| 26/11/2024 | Yannick | ziek | ziek | --- |
|
||||
| 26/11/2024 | Mees | Engels video | stepper motor | vscode werkt niet |
|
||||
| 02/12/2024 | Ishak | database | database | --- |
|
||||
| 02/12/2024 | Sam | opencv | camera beeld op website | --- |
|
||||
| 02/12/2024 | Yannick | ziek, documentatie | behuizing voor esp | --- |
|
@@ -1,12 +0,0 @@
|
||||
# sprint review 4 feedback
|
||||
|
||||
- Definition of done SMART maken
|
||||
- Uitgebreider beschrijven wat er voor de definition of done nodig is
|
||||
- Testen van de software niet meer dan een halve A4
|
||||
- Acceptatie criteria beter uitschrijven( vragen aan ed)
|
||||
- Meer software ontwikkelen
|
||||
- kijken of we met een punten systeem kunnen werken in user stories. zo kan je zien hoe groot een user story is.
|
||||
- read.me file aanpassen
|
||||
- meer aan documentatie doen.
|
||||
- technisch iets te uitdagend
|
||||
- planning beter maken
|
33
mkdocs.yml
33
mkdocs.yml
@@ -34,22 +34,17 @@ plugins:
|
||||
modules: [mkdocs_macros_mdocotion]
|
||||
|
||||
markdown_extensions:
|
||||
- attr_list
|
||||
- admonition
|
||||
- pymdownx.details
|
||||
- pymdownx.superfences
|
||||
- md_in_html
|
||||
- fenced_code
|
||||
- pymdownx.highlight:
|
||||
linenums: true
|
||||
use_pygments: true
|
||||
- pymdownx.inlinehilite
|
||||
- pymdownx.snippets
|
||||
- pymdownx.superfences:
|
||||
custom_fences:
|
||||
- name: mermaid
|
||||
class: mermaid
|
||||
format: !!python/name:pymdownx.superfences.fence_code_format
|
||||
- toc:
|
||||
permalink: true
|
||||
- pymdownx.details
|
||||
- attr_list
|
||||
- md_in_html
|
||||
- fenced_code
|
||||
- pymdownx.highlight:
|
||||
linenums: true
|
||||
use_pygments: true
|
||||
- pymdownx.inlinehilite
|
||||
- pymdownx.snippets
|
||||
- pymdownx.tabbed
|
||||
- pymdownx.superfences:
|
||||
custom_fences:
|
||||
- name: mermaid
|
||||
class: mermaid
|
||||
format: !!python/name:pymdownx.superfences.fence_code_format
|
||||
|
123
src/Arduino/Sensors/Sensors.ino
Normal file
123
src/Arduino/Sensors/Sensors.ino
Normal file
@@ -0,0 +1,123 @@
|
||||
#include <DHT.h>
|
||||
#include <Wire.h>
|
||||
#include "Adafruit_SGP30.h"
|
||||
#include <WiFi.h>
|
||||
#include <PubSubClient.h>
|
||||
#include <ArduinoWebsockets.h>
|
||||
|
||||
using namespace websockets;
|
||||
|
||||
Adafruit_SGP30 sgp;
|
||||
|
||||
// Definieert de pins voor de sensoren
|
||||
#define DHTPIN 4
|
||||
#define DHTTYPE DHT11
|
||||
|
||||
#define MQ5_PIN 2
|
||||
|
||||
#define SDA_PIN 10
|
||||
#define SCL_PIN 11
|
||||
|
||||
DHT dht(DHTPIN, DHTTYPE);
|
||||
|
||||
// WiFi en MQTT instellingen
|
||||
const char* ssid = "";
|
||||
const char* password = "";
|
||||
|
||||
const char* mqtt_server = "192.168.68.104";
|
||||
const int mqtt_port = 8080; //websocket-poort
|
||||
const char* mqtt_topic = "sensors/data";
|
||||
|
||||
// MQTT client
|
||||
WiFiClient espClient;
|
||||
WebsocketsClient websocket;
|
||||
PubSubClient client(espClient);
|
||||
|
||||
// Functie om verbinding te maken met WiFi
|
||||
void setup_wifi() {
|
||||
Serial.print("Verbinden met WiFi...");
|
||||
WiFi.begin(ssid, password);
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(500);
|
||||
Serial.print(".");
|
||||
}
|
||||
Serial.println("Verbonden!");
|
||||
}
|
||||
|
||||
void reconnectMQTT() {
|
||||
while (!client.connected()) {
|
||||
Serial.print("Verbinding maken met MQTT via WebSockets...");
|
||||
if (client.connect("ESP32Client")) {
|
||||
Serial.println("Verbonden!");
|
||||
} else {
|
||||
Serial.print("Fout: ");
|
||||
Serial.print(client.state());
|
||||
delay(5000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
// Start de seriële monitor
|
||||
Serial.begin(9600);
|
||||
|
||||
dht.begin();
|
||||
|
||||
pinMode(MQ5_PIN, INPUT);
|
||||
|
||||
Wire.begin(SDA_PIN, SCL_PIN);
|
||||
Serial.println("SGP30 test");
|
||||
|
||||
// SGP30 initialiseren
|
||||
if (!sgp.begin()) {
|
||||
Serial.println("SGP30 sensor niet gevonden :(");
|
||||
while (1);
|
||||
}
|
||||
if (!sgp.IAQinit()) {
|
||||
Serial.println("SGP30 IAQ-initialisatie mislukt!");
|
||||
while (1);
|
||||
}
|
||||
|
||||
// Verbind met WiFi en MQTT-broker
|
||||
setup_wifi();
|
||||
// Stel MQTT-broker in met websockets
|
||||
client.setServer(mqtt_server, mqtt_port);
|
||||
reconnectMQTT();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Zorgt ervoor dat MQTT verbonden blijft
|
||||
if (!client.connected()) {
|
||||
reconnectMQTT();
|
||||
}
|
||||
client.loop();
|
||||
|
||||
float h = dht.readHumidity();
|
||||
float t = dht.readTemperature();
|
||||
int mq5Value = analogRead(MQ5_PIN);
|
||||
|
||||
// Check of de sensorwaarden geldig zijn
|
||||
if (isnan(h) || isnan(t) || mq5Value < 0) {
|
||||
Serial.println("Fout bij het lezen van de sensors!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Maak een JSON-payload
|
||||
String payload = "{";
|
||||
payload += "\"humidity\":" + String(h) + ",";
|
||||
payload += "\"temperature\":" + String(t) + ",";
|
||||
payload += "\"mq5\":" + String(mq5Value) + ",";
|
||||
payload += "\"tvoc\":" + String(sgp.TVOC) + ",";
|
||||
payload += "\"eco2\":" + String(sgp.eCO2);
|
||||
payload += "}";
|
||||
|
||||
// Verzend de payload via MQTT
|
||||
if (client.publish(mqtt_topic, payload.c_str())) {
|
||||
Serial.println("Bericht verzonden: " + payload);
|
||||
} else {
|
||||
Serial.println("Fout bij verzenden van bericht!");
|
||||
}
|
||||
|
||||
// Wacht 5 seconden voor de volgende meting
|
||||
delay(5000);
|
||||
}
|
40
src/Arduino/TestM5/TestM5.ino
Normal file
40
src/Arduino/TestM5/TestM5.ino
Normal file
@@ -0,0 +1,40 @@
|
||||
// Test code is merged to main sensor code os this file is not needed anymore
|
||||
|
||||
#include <Wire.h>
|
||||
#include "Adafruit_SGP30.h"
|
||||
|
||||
Adafruit_SGP30 sgp;
|
||||
|
||||
#define SDA_PIN 10
|
||||
#define SCL_PIN 11
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
while (!Serial) { delay(10); }
|
||||
|
||||
Wire.begin(SDA_PIN, SCL_PIN);
|
||||
|
||||
Serial.println("SGP30 test");
|
||||
|
||||
if (!sgp.begin()) {
|
||||
Serial.println("SGP30 sensor not found :(");
|
||||
while (1);
|
||||
}
|
||||
|
||||
// Start measurements (initialize baseline)
|
||||
if (! sgp.IAQinit()) {
|
||||
Serial.println("SGP30 IAQinit failed!");
|
||||
while (1);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (! sgp.IAQmeasure()) {
|
||||
Serial.println("Measurement failed");
|
||||
return;
|
||||
}
|
||||
Serial.print("TVOC "); Serial.print(sgp.TVOC); Serial.print(" ppb\t");
|
||||
Serial.print("eCO2 "); Serial.print(sgp.eCO2); Serial.println(" ppm");
|
||||
|
||||
delay(1000); // 1 second delay
|
||||
}
|
@@ -1,26 +1,12 @@
|
||||
cmake_minimum_required(VERSION 3.9)
|
||||
project(kobuki_control)
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
|
||||
# Find the Paho MQTT C++ library (static)
|
||||
find_library(PAHO_MQTTPP_LIBRARY paho-mqttpp3 PATHS /usr/local/lib)
|
||||
find_library(PAHO_MQTT_LIBRARY paho-mqtt3a PATHS /usr/local/lib)
|
||||
|
||||
# Find OpenCV package
|
||||
find_package(OpenCV REQUIRED)
|
||||
find_package(OpenEXR REQUIRED)
|
||||
include_directories(${OpenCV_INCLUDE_DIRS})
|
||||
|
||||
set(SOURCE_FILES
|
||||
src/KobukiDriver/KobukiParser.cpp
|
||||
src/KobukiDriver/KobukiParser.h
|
||||
src/KobukiDriver/CKobuki.cpp
|
||||
src/KobukiDriver/CKobuki.h
|
||||
src/MQTT/MqttClient.cpp
|
||||
src/MQTT/MqttClient.h
|
||||
src/main.cpp)
|
||||
src/KobukiParser.cpp
|
||||
src/KobukiParser.h
|
||||
src/CKobuki.cpp
|
||||
src/CKobuki.h
|
||||
src/main.cpp)
|
||||
|
||||
add_executable(kobuki_control ${SOURCE_FILES})
|
||||
|
||||
# Link the static libraries
|
||||
target_link_libraries(kobuki_control ${PAHO_MQTTPP_LIBRARY} ${PAHO_MQTT_LIBRARY} ${OpenCV_LIBS} pthread OpenEXR::OpenEXR)
|
||||
#target_link_libraries(kobuki_control )
|
||||
|
683
src/C++/Driver/src/CKobuki.cpp
Executable file
683
src/C++/Driver/src/CKobuki.cpp
Executable file
@@ -0,0 +1,683 @@
|
||||
#include "CKobuki.h"
|
||||
#include "errno.h"
|
||||
#include "termios.h"
|
||||
#include <cstddef>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
|
||||
// plot p;
|
||||
static std::vector<float> vectorX;
|
||||
static std::vector<float> vectorY;
|
||||
static std::vector<float> vectorGyroTheta;
|
||||
|
||||
// obsluha tty pod unixom
|
||||
int set_interface_attribs2(int fd, int speed, int parity)
|
||||
{
|
||||
struct termios tty;
|
||||
memset(&tty, 0, sizeof tty);
|
||||
if (tcgetattr(fd, &tty) != 0)
|
||||
{
|
||||
printf("error %d from tcgetattr", errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
cfsetospeed(&tty, speed);
|
||||
cfsetispeed(&tty, speed);
|
||||
|
||||
tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; // 8-bit chars
|
||||
// disable IGNBRK for mismatched speed tests; otherwise receive break
|
||||
// as \000 chars
|
||||
// tty.c_iflag &= ~IGNBRK; // disable break processing
|
||||
tty.c_lflag = 0; // no signaling chars, no echo,
|
||||
// no canonical processing
|
||||
tty.c_oflag = 0; // no remapping, no delays
|
||||
tty.c_cc[VMIN] = 0; // read doesn't block
|
||||
tty.c_cc[VTIME] = 5; // 0.5 seconds read timeout
|
||||
|
||||
tty.c_iflag &= ~(IGNBRK | INLCR | ICRNL | IXON | IXOFF |
|
||||
IXANY); // shut off xon/xoff ctrl
|
||||
|
||||
tty.c_cflag |= (CLOCAL | CREAD); // ignore modem controls,
|
||||
// enable reading
|
||||
tty.c_cflag &= ~(PARENB | PARODD); // shut off parity
|
||||
tty.c_cflag |= parity;
|
||||
tty.c_cflag &= ~CSTOPB;
|
||||
tty.c_cflag &= ~CRTSCTS;
|
||||
|
||||
if (tcsetattr(fd, TCSANOW, &tty) != 0)
|
||||
{
|
||||
printf("error %d from tcsetattr", errno);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void set_blocking2(int fd, int should_block)
|
||||
{
|
||||
struct termios tty;
|
||||
memset(&tty, 0, sizeof tty);
|
||||
if (tcgetattr(fd, &tty) != 0)
|
||||
{
|
||||
printf("error %d from tggetattr", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
tty.c_cc[VMIN] = should_block ? 1 : 0;
|
||||
tty.c_cc[VTIME] = 5; // 0.5 seconds read timeout
|
||||
|
||||
if (tcsetattr(fd, TCSANOW, &tty) != 0)
|
||||
printf("error %d setting term attributes", errno);
|
||||
}
|
||||
|
||||
int CKobuki::connect(char *comportT)
|
||||
{
|
||||
HCom = open(comportT, O_RDWR | O_NOCTTY | O_NONBLOCK);
|
||||
|
||||
if (HCom == -1)
|
||||
{
|
||||
printf("Kobuki nepripojeny\n");
|
||||
return HCom;
|
||||
}
|
||||
else
|
||||
{
|
||||
set_interface_attribs2(HCom, B115200,
|
||||
0); // set speed to 115,200 bps, 8n1 (no parity)
|
||||
set_blocking2(HCom, 0); // set no blocking
|
||||
/* struct termios settings;
|
||||
tcgetattr(HCom, &settings);
|
||||
|
||||
cfsetospeed(&settings, B115200); // baud rate
|
||||
settings.c_cflag &= ~PARENB; // no parity
|
||||
settings.c_cflag &= ~CSTOPB; // 1 stop bit
|
||||
settings.c_cflag &= ~CSIZE;
|
||||
settings.c_cflag |= CS8 | CLOCAL; // 8 bits
|
||||
settings.c_lflag &= ~ICANON; // canonical mode
|
||||
settings.c_cc[VTIME]=1;
|
||||
settings.c_oflag &= ~OPOST; // raw output
|
||||
|
||||
tcsetattr(HCom, TCSANOW, &settings); // apply the settings*/
|
||||
tcflush(HCom, TCOFLUSH);
|
||||
|
||||
printf("Kobuki pripojeny\n");
|
||||
return HCom;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char *CKobuki::readKobukiMessage()
|
||||
{
|
||||
unsigned char buffer[1];
|
||||
ssize_t Pocet;
|
||||
buffer[0] = 0;
|
||||
unsigned char *null_buffer(0);
|
||||
// citame kym nezachytime zaciatok spravy
|
||||
do
|
||||
{
|
||||
Pocet = read(HCom, buffer, 1);
|
||||
} while (buffer[0] != 0xAA);
|
||||
// mame zaciatok spravy (asi)
|
||||
if (Pocet == 1 && buffer[0] == 0xAA)
|
||||
{
|
||||
// citame dalsi byte
|
||||
do
|
||||
{
|
||||
|
||||
Pocet = read(HCom, buffer, 1);
|
||||
|
||||
} while (Pocet != 1); // na linuxe -1 na windowse 0
|
||||
|
||||
// a ak je to druhy byte hlavicky
|
||||
if (Pocet == 1 && buffer[0] == 0x55)
|
||||
{
|
||||
// precitame dlzku
|
||||
Pocet = read(HCom, buffer, 1);
|
||||
|
||||
// ReadFile(hCom, buffer, 1, &Pocet, NULL);
|
||||
if (Pocet == 1)
|
||||
{
|
||||
// mame dlzku.. nastavime vektor a precitame ho cely
|
||||
int readLenght = buffer[0];
|
||||
unsigned char *outputBuffer =
|
||||
(unsigned char *)calloc(readLenght + 4, sizeof(char));
|
||||
outputBuffer[0] = buffer[0];
|
||||
int pct = 0;
|
||||
|
||||
do
|
||||
{
|
||||
Pocet = 0;
|
||||
int readpoc = (readLenght + 1 - pct);
|
||||
Pocet = read(HCom, outputBuffer + 1 + pct, readpoc);
|
||||
|
||||
pct = pct + (Pocet == -1 ? 0 : Pocet);
|
||||
} while (pct != (readLenght + 1));
|
||||
|
||||
// tu si mozeme ceknut co chodi zo serial intefejsu Kobukiho
|
||||
// for(int i=0;i<outputBuffer[0]+2;i++)
|
||||
// {
|
||||
// printf("%x ",outputBuffer[i]);
|
||||
// }
|
||||
|
||||
return outputBuffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null_buffer;
|
||||
}
|
||||
|
||||
void CKobuki::setLed(int led1, int led2)
|
||||
{
|
||||
unsigned char message[8] = {0xaa, 0x55, 0x04, 0x0c, 0x02, 0x00, (unsigned char)((led1 + led2 * 4) % 256), 0x00};
|
||||
message[7] = message[2] ^ message[3] ^ message[4] ^ message[5] ^ message[6];
|
||||
uint32_t pocet;
|
||||
pocet = write(HCom, &message, 8);
|
||||
}
|
||||
|
||||
// tato funkcia nema moc sama o sebe vyznam, payload o tom, ze maju byt externe
|
||||
// napajania aktivne musi byt aj tak v kazdej sprave...
|
||||
void CKobuki::setPower(int value)
|
||||
{
|
||||
if (value == 1)
|
||||
{
|
||||
unsigned char message[8] = {0xaa, 0x55, 0x04, 0x0C, 0x02, 0xf0, 0x00, 0xAF};
|
||||
uint32_t pocet;
|
||||
pocet = write(HCom, &message, 8);
|
||||
}
|
||||
}
|
||||
|
||||
void CKobuki::setTranslationSpeed(int mmpersec)
|
||||
{
|
||||
unsigned char message[14] = {0xaa, 0x55, 0x0A, 0x0c, 0x02,
|
||||
0xf0, 0x00, 0x01, 0x04, mmpersec % 256,
|
||||
mmpersec >> 8, 0x00, 0x00, 0x00};
|
||||
message[13] = message[2] ^ message[3] ^ message[4] ^ message[5] ^ message[6] ^
|
||||
message[7] ^ message[8] ^ message[9] ^ message[10] ^
|
||||
message[11] ^ message[12];
|
||||
|
||||
uint32_t pocet;
|
||||
pocet = write(HCom, &message, 14);
|
||||
}
|
||||
|
||||
void CKobuki::setRotationSpeed(double radpersec)
|
||||
{
|
||||
int speedvalue = radpersec * 230.0f / 2.0f;
|
||||
unsigned char message[14] = {0xaa,
|
||||
0x55,
|
||||
0x0A,
|
||||
0x0c,
|
||||
0x02,
|
||||
0xf0,
|
||||
0x00,
|
||||
0x01,
|
||||
0x04,
|
||||
speedvalue % 256,
|
||||
speedvalue >> 8,
|
||||
0x01,
|
||||
0x00,
|
||||
0x00};
|
||||
message[13] = message[2] ^ message[3] ^ message[4] ^ message[5] ^ message[6] ^
|
||||
message[7] ^ message[8] ^ message[9] ^ message[10] ^
|
||||
message[11] ^ message[12];
|
||||
|
||||
uint32_t pocet;
|
||||
pocet = write(HCom, &message, 14);
|
||||
}
|
||||
|
||||
void CKobuki::setArcSpeed(int mmpersec, int radius)
|
||||
{
|
||||
if (radius == 0)
|
||||
{
|
||||
setTranslationSpeed(mmpersec);
|
||||
return;
|
||||
}
|
||||
|
||||
int speedvalue =
|
||||
mmpersec * ((radius + (radius > 0 ? 230 : -230)) / 2) / radius;
|
||||
unsigned char message[14] = {0xaa,
|
||||
0x55,
|
||||
0x0A,
|
||||
0x0c,
|
||||
0x02,
|
||||
0xf0,
|
||||
0x00,
|
||||
0x01,
|
||||
0x04,
|
||||
speedvalue % 256,
|
||||
speedvalue >> 8,
|
||||
radius % 256,
|
||||
radius >> 8,
|
||||
0x00};
|
||||
message[13] = message[2] ^ message[3] ^ message[4] ^ message[5] ^ message[6] ^
|
||||
message[7] ^ message[8] ^ message[9] ^ message[10] ^
|
||||
message[11] ^ message[12];
|
||||
uint32_t pocet;
|
||||
pocet = write(HCom, &message, 14);
|
||||
}
|
||||
|
||||
void CKobuki::setSound(int noteinHz, int duration)
|
||||
{
|
||||
int notevalue = floor((double)1.0 / ((double)noteinHz * 0.00000275) + 0.5);
|
||||
unsigned char message[9] = {0xaa, 0x55, 0x05,
|
||||
0x03, 0x03, notevalue % 256,
|
||||
notevalue >> 8, duration % 256, 0x00};
|
||||
message[8] = message[2] ^ message[3] ^ message[4] ^ message[5] ^ message[6] ^
|
||||
message[7];
|
||||
|
||||
uint32_t pocet;
|
||||
pocet = write(HCom, &message, 9);
|
||||
}
|
||||
|
||||
void CKobuki::startCommunication(char *portname, bool CommandsEnabled, void *userDataL)
|
||||
{
|
||||
connect(portname);
|
||||
enableCommands(CommandsEnabled);
|
||||
userData = userDataL;
|
||||
|
||||
int pthread_result;
|
||||
pthread_result = pthread_create(&threadHandle, NULL, KobukiProcess, (void *)this);
|
||||
if (pthread_result != 0) {
|
||||
std::cerr << "Error creating thread: " << pthread_result << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
int CKobuki::measure()
|
||||
{
|
||||
while (stopVlakno == 0)
|
||||
{
|
||||
unsigned char *message = readKobukiMessage();
|
||||
if (message == NULL)
|
||||
{
|
||||
// printf("vratil null message\n");
|
||||
continue;
|
||||
}
|
||||
int ok = parser.parseKobukiMessage(parser.data, message);
|
||||
|
||||
// maximalne moze trvat callback funkcia 20 ms, ak by trvala viac, nestihame
|
||||
// citat
|
||||
if (ok == 0)
|
||||
{
|
||||
loop(userData, parser.data);
|
||||
}
|
||||
free(message);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
long double CKobuki::gyroToRad(signed short GyroAngle)
|
||||
{
|
||||
|
||||
long double rad;
|
||||
if (GyroAngle < 0)
|
||||
{
|
||||
rad = GyroAngle + 360;
|
||||
}
|
||||
else
|
||||
{
|
||||
rad = GyroAngle;
|
||||
}
|
||||
return (long double)rad * PI / 180.0;
|
||||
}
|
||||
|
||||
long CKobuki::loop(void *user_data, TKobukiData &Kobuki_data)
|
||||
{
|
||||
if (iterationCount == 0)
|
||||
{
|
||||
prevLeftEncoder = Kobuki_data.EncoderLeft;
|
||||
prevRightEncoder = Kobuki_data.EncoderRight;
|
||||
prevTimestamp = Kobuki_data.timestamp;
|
||||
prevGyroTheta = gyroToRad(Kobuki_data.GyroAngle);
|
||||
iterationCount++;
|
||||
}
|
||||
|
||||
int dLeft;
|
||||
if (abs(Kobuki_data.EncoderLeft - prevLeftEncoder) > 32000)
|
||||
{
|
||||
dLeft = Kobuki_data.EncoderLeft - prevLeftEncoder +
|
||||
(Kobuki_data.EncoderLeft > prevLeftEncoder ? -65536 : +65536);
|
||||
}
|
||||
else
|
||||
{
|
||||
dLeft = Kobuki_data.EncoderLeft - prevLeftEncoder;
|
||||
}
|
||||
|
||||
int dRight;
|
||||
if (abs(Kobuki_data.EncoderRight - prevRightEncoder) > 32000)
|
||||
{
|
||||
dRight = Kobuki_data.EncoderRight - prevRightEncoder +
|
||||
(Kobuki_data.EncoderRight > prevRightEncoder ? -65536 : +65536);
|
||||
}
|
||||
else
|
||||
{
|
||||
dRight = Kobuki_data.EncoderRight - prevRightEncoder;
|
||||
}
|
||||
|
||||
long double dGyroTheta = prevGyroTheta - gyroToRad(Kobuki_data.GyroAngle);
|
||||
|
||||
if (dGyroTheta > PI)
|
||||
{
|
||||
dGyroTheta -= 2 * PI;
|
||||
}
|
||||
if (dGyroTheta < -1 * PI)
|
||||
{
|
||||
dGyroTheta += 2 * PI;
|
||||
}
|
||||
|
||||
gyroTheta += dGyroTheta;
|
||||
|
||||
uint16_t dTimestamp = Kobuki_data.timestamp - prevTimestamp;
|
||||
|
||||
long double mLeft = dLeft * tickToMeter;
|
||||
long double mRight = dRight * tickToMeter;
|
||||
|
||||
if (mLeft == mRight)
|
||||
{
|
||||
x = x + mRight;
|
||||
}
|
||||
else
|
||||
{
|
||||
x = x + (b * (mRight + mLeft)) / (2 * (mRight - mLeft)) *
|
||||
(sin((mRight - mLeft) / b + theta) - sin(theta));
|
||||
y = y + (b * (mRight + mLeft)) / (2 * (mRight - mLeft)) *
|
||||
(cos((mRight - mLeft) / b + theta) - cos(theta));
|
||||
theta = (mRight - mLeft) / b + theta;
|
||||
}
|
||||
|
||||
displacement = (mRight + mLeft) / 2;
|
||||
integratedGyroTheta = integratedGyroTheta + dGyroTheta;
|
||||
gx = gx + displacement * cos(integratedGyroTheta + dGyroTheta / 2);
|
||||
|
||||
gy = gy + displacement * sin(integratedGyroTheta + dGyroTheta / 2);
|
||||
|
||||
totalLeft += dLeft;
|
||||
totalRight += dRight;
|
||||
|
||||
// ak je suma novej a predchadzajucej vacsia ako 65536 tak to pretieklo?
|
||||
directionL = (prevLeftEncoder < Kobuki_data.EncoderLeft ? 1 : -1);
|
||||
directionR = (prevRightEncoder < Kobuki_data.EncoderRight ? 1 : -1);
|
||||
dTimestamp = (Kobuki_data.timestamp < prevTimestamp
|
||||
? prevTimestamp - Kobuki_data.timestamp + 65536
|
||||
: dTimestamp);
|
||||
|
||||
prevLeftEncoder = Kobuki_data.EncoderLeft;
|
||||
prevRightEncoder = Kobuki_data.EncoderRight;
|
||||
prevTimestamp = Kobuki_data.timestamp;
|
||||
prevGyroTheta = gyroToRad(Kobuki_data.GyroAngle);
|
||||
|
||||
// std::cout << "X: " << x
|
||||
// << " Y: " << y
|
||||
// << " Theta: " << theta
|
||||
// << "Gyro theta:" << gyroTheta
|
||||
// << std::endl;
|
||||
|
||||
static long counter = 0;
|
||||
|
||||
//vector for data plotting
|
||||
vectorX.push_back(gx);
|
||||
vectorY.push_back(gy);
|
||||
vectorGyroTheta.push_back(gyroTheta);
|
||||
|
||||
// if (counter % 100 == 0) {
|
||||
// p.plot_data(vectorY, vectorX);
|
||||
// }
|
||||
counter++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// tells the kobuki to go a few meters forward or backward, the sign decides
|
||||
// the function compensates for walking straight with the controller, internally it uses setArcSpeed and
|
||||
// uses encoder data as feedback
|
||||
void CKobuki::goStraight(long double distance){
|
||||
long double u_translation = 0; // controlled magnitude, speed of the robot in motion
|
||||
long double w_translation = distance; // requested value
|
||||
|
||||
// controller parameters
|
||||
long double Kp_translation = 4500;
|
||||
long double e_translation = 0;
|
||||
int upper_thresh_translation = 600;
|
||||
int lower_thresh_translation = 40;
|
||||
int translation_start_gain = 20;
|
||||
|
||||
long double u_rotation = 0; // controlled magnitude
|
||||
long double w_rotation = 0;
|
||||
long double Kp_rotation = 57;
|
||||
long double e_rotation = 0;
|
||||
|
||||
x = 0;
|
||||
y = 0;
|
||||
theta = 0;
|
||||
|
||||
long i = 5;
|
||||
//send command and hold until robot reaches point
|
||||
while (fabs(x - w_translation) > 0.005 && x < w_translation)
|
||||
{
|
||||
e_translation = w_translation - x;
|
||||
u_translation = Kp_translation * e_translation;
|
||||
|
||||
e_rotation = w_rotation - theta;
|
||||
if (!e_rotation == 0)
|
||||
u_rotation = Kp_rotation / e_rotation;
|
||||
|
||||
// limit translation speed
|
||||
if (u_translation > upper_thresh_translation)
|
||||
u_translation = upper_thresh_translation;
|
||||
if (u_translation < lower_thresh_translation)
|
||||
u_translation = lower_thresh_translation;
|
||||
|
||||
// rewrite starting speed with line
|
||||
if (i < u_translation)
|
||||
{
|
||||
u_translation = i;
|
||||
}
|
||||
|
||||
if (fabs(u_rotation) > 32767)
|
||||
{
|
||||
u_rotation = -32767;
|
||||
}
|
||||
|
||||
if (u_rotation == 0)
|
||||
{
|
||||
u_rotation = -32767;
|
||||
}
|
||||
//send command to robot
|
||||
this->setArcSpeed(u_translation, u_rotation);
|
||||
|
||||
// increment starting speed
|
||||
i = i + translation_start_gain;
|
||||
}
|
||||
this->setTranslationSpeed(0);
|
||||
}
|
||||
|
||||
/// the method performs the rotation, it rotates using the regulator, the
|
||||
/// gyroscope serves as feedback, because it is much more accurate than encoders
|
||||
void CKobuki::doRotation(long double th)
|
||||
{
|
||||
long double u = 0; // controlled variable, angular speed of the robot during movement
|
||||
long double w = th; // desired value in radians
|
||||
long double Kp = PI;
|
||||
long double e = 0;
|
||||
int thresh = PI / 2;
|
||||
|
||||
theta = 0;
|
||||
x = 0;
|
||||
y = 0;
|
||||
gyroTheta = 0;
|
||||
|
||||
long double i = 0;
|
||||
|
||||
if (w > 0)
|
||||
{
|
||||
while (gyroTheta < w)
|
||||
{
|
||||
e = w - gyroTheta;
|
||||
u = Kp * e;
|
||||
|
||||
if (u > thresh)
|
||||
u = thresh;
|
||||
if (u < 0.4)
|
||||
u = 0.4;
|
||||
|
||||
if (i < u)
|
||||
{
|
||||
u = i;
|
||||
}
|
||||
|
||||
std::cout << "Angle: " << gyroTheta << " required:" << w << std::endl;
|
||||
this->setRotationSpeed(-1 * u);
|
||||
usleep(25 * 1000);
|
||||
i = i + 0.1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (gyroTheta > w)
|
||||
{
|
||||
e = w - gyroTheta;
|
||||
u = Kp * e * -1;
|
||||
|
||||
if (u > thresh)
|
||||
u = thresh;
|
||||
if (u < 0.4)
|
||||
u = 0.4;
|
||||
|
||||
if (i < u)
|
||||
{
|
||||
u = i;
|
||||
}
|
||||
|
||||
std::cout << "Angle: " << gyroTheta << " required:" << w << std::endl;
|
||||
this->setRotationSpeed(u);
|
||||
usleep(25 * 1000);
|
||||
i = i + 0.1;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "Rotation done" << std::endl;
|
||||
this->setRotationSpeed(0);
|
||||
usleep(25*1000);
|
||||
}
|
||||
|
||||
// combines navigation to a coordinate and rotation by an angle, performs movement to
|
||||
// the selected coordinate in the robot's coordinate system
|
||||
void CKobuki::goToXy(long double xx, long double yy)
|
||||
{
|
||||
long double th;
|
||||
|
||||
yy = yy * -1;
|
||||
|
||||
th = atan2(yy, xx);
|
||||
doRotation(th);
|
||||
|
||||
long double s = sqrt(pow(xx, 2) + pow(yy, 2));
|
||||
|
||||
// resetnem suradnicovu sustavu robota
|
||||
x = 0;
|
||||
y = 0;
|
||||
iterationCount = 0;
|
||||
theta = 0;
|
||||
|
||||
// std::cout << "mam prejst: " << s << "[m]" << std::endl;
|
||||
|
||||
goStraight(s);
|
||||
|
||||
usleep(25 * 1000);
|
||||
return;
|
||||
}
|
||||
|
||||
/// @brief Makes the Kobuki go forward
|
||||
/// @param speedvalue speed of robot in mm/s
|
||||
/// @param distance distance in meters
|
||||
void CKobuki::forward(int speedvalue) {
|
||||
// Use the goStraight logic to determine the speed and distance
|
||||
|
||||
// Calculate the actual speed and radius values based on the conversion table
|
||||
int actual_speed = speedvalue;
|
||||
int actual_radius = 0; // Pure translation (straight line)
|
||||
|
||||
unsigned char message[11] = {
|
||||
0xaa, // Start byte 1
|
||||
0x55, // Start byte 2
|
||||
0x08, // Payload length (the first 2 bytes dont count)
|
||||
0x01, // payload type (0x01 = control command)
|
||||
0x04, // Control byte or additional identifier
|
||||
actual_speed % 256, // Lower byte of speed value
|
||||
actual_speed >> 8, // Upper byte of speed value
|
||||
0x00, // Placeholder for radius
|
||||
0x00, // Placeholder for radius
|
||||
0x00 // Placeholder for checksum
|
||||
};
|
||||
|
||||
// Calculate checksum
|
||||
message[10] = message[2] ^ message[3] ^ message[4] ^ message[5] ^ message[6] ^
|
||||
message[7] ^ message[8] ^ message[9];
|
||||
|
||||
// Send the message
|
||||
uint32_t pocet;
|
||||
pocet = write(HCom, &message, 11);
|
||||
pocet = write(HCom, &message, 11);
|
||||
|
||||
}
|
||||
|
||||
/// @brief Makes the kobuki rotate
|
||||
/// @param degrees Rotation in degrees
|
||||
void CKobuki::Rotate(int degrees) {
|
||||
|
||||
// convert raidans to degrees
|
||||
float radians = degrees * PI / 180.0;
|
||||
|
||||
// Calculate the rotation speed in radians per second
|
||||
double radpersec = 1;
|
||||
|
||||
// calculator rotation time and give absolute value
|
||||
float rotation_time = std::abs(radians / radpersec);
|
||||
|
||||
// Use original function to set the rotation speed in mm/s
|
||||
setRotationSpeed(radians);
|
||||
|
||||
// Sleep for the calculated rotation time
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(static_cast<int>(rotation_time * 1000)));
|
||||
|
||||
// Stop the robot after the rotation
|
||||
setRotationSpeed(0);
|
||||
}
|
||||
|
||||
|
||||
void CKobuki::robotSafety() {
|
||||
while (true) {
|
||||
|
||||
if (parser.data.BumperCenter || parser.data.BumperLeft || parser.data.BumperRight ||
|
||||
parser.data.CliffLeft || parser.data.CliffCenter || parser.data.CliffRight) {
|
||||
std::cout << "Safety condition triggered!" << std::endl; // Debug print
|
||||
forward(-100); // reverse the robot
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void CKobuki::sendNullMessage(){
|
||||
|
||||
unsigned char message[11] = {
|
||||
0xaa, // Start byte 1
|
||||
0x55, // Start byte 2
|
||||
0x08, // Payload length (the first 2 bytes dont count)
|
||||
0x01, // payload type (0x01 = control command)
|
||||
0x04, // Control byte or additional identifier
|
||||
0x00, // Lower byte of speed value
|
||||
0x00, // Upper byte of speed value
|
||||
0x00, // Placeholder for radius
|
||||
0x00, // Placeholder for radius
|
||||
0x00 // Placeholder for checksum
|
||||
};
|
||||
|
||||
|
||||
message[10] = message[2] ^ message[3] ^ message[4] ^ message[5] ^ message[6] ^
|
||||
message[7] ^ message[8] ^ message[9];
|
||||
|
||||
// Send the message
|
||||
uint32_t pocet;
|
||||
pocet = write(HCom, &message, 11);
|
||||
}
|
@@ -31,6 +31,7 @@
|
||||
#include <chrono>
|
||||
#include <sstream>
|
||||
#include "KobukiParser.h"
|
||||
#include "graph.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -75,10 +76,8 @@ public:
|
||||
void goToXy(long double xx, long double yy);
|
||||
void Rotate(int degrees);
|
||||
std::ofstream odometry_log;
|
||||
void robotSafety(std::string *pointerToMessage);
|
||||
void robotSafety(); //overload
|
||||
void robotSafety();
|
||||
void sendNullMessage();
|
||||
bool safetyActive = false;
|
||||
KobukiParser parser;
|
||||
|
||||
|
@@ -1,620 +0,0 @@
|
||||
#include "CKobuki.h"
|
||||
#include "errno.h"
|
||||
#include "termios.h"
|
||||
#include <cstddef>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
// plot p;
|
||||
static std::vector<float> vectorX;
|
||||
static std::vector<float> vectorY;
|
||||
static std::vector<float> vectorGyroTheta;
|
||||
|
||||
// obsluha tty pod unixom
|
||||
int set_interface_attribs2(int fd, int speed, int parity) {
|
||||
struct termios tty;
|
||||
memset(&tty, 0, sizeof tty);
|
||||
if (tcgetattr(fd, &tty) != 0) {
|
||||
printf("error %d from tcgetattr", errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
cfsetospeed(&tty, speed);
|
||||
cfsetispeed(&tty, speed);
|
||||
|
||||
tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; // 8-bit chars
|
||||
// disable IGNBRK for mismatched speed tests; otherwise receive break
|
||||
// as \000 chars
|
||||
// tty.c_iflag &= ~IGNBRK; // disable break processing
|
||||
tty.c_lflag = 0; // no signaling chars, no echo,
|
||||
// no canonical processing
|
||||
tty.c_oflag = 0; // no remapping, no delays
|
||||
tty.c_cc[VMIN] = 0; // read doesn't block
|
||||
tty.c_cc[VTIME] = 5; // 0.5 seconds read timeout
|
||||
|
||||
tty.c_iflag &= ~(IGNBRK | INLCR | ICRNL | IXON | IXOFF |
|
||||
IXANY); // shut off xon/xoff ctrl
|
||||
|
||||
tty.c_cflag |= (CLOCAL | CREAD); // ignore modem controls,
|
||||
// enable reading
|
||||
tty.c_cflag &= ~(PARENB | PARODD); // shut off parity
|
||||
tty.c_cflag |= parity;
|
||||
tty.c_cflag &= ~CSTOPB;
|
||||
tty.c_cflag &= ~CRTSCTS;
|
||||
|
||||
if (tcsetattr(fd, TCSANOW, &tty) != 0) {
|
||||
printf("error %d from tcsetattr", errno);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void set_blocking2(int fd, int should_block) {
|
||||
struct termios tty;
|
||||
memset(&tty, 0, sizeof tty);
|
||||
if (tcgetattr(fd, &tty) != 0) {
|
||||
printf("error %d from tggetattr", errno);
|
||||
return;
|
||||
}
|
||||
|
||||
tty.c_cc[VMIN] = should_block ? 1 : 0;
|
||||
tty.c_cc[VTIME] = 5; // 0.5 seconds read timeout
|
||||
|
||||
if (tcsetattr(fd, TCSANOW, &tty) != 0)
|
||||
printf("error %d setting term attributes", errno);
|
||||
}
|
||||
|
||||
int CKobuki::connect(char *comportT) {
|
||||
HCom = open(comportT, O_RDWR | O_NOCTTY | O_NONBLOCK);
|
||||
|
||||
if (HCom == -1) {
|
||||
printf("Kobuki nepripojeny\n");
|
||||
return HCom;
|
||||
} else {
|
||||
set_interface_attribs2(HCom, B115200,
|
||||
0); // set speed to 115,200 bps, 8n1 (no parity)
|
||||
set_blocking2(HCom, 0); // set no blocking
|
||||
/* struct termios settings;
|
||||
tcgetattr(HCom, &settings);
|
||||
|
||||
cfsetospeed(&settings, B115200); // baud rate
|
||||
settings.c_cflag &= ~PARENB; // no parity
|
||||
settings.c_cflag &= ~CSTOPB; // 1 stop bit
|
||||
settings.c_cflag &= ~CSIZE;
|
||||
settings.c_cflag |= CS8 | CLOCAL; // 8 bits
|
||||
settings.c_lflag &= ~ICANON; // canonical mode
|
||||
settings.c_cc[VTIME]=1;
|
||||
settings.c_oflag &= ~OPOST; // raw output
|
||||
|
||||
tcsetattr(HCom, TCSANOW, &settings); // apply the settings*/
|
||||
tcflush(HCom, TCOFLUSH);
|
||||
|
||||
printf("Kobuki pripojeny\n");
|
||||
return HCom;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char *CKobuki::readKobukiMessage() {
|
||||
unsigned char buffer[1];
|
||||
ssize_t Pocet;
|
||||
buffer[0] = 0;
|
||||
unsigned char *null_buffer(0);
|
||||
// citame kym nezachytime zaciatok spravy
|
||||
do {
|
||||
Pocet = read(HCom, buffer, 1);
|
||||
} while (buffer[0] != 0xAA);
|
||||
// mame zaciatok spravy (asi)
|
||||
if (Pocet == 1 && buffer[0] == 0xAA) {
|
||||
// citame dalsi byte
|
||||
do {
|
||||
|
||||
Pocet = read(HCom, buffer, 1);
|
||||
|
||||
} while (Pocet != 1); // na linuxe -1 na windowse 0
|
||||
|
||||
// a ak je to druhy byte hlavicky
|
||||
if (Pocet == 1 && buffer[0] == 0x55) {
|
||||
// precitame dlzku
|
||||
Pocet = read(HCom, buffer, 1);
|
||||
|
||||
// ReadFile(hCom, buffer, 1, &Pocet, NULL);
|
||||
if (Pocet == 1) {
|
||||
// mame dlzku.. nastavime vektor a precitame ho cely
|
||||
int readLenght = buffer[0];
|
||||
unsigned char *outputBuffer =
|
||||
(unsigned char *)calloc(readLenght + 4, sizeof(char));
|
||||
outputBuffer[0] = buffer[0];
|
||||
int pct = 0;
|
||||
|
||||
do {
|
||||
Pocet = 0;
|
||||
int readpoc = (readLenght + 1 - pct);
|
||||
Pocet = read(HCom, outputBuffer + 1 + pct, readpoc);
|
||||
|
||||
pct = pct + (Pocet == -1 ? 0 : Pocet);
|
||||
} while (pct != (readLenght + 1));
|
||||
|
||||
// tu si mozeme ceknut co chodi zo serial intefejsu Kobukiho
|
||||
// for(int i=0;i<outputBuffer[0]+2;i++)
|
||||
// {
|
||||
// printf("%x ",outputBuffer[i]);
|
||||
// }
|
||||
|
||||
return outputBuffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null_buffer;
|
||||
}
|
||||
|
||||
void CKobuki::setLed(int led1, int led2) {
|
||||
unsigned char message[8] = {0xaa,
|
||||
0x55,
|
||||
0x04,
|
||||
0x0c,
|
||||
0x02,
|
||||
0x00,
|
||||
(unsigned char)((led1 + led2 * 4) % 256),
|
||||
0x00};
|
||||
message[7] = message[2] ^ message[3] ^ message[4] ^ message[5] ^ message[6];
|
||||
uint32_t pocet;
|
||||
pocet = write(HCom, &message, 8);
|
||||
}
|
||||
|
||||
// tato funkcia nema moc sama o sebe vyznam, payload o tom, ze maju byt externe
|
||||
// napajania aktivne musi byt aj tak v kazdej sprave...
|
||||
void CKobuki::setPower(int value) {
|
||||
if (value == 1) {
|
||||
unsigned char message[8] = {0xaa, 0x55, 0x04, 0x0C, 0x02, 0xf0, 0x00, 0xAF};
|
||||
uint32_t pocet;
|
||||
pocet = write(HCom, &message, 8);
|
||||
}
|
||||
}
|
||||
|
||||
void CKobuki::setTranslationSpeed(int mmpersec) {
|
||||
unsigned char message[14] = {0xaa, 0x55, 0x0A, 0x0c, 0x02,
|
||||
0xf0, 0x00, 0x01, 0x04, mmpersec % 256,
|
||||
mmpersec >> 8, 0x00, 0x00, 0x00};
|
||||
message[13] = message[2] ^ message[3] ^ message[4] ^ message[5] ^ message[6] ^
|
||||
message[7] ^ message[8] ^ message[9] ^ message[10] ^
|
||||
message[11] ^ message[12];
|
||||
|
||||
uint32_t pocet;
|
||||
pocet = write(HCom, &message, 14);
|
||||
}
|
||||
|
||||
void CKobuki::setRotationSpeed(double radpersec) {
|
||||
int speedvalue = radpersec * 230.0f / 2.0f;
|
||||
unsigned char message[14] = {0xaa,
|
||||
0x55,
|
||||
0x0A,
|
||||
0x0c,
|
||||
0x02,
|
||||
0xf0,
|
||||
0x00,
|
||||
0x01,
|
||||
0x04,
|
||||
speedvalue % 256,
|
||||
speedvalue >> 8,
|
||||
0x01,
|
||||
0x00,
|
||||
0x00};
|
||||
message[13] = message[2] ^ message[3] ^ message[4] ^ message[5] ^ message[6] ^
|
||||
message[7] ^ message[8] ^ message[9] ^ message[10] ^
|
||||
message[11] ^ message[12];
|
||||
|
||||
uint32_t pocet;
|
||||
pocet = write(HCom, &message, 14);
|
||||
}
|
||||
|
||||
void CKobuki::setArcSpeed(int mmpersec, int radius) {
|
||||
if (radius == 0) {
|
||||
setTranslationSpeed(mmpersec);
|
||||
return;
|
||||
}
|
||||
|
||||
int speedvalue =
|
||||
mmpersec * ((radius + (radius > 0 ? 230 : -230)) / 2) / radius;
|
||||
unsigned char message[14] = {0xaa,
|
||||
0x55,
|
||||
0x0A,
|
||||
0x0c,
|
||||
0x02,
|
||||
0xf0,
|
||||
0x00,
|
||||
0x01,
|
||||
0x04,
|
||||
speedvalue % 256,
|
||||
speedvalue >> 8,
|
||||
radius % 256,
|
||||
radius >> 8,
|
||||
0x00};
|
||||
message[13] = message[2] ^ message[3] ^ message[4] ^ message[5] ^ message[6] ^
|
||||
message[7] ^ message[8] ^ message[9] ^ message[10] ^
|
||||
message[11] ^ message[12];
|
||||
uint32_t pocet;
|
||||
pocet = write(HCom, &message, 14);
|
||||
}
|
||||
|
||||
void CKobuki::setSound(int noteinHz, int duration) {
|
||||
int notevalue = floor((double)1.0 / ((double)noteinHz * 0.00000275) + 0.5);
|
||||
unsigned char message[9] = {0xaa, 0x55, 0x05,
|
||||
0x03, 0x03, notevalue % 256,
|
||||
notevalue >> 8, duration % 256, 0x00};
|
||||
message[8] = message[2] ^ message[3] ^ message[4] ^ message[5] ^ message[6] ^
|
||||
message[7];
|
||||
|
||||
uint32_t pocet;
|
||||
pocet = write(HCom, &message, 9);
|
||||
}
|
||||
|
||||
void CKobuki::startCommunication(char *portname, bool CommandsEnabled,
|
||||
void *userDataL) {
|
||||
connect(portname);
|
||||
enableCommands(CommandsEnabled);
|
||||
userData = userDataL;
|
||||
|
||||
int pthread_result;
|
||||
pthread_result =
|
||||
pthread_create(&threadHandle, NULL, KobukiProcess, (void *)this);
|
||||
if (pthread_result != 0) {
|
||||
std::cerr << "Error creating thread: " << pthread_result << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
int CKobuki::measure() {
|
||||
while (stopVlakno == 0) {
|
||||
unsigned char *message = readKobukiMessage();
|
||||
if (message == NULL) {
|
||||
// printf("vratil null message\n");
|
||||
continue;
|
||||
}
|
||||
int ok = parser.parseKobukiMessage(parser.data, message);
|
||||
|
||||
// maximalne moze trvat callback funkcia 20 ms, ak by trvala viac, nestihame
|
||||
// citat
|
||||
if (ok == 0) {
|
||||
loop(userData, parser.data);
|
||||
}
|
||||
free(message);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
long double CKobuki::gyroToRad(signed short GyroAngle) {
|
||||
|
||||
long double rad;
|
||||
if (GyroAngle < 0) {
|
||||
rad = GyroAngle + 360;
|
||||
} else {
|
||||
rad = GyroAngle;
|
||||
}
|
||||
return (long double)rad * PI / 180.0;
|
||||
}
|
||||
|
||||
long CKobuki::loop(void *user_data, TKobukiData &Kobuki_data) {
|
||||
if (iterationCount == 0) {
|
||||
prevLeftEncoder = Kobuki_data.EncoderLeft;
|
||||
prevRightEncoder = Kobuki_data.EncoderRight;
|
||||
prevTimestamp = Kobuki_data.timestamp;
|
||||
prevGyroTheta = gyroToRad(Kobuki_data.GyroAngle);
|
||||
iterationCount++;
|
||||
}
|
||||
|
||||
int dLeft;
|
||||
if (abs(Kobuki_data.EncoderLeft - prevLeftEncoder) > 32000) {
|
||||
dLeft = Kobuki_data.EncoderLeft - prevLeftEncoder +
|
||||
(Kobuki_data.EncoderLeft > prevLeftEncoder ? -65536 : +65536);
|
||||
} else {
|
||||
dLeft = Kobuki_data.EncoderLeft - prevLeftEncoder;
|
||||
}
|
||||
|
||||
int dRight;
|
||||
if (abs(Kobuki_data.EncoderRight - prevRightEncoder) > 32000) {
|
||||
dRight = Kobuki_data.EncoderRight - prevRightEncoder +
|
||||
(Kobuki_data.EncoderRight > prevRightEncoder ? -65536 : +65536);
|
||||
} else {
|
||||
dRight = Kobuki_data.EncoderRight - prevRightEncoder;
|
||||
}
|
||||
|
||||
long double dGyroTheta = prevGyroTheta - gyroToRad(Kobuki_data.GyroAngle);
|
||||
|
||||
if (dGyroTheta > PI) {
|
||||
dGyroTheta -= 2 * PI;
|
||||
}
|
||||
if (dGyroTheta < -1 * PI) {
|
||||
dGyroTheta += 2 * PI;
|
||||
}
|
||||
|
||||
gyroTheta += dGyroTheta;
|
||||
|
||||
uint16_t dTimestamp = Kobuki_data.timestamp - prevTimestamp;
|
||||
|
||||
long double mLeft = dLeft * tickToMeter;
|
||||
long double mRight = dRight * tickToMeter;
|
||||
|
||||
if (mLeft == mRight) {
|
||||
x = x + mRight;
|
||||
} else {
|
||||
x = x + (b * (mRight + mLeft)) / (2 * (mRight - mLeft)) *
|
||||
(sin((mRight - mLeft) / b + theta) - sin(theta));
|
||||
y = y + (b * (mRight + mLeft)) / (2 * (mRight - mLeft)) *
|
||||
(cos((mRight - mLeft) / b + theta) - cos(theta));
|
||||
theta = (mRight - mLeft) / b + theta;
|
||||
}
|
||||
|
||||
displacement = (mRight + mLeft) / 2;
|
||||
integratedGyroTheta = integratedGyroTheta + dGyroTheta;
|
||||
gx = gx + displacement * cos(integratedGyroTheta + dGyroTheta / 2);
|
||||
|
||||
gy = gy + displacement * sin(integratedGyroTheta + dGyroTheta / 2);
|
||||
|
||||
totalLeft += dLeft;
|
||||
totalRight += dRight;
|
||||
|
||||
// ak je suma novej a predchadzajucej vacsia ako 65536 tak to pretieklo?
|
||||
directionL = (prevLeftEncoder < Kobuki_data.EncoderLeft ? 1 : -1);
|
||||
directionR = (prevRightEncoder < Kobuki_data.EncoderRight ? 1 : -1);
|
||||
dTimestamp = (Kobuki_data.timestamp < prevTimestamp
|
||||
? prevTimestamp - Kobuki_data.timestamp + 65536
|
||||
: dTimestamp);
|
||||
|
||||
prevLeftEncoder = Kobuki_data.EncoderLeft;
|
||||
prevRightEncoder = Kobuki_data.EncoderRight;
|
||||
prevTimestamp = Kobuki_data.timestamp;
|
||||
prevGyroTheta = gyroToRad(Kobuki_data.GyroAngle);
|
||||
|
||||
// std::cout << "X: " << x
|
||||
// << " Y: " << y
|
||||
// << " Theta: " << theta
|
||||
// << "Gyro theta:" << gyroTheta
|
||||
// << std::endl;
|
||||
|
||||
static long counter = 0;
|
||||
|
||||
vectorX.push_back(gx);
|
||||
vectorY.push_back(gy);
|
||||
vectorGyroTheta.push_back(gyroTheta);
|
||||
|
||||
// if (counter % 100 == 0) {
|
||||
// p.plot_data(vectorY, vectorX);
|
||||
// }
|
||||
counter++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// tells the kobuki to go a few meters forward or backward, the sign decides
|
||||
// the function compensates for walking straight with the controller, internally
|
||||
// it uses setArcSpeed and uses encoder data as feedback
|
||||
void CKobuki::goStraight(long double distance) {
|
||||
long double u_translation =
|
||||
0; // controlled magnitude, speed of the robot in motion
|
||||
long double w_translation = distance; // requested value
|
||||
|
||||
// controller parameters
|
||||
long double Kp_translation = 4500;
|
||||
long double e_translation = 0;
|
||||
int upper_thresh_translation = 600;
|
||||
int lower_thresh_translation = 40;
|
||||
int translation_start_gain = 20;
|
||||
|
||||
long double u_rotation = 0; // controlled magnitude
|
||||
long double w_rotation = 0;
|
||||
long double Kp_rotation = 57;
|
||||
long double e_rotation = 0;
|
||||
|
||||
x = 0;
|
||||
y = 0;
|
||||
theta = 0;
|
||||
|
||||
long i = 5;
|
||||
// send command and hold until robot reaches point
|
||||
while (fabs(x - w_translation) > 0.005 && x < w_translation) {
|
||||
e_translation = w_translation - x;
|
||||
u_translation = Kp_translation * e_translation;
|
||||
|
||||
e_rotation = w_rotation - theta;
|
||||
if (!e_rotation == 0)
|
||||
u_rotation = Kp_rotation / e_rotation;
|
||||
|
||||
// limit translation speed
|
||||
if (u_translation > upper_thresh_translation)
|
||||
u_translation = upper_thresh_translation;
|
||||
if (u_translation < lower_thresh_translation)
|
||||
u_translation = lower_thresh_translation;
|
||||
|
||||
// rewrite starting speed with line
|
||||
if (i < u_translation) {
|
||||
u_translation = i;
|
||||
}
|
||||
|
||||
if (fabs(u_rotation) > 32767) {
|
||||
u_rotation = -32767;
|
||||
}
|
||||
|
||||
if (u_rotation == 0) {
|
||||
u_rotation = -32767;
|
||||
}
|
||||
// send command to robot
|
||||
this->setArcSpeed(u_translation, u_rotation);
|
||||
|
||||
// increment starting speed
|
||||
i = i + translation_start_gain;
|
||||
}
|
||||
this->setTranslationSpeed(0);
|
||||
}
|
||||
|
||||
/// the method performs the rotation, it rotates using the regulator, the
|
||||
/// gyroscope serves as feedback, because it is much more accurate than encoders
|
||||
void CKobuki::doRotation(long double th) {
|
||||
long double u =
|
||||
0; // controlled variable, angular speed of the robot during movement
|
||||
long double w = th; // desired value in radians
|
||||
long double Kp = PI;
|
||||
long double e = 0;
|
||||
long double thresh = PI / 2;
|
||||
|
||||
theta = 0;
|
||||
x = 0;
|
||||
y = 0;
|
||||
gyroTheta = 0;
|
||||
|
||||
long double i = 0;
|
||||
|
||||
if (w > 0) {
|
||||
while (gyroTheta < w) {
|
||||
e = w - gyroTheta;
|
||||
u = Kp * e;
|
||||
|
||||
if (u > thresh) {
|
||||
u = thresh;
|
||||
}
|
||||
if (u < 0.4) {
|
||||
u = 0.4;
|
||||
}
|
||||
if (i < u) {
|
||||
u = i;
|
||||
}
|
||||
|
||||
std::cout << "Angle: " << gyroTheta << " required:" << w << std::endl;
|
||||
this->setRotationSpeed(-1 * u);
|
||||
usleep(25 * 1000);
|
||||
i = i + 0.1;
|
||||
}
|
||||
} else {
|
||||
while (gyroTheta > w) {
|
||||
e = w - gyroTheta;
|
||||
u = Kp * e * -1;
|
||||
|
||||
if (u > thresh)
|
||||
u = thresh;
|
||||
if (u < 0.4)
|
||||
u = 0.4;
|
||||
|
||||
if (i < u) {
|
||||
u = i;
|
||||
}
|
||||
|
||||
std::cout << "Angle: " << gyroTheta << " required:" << w << std::endl;
|
||||
this->setRotationSpeed(u);
|
||||
usleep(25 * 1000);
|
||||
i = i + 0.1;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "Rotation done" << std::endl;
|
||||
this->setRotationSpeed(0);
|
||||
usleep(25 * 1000);
|
||||
}
|
||||
|
||||
/// @brief Makes the robot move forward for 3 seconds
|
||||
/// @param speedvalue How fast it will drive forward from 0 - 1024
|
||||
void CKobuki::forward(int speedvalue) {
|
||||
// Use the goStraight logic to determine the speed and distance
|
||||
|
||||
// Calculate the actual speed and radius values based on the conversion table
|
||||
int actual_speed = speedvalue;
|
||||
int actual_radius = 0; // Pure translation (straight line)
|
||||
|
||||
unsigned char message[11] = {
|
||||
0xaa, // Start byte 1
|
||||
0x55, // Start byte 2
|
||||
0x08, // Payload length (the first 2 bytes dont count)
|
||||
0x01, // payload type (0x01 = control command)
|
||||
0x04, // Control byte or additional identifier
|
||||
actual_speed % 256, // Lower byte of speed value
|
||||
actual_speed >> 8, // Upper byte of speed value
|
||||
0x00, // Placeholder for radius
|
||||
0x00, // Placeholder for radius
|
||||
0x00 // Placeholder for checksum
|
||||
};
|
||||
|
||||
// Calculate checksum
|
||||
message[10] = message[2] ^ message[3] ^ message[4] ^ message[5] ^ message[6] ^
|
||||
message[7] ^ message[8] ^ message[9];
|
||||
|
||||
// Send the message
|
||||
uint32_t pocet;
|
||||
pocet = write(HCom, &message, 11);
|
||||
}
|
||||
|
||||
/// @brief Makes the kobuki rotate
|
||||
/// @param degrees Rotation in degrees
|
||||
void CKobuki::Rotate(int degrees) {
|
||||
|
||||
// convert raidans to degrees
|
||||
float radians = degrees * PI / 180.0;
|
||||
|
||||
// Calculate the rotation speed in radians per second
|
||||
double RADS_PER_SEC = 1;
|
||||
|
||||
// calculator rotation time and give absolute value
|
||||
float rotation_time = std::abs(radians / RADS_PER_SEC);
|
||||
|
||||
// Use original function to set the rotation speed in mm/s
|
||||
setRotationSpeed(radians);
|
||||
|
||||
// Sleep for the calculated rotation time
|
||||
std::this_thread::sleep_for(
|
||||
std::chrono::milliseconds(static_cast<int>(rotation_time * 1000)));
|
||||
|
||||
// Stop the robot after the rotation
|
||||
setRotationSpeed(0);
|
||||
}
|
||||
|
||||
|
||||
/// @brief Robot safety function to be ran in another thread. Makes sure the robot does not throw inteself from the table. Only use this when the speed is lower than 350
|
||||
/// @param pointerToMessage Set this pointer to the control message and then it attempts to reset it when it bumps into something so it doesnt keep trying to do the past commant
|
||||
// TODO: make this return bool so it can be used in the control part
|
||||
void CKobuki::robotSafety(std::string *pointerToMessage) {
|
||||
while (true) {
|
||||
|
||||
if (parser.data.BumperCenter || parser.data.BumperLeft ||
|
||||
parser.data.BumperRight || parser.data.CliffLeft ||
|
||||
parser.data.CliffCenter || parser.data.CliffRight) {
|
||||
std::cout << "Safety condition triggered!" << std::endl; // Debug print
|
||||
*pointerToMessage = "estop";
|
||||
forward(-100); // reverse the robot
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(static_cast<int>(100)));
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Robot safety function to be ran in another thread. Makes sure the robot does not throw inteself from the table. Only use this when the speed is lower than 350
|
||||
void CKobuki::robotSafety() {
|
||||
while (true) {
|
||||
|
||||
if (parser.data.BumperCenter || parser.data.BumperLeft ||
|
||||
parser.data.BumperRight || parser.data.CliffLeft ||
|
||||
parser.data.CliffCenter || parser.data.CliffRight) {
|
||||
std::cout << "Safety condition triggered!" << std::endl; // Debug print
|
||||
forward(-100); // reverse the robot
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief When called the robot gets a control message to stop whatever its doing
|
||||
void CKobuki::sendNullMessage() {
|
||||
|
||||
unsigned char message[11] = {
|
||||
0xaa, // Start byte 1
|
||||
0x55, // Start byte 2
|
||||
0x08, // Payload length (the first 2 bytes dont count)
|
||||
0x01, // payload type (0x01 = control command)
|
||||
0x04, // Control byte or additional identifier
|
||||
0x00, // Lower byte of speed value
|
||||
0x00, // Upper byte of speed value
|
||||
0x00, // Placeholder for radius
|
||||
0x00, // Placeholder for radius
|
||||
0x00 // Placeholder for checksum
|
||||
};
|
||||
|
||||
message[10] = message[2] ^ message[3] ^ message[4] ^ message[5] ^ message[6] ^
|
||||
message[7] ^ message[8] ^ message[9];
|
||||
|
||||
// Send the message
|
||||
uint32_t pocet;
|
||||
pocet = write(HCom, &message, 11);
|
||||
}
|
@@ -4,7 +4,7 @@
|
||||
int KobukiParser::parseKobukiMessage(TKobukiData &output, unsigned char *data) {
|
||||
int rtrnvalue = checkChecksum(data);
|
||||
if (rtrnvalue != 0) {
|
||||
// std::cerr << "Invalid checksum" << std::endl;
|
||||
std::cerr << "Invalid checksum" << std::endl;
|
||||
return -2;
|
||||
}
|
||||
|
@@ -1,30 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
|
||||
# Project name
|
||||
project(mqtt_receiver)
|
||||
|
||||
# Find the Paho MQTT C++ library
|
||||
find_library(PAHO_MQTTPP_LIBRARY paho-mqttpp3 PATHS /usr/local/lib)
|
||||
find_library(PAHO_MQTT_LIBRARY paho-mqtt3a PATHS /usr/local/lib)
|
||||
|
||||
# Include the headers
|
||||
include_directories(/usr/local/include)
|
||||
|
||||
# Set source files
|
||||
set(SOURCE_FILES
|
||||
main.cpp
|
||||
MqttClient.cpp
|
||||
MqttClient.h
|
||||
)
|
||||
|
||||
# Add the executable
|
||||
add_executable(mqtt_receiver ${SOURCE_FILES})
|
||||
|
||||
# Link the libraries
|
||||
|
||||
# Include directories for headers
|
||||
target_include_directories(mqtt_receiver PRIVATE)
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(mqtt_receiver Threads::Threads)
|
@@ -1,77 +0,0 @@
|
||||
#include "MqttClient.h"
|
||||
|
||||
MqttClient::MqttClient(const std::string& address, const std::string& clientId, const std::string& username, const std::string& password)
|
||||
//client_ is the connection
|
||||
//here all the @PARAMS are getting set for the connection
|
||||
: client_(address, clientId), username_(username), password_(password), callback_(*this) {
|
||||
client_.set_callback(callback_);
|
||||
|
||||
options.set_clean_session(true);
|
||||
options.set_mqtt_version(MQTTVERSION_3_1_1); // For MQTT 3.1.1
|
||||
if (!username_.empty() && !password_.empty()) {
|
||||
options.set_user_name(username_);
|
||||
options.set_password(password_);
|
||||
}
|
||||
}
|
||||
|
||||
void MqttClient::connect() {
|
||||
try {
|
||||
std::cout << "Connecting to broker..." << std::endl;
|
||||
client_.connect(options)->wait();
|
||||
std::cout << "Connected!" << std::endl;
|
||||
} catch (const mqtt::exception& exc) {
|
||||
std::cerr << "Error: " << exc.what() << std::endl;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void MqttClient::subscribe(const std::string& topic, int qos) {
|
||||
try {
|
||||
std::cout << "Subscribing to topic: " << topic << std::endl;
|
||||
client_.subscribe(topic, qos)->wait();
|
||||
} catch (const mqtt::exception& exc) {
|
||||
std::cerr << "Error: " << exc.what() << std::endl;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void MqttClient::publishMessage(const std::string& topic, const std::string& payload) {
|
||||
try {
|
||||
std::cout << "Publishing message: " << payload << std::endl;
|
||||
client_.publish(topic, payload)->wait();
|
||||
} catch (const mqtt::exception& exc) {
|
||||
std::cerr << "Error: " << exc.what() << std::endl;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Only needed when program doesnt keep itself alive
|
||||
void MqttClient::run() {
|
||||
// Keep the client running to receive messages
|
||||
while (true) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1)); // Wait to reduce CPU usage
|
||||
}
|
||||
}
|
||||
|
||||
void MqttClient::Callback::message_arrived(mqtt::const_message_ptr msg) {
|
||||
//lock the variable, it automaticly unlocks when going out of scope using lock_guard
|
||||
std::lock_guard<std::mutex> lock(client_.messageMutex_);
|
||||
client_.lastMessage_ = msg->to_string();
|
||||
}
|
||||
|
||||
void MqttClient::Callback::connection_lost(const std::string& cause) {
|
||||
std::cerr << "Connection lost. Cause: " << cause << std::endl;
|
||||
}
|
||||
|
||||
void MqttClient::Callback::delivery_complete(mqtt::delivery_token_ptr token) {
|
||||
std::cout << "Message delivered!" << std::endl;
|
||||
}
|
||||
|
||||
/// @brief Get the last message received from the MQTT broker
|
||||
/// @return The last message received in a string
|
||||
//std::string is the datatype of the return value
|
||||
std::string MqttClient::getLastMessage() {
|
||||
//lock the variable, it automaticly unlocks when going out of scope using lock_guard
|
||||
std::lock_guard<std::mutex> lock(messageMutex_);
|
||||
return lastMessage_;
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
#ifndef MQTTCLIENT_H
|
||||
#define MQTTCLIENT_H
|
||||
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <mqtt/async_client.h>
|
||||
|
||||
class MqttClient {
|
||||
public:
|
||||
MqttClient(const std::string& address, const std::string& clientId, const std::string& username = "", const std::string& password = "");
|
||||
void connect();
|
||||
void subscribe(const std::string& topic, int qos = 1);
|
||||
void run();
|
||||
std::string getLastMessage();
|
||||
void publishMessage(const std::string& topic, const std::string& payload);
|
||||
|
||||
private:
|
||||
class Callback : public virtual mqtt::callback {
|
||||
public:
|
||||
Callback(MqttClient& client) : client_(client) {}
|
||||
void message_arrived(mqtt::const_message_ptr msg) override;
|
||||
void connection_lost(const std::string& cause) override;
|
||||
void delivery_complete(mqtt::delivery_token_ptr token) override;
|
||||
|
||||
private:
|
||||
MqttClient& client_;
|
||||
};
|
||||
|
||||
mqtt::async_client client_;
|
||||
mqtt::connect_options options;
|
||||
Callback callback_;
|
||||
std::string username_;
|
||||
std::string password_;
|
||||
std::string lastMessage_;
|
||||
std::mutex messageMutex_;
|
||||
};
|
||||
|
||||
#endif //MQTTCLIENT_H
|
@@ -1,10 +0,0 @@
|
||||
#include "MqttClient.h"
|
||||
//example file for testing
|
||||
int main(){
|
||||
MqttClient client("mqtt://localhost:1883", "raspberry_pi_client", "ishak", "kobuki");
|
||||
client.connect();
|
||||
client.subscribe("home/commands");
|
||||
client.run();
|
||||
|
||||
return 0;
|
||||
}
|
71
src/C++/Driver/src/graph.h
Normal file
71
src/C++/Driver/src/graph.h
Normal file
@@ -0,0 +1,71 @@
|
||||
#ifndef GRAPH1010
|
||||
#define GRAPH1010
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
#define GRAPH_ENABLED true
|
||||
|
||||
class plot {
|
||||
public:
|
||||
FILE *gp;
|
||||
bool enabled,persist;
|
||||
plot(bool _persist=false,bool _enabled=GRAPH_ENABLED) {
|
||||
enabled=_enabled;
|
||||
persist=_persist;
|
||||
if (enabled) {
|
||||
if(persist)
|
||||
gp=popen("gnuplot -persist","w");
|
||||
else
|
||||
gp=popen("gnuplot","w");
|
||||
}
|
||||
}
|
||||
|
||||
void plot_data(vector<float> x,const char* style="points",const char* title="Data") {
|
||||
if(!enabled)
|
||||
return;
|
||||
fprintf(gp,"set title '%s' \n",title);
|
||||
fprintf(gp,"plot '-' w %s \n",style);
|
||||
for(int k=0;k<x.size();k++) {
|
||||
fprintf(gp,"%f\n",x[k]);
|
||||
}
|
||||
fprintf(gp,"e\n");
|
||||
fflush(gp);
|
||||
}
|
||||
|
||||
void plot_data(vector<float> x,vector<float> y,const char* style="points",const char* title="Data") {
|
||||
if(!enabled)
|
||||
return;
|
||||
fprintf(gp,"set title '%s' \n",title);
|
||||
fprintf(gp,"plot '-' w %s \n",style);
|
||||
for(int k=0;k<x.size();k++) {
|
||||
fprintf(gp,"%f %f \n",x[k],y[k]);
|
||||
}
|
||||
fprintf(gp,"e\n");
|
||||
fflush(gp);
|
||||
}
|
||||
|
||||
~plot() {
|
||||
if(enabled)
|
||||
pclose(gp);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
int main(int argc,char **argv) {
|
||||
plot p;
|
||||
for(int a=0;a<100;a++) {
|
||||
vector<float> x,y;
|
||||
for(int k=a;k<a+200;k++) {
|
||||
x.push_back(k);
|
||||
y.push_back(k*k);
|
||||
}
|
||||
p.plot_data(x,y);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
#endif
|
@@ -1,92 +1,70 @@
|
||||
#include "CKobuki.h"
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include <thread>
|
||||
#include "MQTT/MqttClient.h"
|
||||
#include "KobukiDriver/CKobuki.h"
|
||||
#include <opencv4/opencv2/opencv.hpp>
|
||||
#include <opencv4/opencv2/core.hpp>
|
||||
#include "graph.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
CKobuki robot;
|
||||
std::string readMQTT();
|
||||
void parseMQTT(std::string message);
|
||||
void CapnSend();
|
||||
//ip, clientID, username, password
|
||||
MqttClient client("ws://145.92.224.21/ws/", "KobukiRPI", "rpi", "rpiwachtwoordofzo"); // create a client object
|
||||
std::string message = "stop";
|
||||
std::string serializeKobukiData(const TKobukiData &data);
|
||||
void sendKobukiData(TKobukiData &data);
|
||||
|
||||
void setup()
|
||||
{
|
||||
unsigned char *null_ptr(0);
|
||||
robot.startCommunication("/dev/ttyUSB0", true, null_ptr);
|
||||
//connect mqtt server and sub to commands
|
||||
|
||||
client.connect();
|
||||
client.subscribe("home/commands");
|
||||
}
|
||||
int movement();
|
||||
int checkCenterCliff();
|
||||
void logToFile();
|
||||
|
||||
int main()
|
||||
{
|
||||
setup();
|
||||
std::thread image (CapnSend);
|
||||
std::thread safety([&]() { robot.robotSafety(&message); });
|
||||
std::thread sendMqtt([&]() { sendKobukiData(robot.parser.data); });
|
||||
unsigned char *null_ptr(0);
|
||||
robot.startCommunication("/dev/ttyUSB0", true, null_ptr);
|
||||
|
||||
while(true){
|
||||
parseMQTT(readMQTT());
|
||||
}
|
||||
std::thread safety([&robot]()
|
||||
{ robot.robotSafety(); }); // use a lambda function to call the member function
|
||||
safety.detach();
|
||||
|
||||
sendMqtt.join();
|
||||
safety.join();
|
||||
image.join();
|
||||
thread movementThread(movement);
|
||||
movementThread.join(); // so the program doesnt quit
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string readMQTT()
|
||||
int checkCenterCliff()
|
||||
{
|
||||
message = client.getLastMessage();
|
||||
if (!message.empty())
|
||||
while (true)
|
||||
{
|
||||
std::cout << "MQTT Message: " << message << std::endl;
|
||||
std::cout << robot.parser.data.CliffSensorRight << endl;
|
||||
}
|
||||
|
||||
// Add a small delay to avoid busy-waiting
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
return message;
|
||||
}
|
||||
|
||||
void parseMQTT(std::string message)
|
||||
int movement()
|
||||
{
|
||||
if (message == "up")
|
||||
int text;
|
||||
while (true)
|
||||
{
|
||||
robot.forward(350);
|
||||
}
|
||||
else if (message == "left")
|
||||
{
|
||||
robot.setRotationSpeed(4);
|
||||
}
|
||||
else if (message == "right")
|
||||
{
|
||||
robot.setRotationSpeed(-4);
|
||||
}
|
||||
else if (message == "down")
|
||||
{
|
||||
robot.forward(-350);
|
||||
}
|
||||
else if (message == "stop")
|
||||
{
|
||||
robot.sendNullMessage();
|
||||
robot.sendNullMessage();
|
||||
}
|
||||
else if (message == "estop")
|
||||
{
|
||||
robot.forward(-400);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Invalid command" << std::endl;
|
||||
cout << "gimme input: ";
|
||||
cin >> text;
|
||||
|
||||
if (text == 1)
|
||||
{
|
||||
robot.forward(400);
|
||||
}
|
||||
else if (text == 2)
|
||||
{
|
||||
// 1 is full circle
|
||||
robot.Rotate(90);
|
||||
}
|
||||
else if (text == 3)
|
||||
{
|
||||
// Add your code here for text == 3
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
robot.doRotation(text);
|
||||
throw "NaN";
|
||||
}
|
||||
catch (const char *msg)
|
||||
{
|
||||
cerr << msg << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,155 +134,3 @@ void logToFile()
|
||||
std::this_thread::sleep_for(std::chrono::seconds(2)); // Sleep for 2 seconds
|
||||
}
|
||||
}
|
||||
|
||||
void sendIndividualKobukiData(const TKobukiData &data) {
|
||||
while (true) {
|
||||
client.publishMessage("kobuki/data/timestamp", std::to_string(data.timestamp));
|
||||
client.publishMessage("kobuki/data/BumperCenter", std::to_string(data.BumperCenter));
|
||||
client.publishMessage("kobuki/data/BumperLeft", std::to_string(data.BumperLeft));
|
||||
client.publishMessage("kobuki/data/BumperRight", std::to_string(data.BumperRight));
|
||||
client.publishMessage("kobuki/data/WheelDropLeft", std::to_string(data.WheelDropLeft));
|
||||
client.publishMessage("kobuki/data/WheelDropRight", std::to_string(data.WheelDropRight));
|
||||
client.publishMessage("kobuki/data/CliffCenter", std::to_string(data.CliffCenter));
|
||||
client.publishMessage("kobuki/data/CliffLeft", std::to_string(data.CliffLeft));
|
||||
client.publishMessage("kobuki/data/CliffRight", std::to_string(data.CliffRight));
|
||||
client.publishMessage("kobuki/data/EncoderLeft", std::to_string(data.EncoderLeft));
|
||||
client.publishMessage("kobuki/data/EncoderRight", std::to_string(data.EncoderRight));
|
||||
client.publishMessage("kobuki/data/PWMleft", std::to_string(data.PWMleft));
|
||||
client.publishMessage("kobuki/data/PWMright", std::to_string(data.PWMright));
|
||||
client.publishMessage("kobuki/data/ButtonPress1", std::to_string(data.ButtonPress1));
|
||||
client.publishMessage("kobuki/data/ButtonPress2", std::to_string(data.ButtonPress2));
|
||||
client.publishMessage("kobuki/data/ButtonPress3", std::to_string(data.ButtonPress3));
|
||||
client.publishMessage("kobuki/data/Charger", std::to_string(data.Charger));
|
||||
client.publishMessage("kobuki/data/Battery", std::to_string(data.Battery));
|
||||
client.publishMessage("kobuki/data/overCurrent", std::to_string(data.overCurrent));
|
||||
client.publishMessage("kobuki/data/IRSensorRight", std::to_string(data.IRSensorRight));
|
||||
client.publishMessage("kobuki/data/IRSensorCenter", std::to_string(data.IRSensorCenter));
|
||||
client.publishMessage("kobuki/data/IRSensorLeft", std::to_string(data.IRSensorLeft));
|
||||
client.publishMessage("kobuki/data/GyroAngle", std::to_string(data.GyroAngle));
|
||||
client.publishMessage("kobuki/data/GyroAngleRate", std::to_string(data.GyroAngleRate));
|
||||
client.publishMessage("kobuki/data/CliffSensorRight", std::to_string(data.CliffSensorRight));
|
||||
client.publishMessage("kobuki/data/CliffSensorCenter", std::to_string(data.CliffSensorCenter));
|
||||
client.publishMessage("kobuki/data/CliffSensorLeft", std::to_string(data.CliffSensorLeft));
|
||||
client.publishMessage("kobuki/data/wheelCurrentLeft", std::to_string(data.wheelCurrentLeft));
|
||||
client.publishMessage("kobuki/data/wheelCurrentRight", std::to_string(data.wheelCurrentRight));
|
||||
client.publishMessage("kobuki/data/digitalInput", std::to_string(data.digitalInput));
|
||||
client.publishMessage("kobuki/data/analogInputCh0", std::to_string(data.analogInputCh0));
|
||||
client.publishMessage("kobuki/data/analogInputCh1", std::to_string(data.analogInputCh1));
|
||||
client.publishMessage("kobuki/data/analogInputCh2", std::to_string(data.analogInputCh2));
|
||||
client.publishMessage("kobuki/data/analogInputCh3", std::to_string(data.analogInputCh3));
|
||||
client.publishMessage("kobuki/data/frameId", std::to_string(data.frameId));
|
||||
client.publishMessage("kobuki/data/extraInfo/HardwareVersionPatch", std::to_string(data.extraInfo.HardwareVersionPatch));
|
||||
client.publishMessage("kobuki/data/extraInfo/HardwareVersionMinor", std::to_string(data.extraInfo.HardwareVersionMinor));
|
||||
client.publishMessage("kobuki/data/extraInfo/HardwareVersionMajor", std::to_string(data.extraInfo.HardwareVersionMajor));
|
||||
client.publishMessage("kobuki/data/extraInfo/FirmwareVersionPatch", std::to_string(data.extraInfo.FirmwareVersionPatch));
|
||||
client.publishMessage("kobuki/data/extraInfo/FirmwareVersionMinor", std::to_string(data.extraInfo.FirmwareVersionMinor));
|
||||
client.publishMessage("kobuki/data/extraInfo/FirmwareVersionMajor", std::to_string(data.extraInfo.FirmwareVersionMajor));
|
||||
client.publishMessage("kobuki/data/extraInfo/UDID0", std::to_string(data.extraInfo.UDID0));
|
||||
client.publishMessage("kobuki/data/extraInfo/UDID1", std::to_string(data.extraInfo.UDID1));
|
||||
client.publishMessage("kobuki/data/extraInfo/UDID2", std::to_string(data.extraInfo.UDID2));
|
||||
|
||||
if (!data.gyroData.empty()) {
|
||||
const auto& latestGyro = data.gyroData.back();
|
||||
client.publishMessage("kobuki/data/gyroData/x", std::to_string(latestGyro.x));
|
||||
client.publishMessage("kobuki/data/gyroData/y", std::to_string(latestGyro.y));
|
||||
client.publishMessage("kobuki/data/gyroData/z", std::to_string(latestGyro.z));
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
||||
}
|
||||
}
|
||||
|
||||
std::string serializeKobukiData(const TKobukiData &data) {
|
||||
std::string json = "{\"timestamp\":" + std::to_string(data.timestamp) +
|
||||
",\"BumperCenter\":" + std::to_string(data.BumperCenter) +
|
||||
",\"BumperLeft\":" + std::to_string(data.BumperLeft) +
|
||||
",\"BumperRight\":" + std::to_string(data.BumperRight) +
|
||||
",\"WheelDropLeft\":" + std::to_string(data.WheelDropLeft) +
|
||||
",\"WheelDropRight\":" + std::to_string(data.WheelDropRight) +
|
||||
",\"CliffCenter\":" + std::to_string(data.CliffCenter) +
|
||||
",\"CliffLeft\":" + std::to_string(data.CliffLeft) +
|
||||
",\"CliffRight\":" + std::to_string(data.CliffRight) +
|
||||
",\"EncoderLeft\":" + std::to_string(data.EncoderLeft) +
|
||||
",\"EncoderRight\":" + std::to_string(data.EncoderRight) +
|
||||
",\"PWMleft\":" + std::to_string(data.PWMleft) +
|
||||
",\"PWMright\":" + std::to_string(data.PWMright) +
|
||||
",\"ButtonPress1\":" + std::to_string(data.ButtonPress1) +
|
||||
",\"ButtonPress2\":" + std::to_string(data.ButtonPress2) +
|
||||
",\"ButtonPress3\":" + std::to_string(data.ButtonPress3) +
|
||||
",\"Charger\":" + std::to_string(data.Charger) +
|
||||
",\"Battery\":" + std::to_string(data.Battery) +
|
||||
",\"overCurrent\":" + std::to_string(data.overCurrent) +
|
||||
",\"IRSensorRight\":" + std::to_string(data.IRSensorRight) +
|
||||
",\"IRSensorCenter\":" + std::to_string(data.IRSensorCenter) +
|
||||
",\"IRSensorLeft\":" + std::to_string(data.IRSensorLeft) +
|
||||
",\"GyroAngle\":" + std::to_string(data.GyroAngle) +
|
||||
",\"GyroAngleRate\":" + std::to_string(data.GyroAngleRate) +
|
||||
",\"CliffSensorRight\":" + std::to_string(data.CliffSensorRight) +
|
||||
",\"CliffSensorCenter\":" + std::to_string(data.CliffSensorCenter) +
|
||||
",\"CliffSensorLeft\":" + std::to_string(data.CliffSensorLeft) +
|
||||
",\"wheelCurrentLeft\":" + std::to_string(data.wheelCurrentLeft) +
|
||||
",\"wheelCurrentRight\":" + std::to_string(data.wheelCurrentRight) +
|
||||
",\"digitalInput\":" + std::to_string(data.digitalInput) +
|
||||
",\"analogInputCh0\":" + std::to_string(data.analogInputCh0) +
|
||||
",\"analogInputCh1\":" + std::to_string(data.analogInputCh1) +
|
||||
",\"analogInputCh2\":" + std::to_string(data.analogInputCh2) +
|
||||
",\"analogInputCh3\":" + std::to_string(data.analogInputCh3) +
|
||||
",\"frameId\":" + std::to_string(data.frameId) +
|
||||
",\"extraInfo\":{\"HardwareVersionPatch\":" + std::to_string(data.extraInfo.HardwareVersionPatch) +
|
||||
",\"HardwareVersionMinor\":" + std::to_string(data.extraInfo.HardwareVersionMinor) +
|
||||
",\"HardwareVersionMajor\":" + std::to_string(data.extraInfo.HardwareVersionMajor) +
|
||||
",\"FirmwareVersionPatch\":" + std::to_string(data.extraInfo.FirmwareVersionPatch) +
|
||||
",\"FirmwareVersionMinor\":" + std::to_string(data.extraInfo.FirmwareVersionMinor) +
|
||||
",\"FirmwareVersionMajor\":" + std::to_string(data.extraInfo.FirmwareVersionMajor) +
|
||||
",\"UDID0\":" + std::to_string(data.extraInfo.UDID0) +
|
||||
",\"UDID1\":" + std::to_string(data.extraInfo.UDID1) +
|
||||
",\"UDID2\":" + std::to_string(data.extraInfo.UDID2) + "},\"gyroData\":[";
|
||||
|
||||
if (!data.gyroData.empty()) {
|
||||
const auto& latestGyro = data.gyroData.back();
|
||||
json += "{\"x\":" + std::to_string(latestGyro.x) +
|
||||
",\"y\":" + std::to_string(latestGyro.y) +
|
||||
",\"z\":" + std::to_string(latestGyro.z) + "}";
|
||||
}
|
||||
|
||||
json += "]}";
|
||||
return json;
|
||||
}
|
||||
//create extra function to send the message every 100ms
|
||||
//needed it so it can be threaded
|
||||
void sendKobukiData(TKobukiData &data) {
|
||||
while (true) {
|
||||
client.publishMessage("kobuki/data", serializeKobukiData(data));
|
||||
std::cout << "Sent data" << std::endl;
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
||||
}
|
||||
}
|
||||
|
||||
void CapnSend() {
|
||||
VideoCapture cap(0);
|
||||
if (!cap.isOpened()) {
|
||||
cerr << "Error: Could not open camera" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
Mat frame;
|
||||
while (true) {
|
||||
cap >> frame; // Capture a new image frame
|
||||
if (frame.empty()) {
|
||||
cerr << "Error: Could not capture image" << endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Convert the image to a byte array
|
||||
vector<uchar> buf;
|
||||
imencode(".jpg", frame, buf);
|
||||
auto* enc_msg = reinterpret_cast<unsigned char*>(buf.data());
|
||||
|
||||
// Publish the image data
|
||||
client.publishMessage("kobuki/cam", string(enc_msg, enc_msg + buf.size()));
|
||||
cout << "Sent image" << endl;
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(300)); // Send image every 1000ms
|
||||
}
|
||||
}
|
@@ -1,61 +1,67 @@
|
||||
#include "CKobuki.h"
|
||||
#include "graph.h"
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include <thread>
|
||||
#include "graph.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// Globale instantie van de CKobuki-klasse
|
||||
CKobuki robot;
|
||||
|
||||
// Functieprototypes
|
||||
int command();
|
||||
int checkCenterCliff();
|
||||
int checkWheelDrop();
|
||||
|
||||
int main() {
|
||||
// Start communicatie met de robot
|
||||
unsigned char *null_ptr(0);
|
||||
robot.startCommunication("/dev/ttyUSB0", true, null_ptr);
|
||||
usleep(1 * 1000 * 1000);
|
||||
const int forward = 1;
|
||||
const int ROTATE = 2;
|
||||
|
||||
// Start een nieuwe thread voor de command-functie
|
||||
thread mv(command);
|
||||
usleep(30 * 1000 * 1000);
|
||||
mv.join(); // Wacht tot de command-thread klaar is
|
||||
int main()
|
||||
{
|
||||
unsigned char *null_ptr(0);
|
||||
robot.startCommunication("/dev/ttyUSB0", true, null_ptr);
|
||||
usleep(1 * 1000 * 1000);
|
||||
thread mv(command);
|
||||
usleep(30 * 1000 * 1000);
|
||||
mv.join(); //only exit once thread one is done running
|
||||
}
|
||||
|
||||
// int checkCenterCliff()
|
||||
// {
|
||||
// while (true)
|
||||
// {
|
||||
// std::cout << "cliffsensordata:" << robot.parser.data.CliffSensorCenter << std::endl;
|
||||
// }
|
||||
// }
|
||||
|
||||
// int checkWheelDrop(){
|
||||
// while (true)
|
||||
// {
|
||||
// std::cout << "wheeldropdata:" << robot.parser.data.WheelDropLeft << std::endl;
|
||||
// }
|
||||
// }
|
||||
|
||||
int command(){
|
||||
cout << "choose between forward and rotate" << endl;
|
||||
cout << "What must the robot do?";
|
||||
cin >> input;
|
||||
|
||||
switch(input){
|
||||
case forward:{
|
||||
int distance;
|
||||
std::cout >> "Enter distance to move forward: ";
|
||||
std::cin >> distance;
|
||||
robot.goStraight(distance);
|
||||
}
|
||||
|
||||
case ROTATE:{
|
||||
int angle;
|
||||
std::cout >> "Enter angle to rotate: ";
|
||||
std::cin >> angle;
|
||||
robot.doRotation(angle);
|
||||
}
|
||||
robot.goStraight(-1);
|
||||
break;
|
||||
|
||||
default:
|
||||
cout << "Invalid input" << endl;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Functie om commando's van de gebruiker te verwerken
|
||||
int command() {
|
||||
int input;
|
||||
|
||||
while (true) {
|
||||
// Vraag de gebruiker om een commando
|
||||
std::cout << "choose between forward = 1 or rotate = 2" << endl;
|
||||
std::cout << "What must the robot do?";
|
||||
std::cin >> input;
|
||||
|
||||
// Verwerk de invoer van de gebruiker
|
||||
switch (input) {
|
||||
case 1: {
|
||||
int distance;
|
||||
std::cout << "Enter distance to move forward: ";
|
||||
std::cin >> distance;
|
||||
robot.goStraight(distance); // Beweeg de robot naar voren
|
||||
} break;
|
||||
|
||||
case 2: {
|
||||
int angle;
|
||||
std::cout << "Enter angle to rotate in degrees: ";
|
||||
std::cin >> angle;
|
||||
robot.doRotation(angle); // Draai de robot
|
||||
} break;
|
||||
|
||||
default:
|
||||
cout << "Invalid input" << endl; // Ongeldige invoer
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,44 +0,0 @@
|
||||
cmake_minimum_required( VERSION 3.6 )
|
||||
|
||||
# Require C++11 (or later)
|
||||
set( CMAKE_CXX_STANDARD 23 )
|
||||
set( CMAKE_CXX_STANDARD_REQUIRED ON )
|
||||
set( CMAKE_CXX_EXTENSIONS OFF )
|
||||
set(BUILD_MODE Debug)
|
||||
# Create Project
|
||||
project( Sample )
|
||||
add_executable( YOLOv4 util.h main.cpp )
|
||||
|
||||
# Set StartUp Project
|
||||
set_property( DIRECTORY PROPERTY VS_STARTUP_PROJECT "YOLOv4" )
|
||||
|
||||
# Find Package
|
||||
# OpenCV
|
||||
find_package( OpenCV REQUIRED )
|
||||
|
||||
if( OpenCV_FOUND )
|
||||
# Additional Include Directories
|
||||
include_directories( ${OpenCV_INCLUDE_DIRS} )
|
||||
|
||||
# Additional Dependencies
|
||||
target_link_libraries( YOLOv4 ${OpenCV_LIBS} )
|
||||
endif()
|
||||
|
||||
# Download Model
|
||||
set( MODEL https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v3_optimal/yolov4.weights )
|
||||
file( DOWNLOAD
|
||||
"${MODEL}"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/yolov4.weights"
|
||||
EXPECTED_HASH SHA256=e8a4f6c62188738d86dc6898d82724ec0964d0eb9d2ae0f0a9d53d65d108d562
|
||||
SHOW_PROGRESS
|
||||
)
|
||||
|
||||
|
||||
# Download Config
|
||||
set( CONFIG https://raw.githubusercontent.com/AlexeyAB/darknet/master/cfg/yolov4.cfg )
|
||||
file( DOWNLOAD
|
||||
"${CONFIG}"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/yolov4.cfg"
|
||||
EXPECTED_HASH SHA256=a6d0f8e5c62cc8378384f75a8159b95fa2964d4162e33351b00ac82e0fc46a34
|
||||
SHOW_PROGRESS
|
||||
)
|
Binary file not shown.
@@ -1,80 +0,0 @@
|
||||
person
|
||||
bicycle
|
||||
car
|
||||
motorbike
|
||||
aeroplane
|
||||
bus
|
||||
train
|
||||
truck
|
||||
boat
|
||||
traffic light
|
||||
fire hydrant
|
||||
stop sign
|
||||
parking meter
|
||||
bench
|
||||
bird
|
||||
cat
|
||||
dog
|
||||
horse
|
||||
sheep
|
||||
cow
|
||||
elephant
|
||||
bear
|
||||
zebra
|
||||
giraffe
|
||||
backpack
|
||||
umbrella
|
||||
handbag
|
||||
tie
|
||||
suitcase
|
||||
frisbee
|
||||
skis
|
||||
snowboard
|
||||
sports ball
|
||||
kite
|
||||
baseball bat
|
||||
baseball glove
|
||||
skateboard
|
||||
surfboard
|
||||
tennis racket
|
||||
bottle
|
||||
wine glass
|
||||
cup
|
||||
fork
|
||||
knife
|
||||
spoon
|
||||
bowl
|
||||
banana
|
||||
apple
|
||||
sandwich
|
||||
orange
|
||||
broccoli
|
||||
carrot
|
||||
hot dog
|
||||
pizza
|
||||
donut
|
||||
cake
|
||||
chair
|
||||
sofa
|
||||
pottedplant
|
||||
bed
|
||||
diningtable
|
||||
toilet
|
||||
tvmonitor
|
||||
laptop
|
||||
mouse
|
||||
remote
|
||||
keyboard
|
||||
cell phone
|
||||
microwave
|
||||
oven
|
||||
toaster
|
||||
sink
|
||||
refrigerator
|
||||
book
|
||||
clock
|
||||
vase
|
||||
scissors
|
||||
teddy bear
|
||||
hair drier
|
||||
toothbrush
|
@@ -1,209 +0,0 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <opencv2/dnn.hpp>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
// Helper function to check if a file exists
|
||||
bool fileExists(const std::string &path)
|
||||
{
|
||||
return std::filesystem::exists(path);
|
||||
}
|
||||
|
||||
// Function to read class names from a file
|
||||
std::vector<std::string> _readClassNameList(const std::string &path)
|
||||
{
|
||||
std::vector<std::string> classes;
|
||||
|
||||
// Check if file exists
|
||||
if (!fileExists(path))
|
||||
{
|
||||
throw std::runtime_error("Class names file not found: " + path);
|
||||
}
|
||||
|
||||
// Try to open and read file
|
||||
std::ifstream file(path);
|
||||
if (!file.is_open())
|
||||
{
|
||||
throw std::runtime_error("Unable to open class names file: " + path);
|
||||
}
|
||||
|
||||
std::string line;
|
||||
while (std::getline(file, line))
|
||||
{
|
||||
if (!line.empty())
|
||||
{
|
||||
classes.push_back(line);
|
||||
}
|
||||
}
|
||||
|
||||
if (classes.empty())
|
||||
{
|
||||
throw std::runtime_error("No classes found in file: " + path);
|
||||
}
|
||||
|
||||
return classes;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
try
|
||||
{
|
||||
// Open Video Capture
|
||||
cv::VideoCapture capture = cv::VideoCapture(0);
|
||||
if (!capture.isOpened())
|
||||
{
|
||||
std::cerr << "Failed to open camera device" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Read Class Name List and Color Table
|
||||
const std::string list = "coco.names";
|
||||
const std::vector<std::string> classes = _readClassNameList(list);
|
||||
const std::vector<cv::Scalar> colors = getClassColors(classes.size());
|
||||
|
||||
// Debug: Print the size of the colors vector
|
||||
std::cout << "Number of colors: " << colors.size() << std::endl;
|
||||
|
||||
// Read Darknet
|
||||
const std::string model = "yolov4.weights";
|
||||
const std::string config = "yolov4.cfg";
|
||||
cv::dnn::Net net = cv::dnn::readNet(model, config);
|
||||
if (net.empty())
|
||||
{
|
||||
std::cerr << "Failed to load network" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Set Preferable Backend
|
||||
net.setPreferableBackend(cv::dnn::DNN_BACKEND_OPENCV);
|
||||
|
||||
// Set Preferable Target
|
||||
net.setPreferableTarget(cv::dnn::DNN_TARGET_OPENCL);
|
||||
|
||||
while (true)
|
||||
{
|
||||
// Read Frame
|
||||
cv::Mat frame;
|
||||
capture >> frame;
|
||||
if (frame.empty())
|
||||
{
|
||||
cv::waitKey(0);
|
||||
break;
|
||||
}
|
||||
if (frame.channels() == 4)
|
||||
{
|
||||
cv::cvtColor(frame, frame, cv::COLOR_BGRA2BGR);
|
||||
}
|
||||
|
||||
// Create Blob from Input Image
|
||||
cv::Mat blob = cv::dnn::blobFromImage(frame, 1 / 255.f, cv::Size(416, 416), cv::Scalar(), true, false);
|
||||
|
||||
// Set Input Blob
|
||||
net.setInput(blob);
|
||||
|
||||
// Run Forward Network
|
||||
std::vector<cv::Mat> detections;
|
||||
net.forward(detections, getOutputsNames(net));
|
||||
|
||||
// Draw Region
|
||||
std::vector<int32_t> class_ids;
|
||||
std::vector<float> confidences;
|
||||
std::vector<cv::Rect> rectangles;
|
||||
for (cv::Mat &detection : detections)
|
||||
{
|
||||
if (detection.empty())
|
||||
{
|
||||
std::cerr << "Detection matrix is empty!" << std::endl;
|
||||
continue;
|
||||
}
|
||||
for (int32_t i = 0; i < detection.rows; i++)
|
||||
{
|
||||
cv::Mat region = detection.row(i);
|
||||
|
||||
// Retrieve Max Confidence and Class Index
|
||||
cv::Mat scores = region.colRange(5, detection.cols);
|
||||
cv::Point class_id;
|
||||
double confidence;
|
||||
cv::minMaxLoc(scores, 0, &confidence, 0, &class_id);
|
||||
|
||||
// Check Confidence
|
||||
constexpr float threshold = 0.2;
|
||||
if (threshold > confidence)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Retrieve Object Position
|
||||
const int32_t x_center = static_cast<int32_t>(region.at<float>(0) * frame.cols);
|
||||
const int32_t y_center = static_cast<int32_t>(region.at<float>(1) * frame.rows);
|
||||
const int32_t width = static_cast<int32_t>(region.at<float>(2) * frame.cols);
|
||||
const int32_t height = static_cast<int32_t>(region.at<float>(3) * frame.rows);
|
||||
const cv::Rect rectangle = cv::Rect(x_center - (width / 2), y_center - (height / 2), width, height);
|
||||
|
||||
// Add Class ID, Confidence, Rectangle
|
||||
class_ids.push_back(class_id.x);
|
||||
confidences.push_back(confidence);
|
||||
rectangles.push_back(rectangle);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove Overlap Rectangles using Non-Maximum Suppression
|
||||
constexpr float confidence_threshold = 0.5; // Confidence
|
||||
constexpr float nms_threshold = 0.5; // IoU (Intersection over Union)
|
||||
std::vector<int32_t> indices;
|
||||
cv::dnn::NMSBoxes(rectangles, confidences, confidence_threshold, nms_threshold, indices);
|
||||
|
||||
// Draw Rectangle
|
||||
for (const int32_t &index : indices)
|
||||
{
|
||||
// Bounds checking
|
||||
if (class_ids[index] >= colors.size())
|
||||
{
|
||||
std::cerr << "Color index out of bounds: " << class_ids[index] << " (max: " << colors.size() - 1 << ")" << std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
const cv::Rect rectangle = rectangles[index];
|
||||
const cv::Scalar color = colors[class_ids[index]];
|
||||
|
||||
// Debug: Print the index and color
|
||||
std::cout << "Drawing rectangle with color index: " << class_ids[index] << std::endl;
|
||||
|
||||
constexpr int32_t thickness = 3;
|
||||
cv::rectangle(frame, rectangle, color, thickness);
|
||||
|
||||
std::string label = classes[class_ids[index]] + ": " + std::to_string(static_cast<int>(confidences[index] * 100)) + "%";
|
||||
|
||||
int baseLine;
|
||||
cv::Size labelSize = cv::getTextSize(label, cv::FONT_HERSHEY_SIMPLEX, 0.5, 1, &baseLine);
|
||||
int top = std::max(rectangle.y, labelSize.height);
|
||||
cv::rectangle(frame, cv::Point(rectangle.x, top - labelSize.height),
|
||||
cv::Point(rectangle.x + labelSize.width, top + baseLine), color, cv::FILLED);
|
||||
cv::putText(frame, label, cv::Point(rectangle.x, top), cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(255, 255, 255), 1);
|
||||
}
|
||||
|
||||
// Show Image
|
||||
cv::imshow("Object Detection", frame);
|
||||
const int32_t key = cv::waitKey(1);
|
||||
if (key == 'q')
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cv::destroyAllWindows();
|
||||
return 0;
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// cloned and fixed from https://github.com/UnaNancyOwen/OpenCVDNNSample/tree/master
|
@@ -1,61 +0,0 @@
|
||||
#ifndef __UTIL__
|
||||
#define __UTIL__
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <opencv2/dnn.hpp>
|
||||
#include <opencv2/core.hpp>
|
||||
#include <opencv2/highgui.hpp>
|
||||
|
||||
// Get Output Layers Name
|
||||
std::vector<std::string> getOutputsNames( const cv::dnn::Net& net )
|
||||
{
|
||||
static std::vector<std::string> names;
|
||||
if( names.empty() ){
|
||||
std::vector<int32_t> out_layers = net.getUnconnectedOutLayers();
|
||||
std::vector<std::string> layers_names = net.getLayerNames();
|
||||
names.resize( out_layers.size() );
|
||||
for( size_t i = 0; i < out_layers.size(); ++i ){
|
||||
names[i] = layers_names[out_layers[i] - 1];
|
||||
}
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
// Get Output Layer Type
|
||||
std::string getOutputLayerType( cv::dnn::Net& net )
|
||||
{
|
||||
const std::vector<int32_t> out_layers = net.getUnconnectedOutLayers();
|
||||
const std::string output_layer_type = net.getLayer( out_layers[0] )->type;
|
||||
return output_layer_type;
|
||||
}
|
||||
|
||||
// Read Class Name List
|
||||
std::vector<std::string> readClassNameList( const std::string list_path )
|
||||
{
|
||||
std::vector<std::string> classes;
|
||||
std::ifstream ifs( list_path );
|
||||
if( !ifs.is_open() ){
|
||||
return classes;
|
||||
}
|
||||
std::string class_name = "";
|
||||
while( std::getline( ifs, class_name ) ){
|
||||
classes.push_back( class_name );
|
||||
}
|
||||
return classes;
|
||||
}
|
||||
|
||||
// Get Class Color Table for Visualize
|
||||
std::vector<cv::Scalar> getClassColors( const int32_t number_of_colors )
|
||||
{
|
||||
cv::RNG random;
|
||||
std::vector<cv::Scalar> colors;
|
||||
for( int32_t i = 0; i < number_of_colors; i++ ){
|
||||
cv::Scalar color( random.uniform( 0, 255 ), random.uniform( 0, 255 ), random.uniform( 0, 255 ) );
|
||||
colors.push_back( color );
|
||||
}
|
||||
return colors;
|
||||
}
|
||||
|
||||
#endif // __UTIL__
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -1,503 +0,0 @@
|
||||
/*
|
||||
TinyGPS++ - a small GPS library for Arduino providing universal NMEA parsing
|
||||
Based on work by and "distanceBetween" and "courseTo" courtesy of Maarten Lamers.
|
||||
Suggestion to add satellites, courseTo(), and cardinal() by Matt Monson.
|
||||
Location precision improvements suggested by Wayne Holder.
|
||||
Copyright (C) 2008-2013 Mikal Hart
|
||||
All rights reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "TinyGPS++.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define _GPRMCterm "GPRMC"
|
||||
#define _GPGGAterm "GPGGA"
|
||||
#define _GNRMCterm "GNRMC"
|
||||
#define _GNGGAterm "GNGGA"
|
||||
|
||||
TinyGPSPlus::TinyGPSPlus()
|
||||
: parity(0)
|
||||
, isChecksumTerm(false)
|
||||
, curSentenceType(GPS_SENTENCE_OTHER)
|
||||
, curTermNumber(0)
|
||||
, curTermOffset(0)
|
||||
, sentenceHasFix(false)
|
||||
, customElts(0)
|
||||
, customCandidates(0)
|
||||
, encodedCharCount(0)
|
||||
, sentencesWithFixCount(0)
|
||||
, failedChecksumCount(0)
|
||||
, passedChecksumCount(0)
|
||||
{
|
||||
term[0] = '\0';
|
||||
}
|
||||
|
||||
//
|
||||
// public methods
|
||||
//
|
||||
|
||||
bool TinyGPSPlus::encode(char c)
|
||||
{
|
||||
++encodedCharCount;
|
||||
|
||||
switch(c)
|
||||
{
|
||||
case ',': // term terminators
|
||||
parity ^= (uint8_t)c;
|
||||
case '\r':
|
||||
case '\n':
|
||||
case '*':
|
||||
{
|
||||
bool isValidSentence = false;
|
||||
if (curTermOffset < sizeof(term))
|
||||
{
|
||||
term[curTermOffset] = 0;
|
||||
isValidSentence = endOfTermHandler();
|
||||
}
|
||||
++curTermNumber;
|
||||
curTermOffset = 0;
|
||||
isChecksumTerm = c == '*';
|
||||
return isValidSentence;
|
||||
}
|
||||
break;
|
||||
|
||||
case '$': // sentence begin
|
||||
curTermNumber = curTermOffset = 0;
|
||||
parity = 0;
|
||||
curSentenceType = GPS_SENTENCE_OTHER;
|
||||
isChecksumTerm = false;
|
||||
sentenceHasFix = false;
|
||||
return false;
|
||||
|
||||
default: // ordinary characters
|
||||
if (curTermOffset < sizeof(term) - 1)
|
||||
term[curTermOffset++] = c;
|
||||
if (!isChecksumTerm)
|
||||
parity ^= c;
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// internal utilities
|
||||
//
|
||||
int TinyGPSPlus::fromHex(char a)
|
||||
{
|
||||
if (a >= 'A' && a <= 'F')
|
||||
return a - 'A' + 10;
|
||||
else if (a >= 'a' && a <= 'f')
|
||||
return a - 'a' + 10;
|
||||
else
|
||||
return a - '0';
|
||||
}
|
||||
|
||||
// static
|
||||
// Parse a (potentially negative) number with up to 2 decimal digits -xxxx.yy
|
||||
int32_t TinyGPSPlus::parseDecimal(const char *term)
|
||||
{
|
||||
bool negative = *term == '-';
|
||||
if (negative) ++term;
|
||||
int32_t ret = 100 * (int32_t)atol(term);
|
||||
while (isdigit(*term)) ++term;
|
||||
if (*term == '.' && isdigit(term[1]))
|
||||
{
|
||||
ret += 10 * (term[1] - '0');
|
||||
if (isdigit(term[2]))
|
||||
ret += term[2] - '0';
|
||||
}
|
||||
return negative ? -ret : ret;
|
||||
}
|
||||
|
||||
// static
|
||||
// Parse degrees in that funny NMEA format DDMM.MMMM
|
||||
void TinyGPSPlus::parseDegrees(const char *term, RawDegrees °)
|
||||
{
|
||||
uint32_t leftOfDecimal = (uint32_t)atol(term);
|
||||
uint16_t minutes = (uint16_t)(leftOfDecimal % 100);
|
||||
uint32_t multiplier = 10000000UL;
|
||||
uint32_t tenMillionthsOfMinutes = minutes * multiplier;
|
||||
|
||||
deg.deg = (int16_t)(leftOfDecimal / 100);
|
||||
|
||||
while (isdigit(*term))
|
||||
++term;
|
||||
|
||||
if (*term == '.')
|
||||
while (isdigit(*++term))
|
||||
{
|
||||
multiplier /= 10;
|
||||
tenMillionthsOfMinutes += (*term - '0') * multiplier;
|
||||
}
|
||||
|
||||
deg.billionths = (5 * tenMillionthsOfMinutes + 1) / 3;
|
||||
deg.negative = false;
|
||||
}
|
||||
|
||||
#define COMBINE(sentence_type, term_number) (((unsigned)(sentence_type) << 5) | term_number)
|
||||
|
||||
// Processes a just-completed term
|
||||
// Returns true if new sentence has just passed checksum test and is validated
|
||||
bool TinyGPSPlus::endOfTermHandler()
|
||||
{
|
||||
// If it's the checksum term, and the checksum checks out, commit
|
||||
if (isChecksumTerm)
|
||||
{
|
||||
byte checksum = 16 * fromHex(term[0]) + fromHex(term[1]);
|
||||
if (checksum == parity)
|
||||
{
|
||||
passedChecksumCount++;
|
||||
if (sentenceHasFix)
|
||||
++sentencesWithFixCount;
|
||||
|
||||
switch(curSentenceType)
|
||||
{
|
||||
case GPS_SENTENCE_GPRMC:
|
||||
date.commit();
|
||||
time.commit();
|
||||
if (sentenceHasFix)
|
||||
{
|
||||
location.commit();
|
||||
speed.commit();
|
||||
course.commit();
|
||||
}
|
||||
break;
|
||||
case GPS_SENTENCE_GPGGA:
|
||||
time.commit();
|
||||
if (sentenceHasFix)
|
||||
{
|
||||
location.commit();
|
||||
altitude.commit();
|
||||
}
|
||||
satellites.commit();
|
||||
hdop.commit();
|
||||
break;
|
||||
}
|
||||
|
||||
// Commit all custom listeners of this sentence type
|
||||
for (TinyGPSCustom *p = customCandidates; p != NULL && strcmp(p->sentenceName, customCandidates->sentenceName) == 0; p = p->next)
|
||||
p->commit();
|
||||
return true;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
++failedChecksumCount;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// the first term determines the sentence type
|
||||
if (curTermNumber == 0)
|
||||
{
|
||||
if (!strcmp(term, _GPRMCterm) || !strcmp(term, _GNRMCterm))
|
||||
curSentenceType = GPS_SENTENCE_GPRMC;
|
||||
else if (!strcmp(term, _GPGGAterm) || !strcmp(term, _GNGGAterm))
|
||||
curSentenceType = GPS_SENTENCE_GPGGA;
|
||||
else
|
||||
curSentenceType = GPS_SENTENCE_OTHER;
|
||||
|
||||
// Any custom candidates of this sentence type?
|
||||
for (customCandidates = customElts; customCandidates != NULL && strcmp(customCandidates->sentenceName, term) < 0; customCandidates = customCandidates->next);
|
||||
if (customCandidates != NULL && strcmp(customCandidates->sentenceName, term) > 0)
|
||||
customCandidates = NULL;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (curSentenceType != GPS_SENTENCE_OTHER && term[0])
|
||||
switch(COMBINE(curSentenceType, curTermNumber))
|
||||
{
|
||||
case COMBINE(GPS_SENTENCE_GPRMC, 1): // Time in both sentences
|
||||
case COMBINE(GPS_SENTENCE_GPGGA, 1):
|
||||
time.setTime(term);
|
||||
break;
|
||||
case COMBINE(GPS_SENTENCE_GPRMC, 2): // GPRMC validity
|
||||
sentenceHasFix = term[0] == 'A';
|
||||
break;
|
||||
case COMBINE(GPS_SENTENCE_GPRMC, 3): // Latitude
|
||||
case COMBINE(GPS_SENTENCE_GPGGA, 2):
|
||||
location.setLatitude(term);
|
||||
break;
|
||||
case COMBINE(GPS_SENTENCE_GPRMC, 4): // N/S
|
||||
case COMBINE(GPS_SENTENCE_GPGGA, 3):
|
||||
location.rawNewLatData.negative = term[0] == 'S';
|
||||
break;
|
||||
case COMBINE(GPS_SENTENCE_GPRMC, 5): // Longitude
|
||||
case COMBINE(GPS_SENTENCE_GPGGA, 4):
|
||||
location.setLongitude(term);
|
||||
break;
|
||||
case COMBINE(GPS_SENTENCE_GPRMC, 6): // E/W
|
||||
case COMBINE(GPS_SENTENCE_GPGGA, 5):
|
||||
location.rawNewLngData.negative = term[0] == 'W';
|
||||
break;
|
||||
case COMBINE(GPS_SENTENCE_GPRMC, 7): // Speed (GPRMC)
|
||||
speed.set(term);
|
||||
break;
|
||||
case COMBINE(GPS_SENTENCE_GPRMC, 8): // Course (GPRMC)
|
||||
course.set(term);
|
||||
break;
|
||||
case COMBINE(GPS_SENTENCE_GPRMC, 9): // Date (GPRMC)
|
||||
date.setDate(term);
|
||||
break;
|
||||
case COMBINE(GPS_SENTENCE_GPGGA, 6): // Fix data (GPGGA)
|
||||
sentenceHasFix = term[0] > '0';
|
||||
break;
|
||||
case COMBINE(GPS_SENTENCE_GPGGA, 7): // Satellites used (GPGGA)
|
||||
satellites.set(term);
|
||||
break;
|
||||
case COMBINE(GPS_SENTENCE_GPGGA, 8): // HDOP
|
||||
hdop.set(term);
|
||||
break;
|
||||
case COMBINE(GPS_SENTENCE_GPGGA, 9): // Altitude (GPGGA)
|
||||
altitude.set(term);
|
||||
break;
|
||||
}
|
||||
|
||||
// Set custom values as needed
|
||||
for (TinyGPSCustom *p = customCandidates; p != NULL && strcmp(p->sentenceName, customCandidates->sentenceName) == 0 && p->termNumber <= curTermNumber; p = p->next)
|
||||
if (p->termNumber == curTermNumber)
|
||||
p->set(term);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* static */
|
||||
double TinyGPSPlus::distanceBetween(double lat1, double long1, double lat2, double long2)
|
||||
{
|
||||
// returns distance in meters between two positions, both specified
|
||||
// as signed decimal-degrees latitude and longitude. Uses great-circle
|
||||
// distance computation for hypothetical sphere of radius 6372795 meters.
|
||||
// Because Earth is no exact sphere, rounding errors may be up to 0.5%.
|
||||
// Courtesy of Maarten Lamers
|
||||
double delta = radians(long1-long2);
|
||||
double sdlong = sin(delta);
|
||||
double cdlong = cos(delta);
|
||||
lat1 = radians(lat1);
|
||||
lat2 = radians(lat2);
|
||||
double slat1 = sin(lat1);
|
||||
double clat1 = cos(lat1);
|
||||
double slat2 = sin(lat2);
|
||||
double clat2 = cos(lat2);
|
||||
delta = (clat1 * slat2) - (slat1 * clat2 * cdlong);
|
||||
delta = sq(delta);
|
||||
delta += sq(clat2 * sdlong);
|
||||
delta = sqrt(delta);
|
||||
double denom = (slat1 * slat2) + (clat1 * clat2 * cdlong);
|
||||
delta = atan2(delta, denom);
|
||||
return delta * 6372795;
|
||||
}
|
||||
|
||||
double TinyGPSPlus::courseTo(double lat1, double long1, double lat2, double long2)
|
||||
{
|
||||
// returns course in degrees (North=0, West=270) from position 1 to position 2,
|
||||
// both specified as signed decimal-degrees latitude and longitude.
|
||||
// Because Earth is no exact sphere, calculated course may be off by a tiny fraction.
|
||||
// Courtesy of Maarten Lamers
|
||||
double dlon = radians(long2-long1);
|
||||
lat1 = radians(lat1);
|
||||
lat2 = radians(lat2);
|
||||
double a1 = sin(dlon) * cos(lat2);
|
||||
double a2 = sin(lat1) * cos(lat2) * cos(dlon);
|
||||
a2 = cos(lat1) * sin(lat2) - a2;
|
||||
a2 = atan2(a1, a2);
|
||||
if (a2 < 0.0)
|
||||
{
|
||||
a2 += TWO_PI;
|
||||
}
|
||||
return degrees(a2);
|
||||
}
|
||||
|
||||
const char *TinyGPSPlus::cardinal(double course)
|
||||
{
|
||||
static const char* directions[] = {"N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"};
|
||||
int direction = (int)((course + 11.25f) / 22.5f);
|
||||
return directions[direction % 16];
|
||||
}
|
||||
|
||||
void TinyGPSLocation::commit()
|
||||
{
|
||||
rawLatData = rawNewLatData;
|
||||
rawLngData = rawNewLngData;
|
||||
lastCommitTime = millis();
|
||||
valid = updated = true;
|
||||
}
|
||||
|
||||
void TinyGPSLocation::setLatitude(const char *term)
|
||||
{
|
||||
TinyGPSPlus::parseDegrees(term, rawNewLatData);
|
||||
}
|
||||
|
||||
void TinyGPSLocation::setLongitude(const char *term)
|
||||
{
|
||||
TinyGPSPlus::parseDegrees(term, rawNewLngData);
|
||||
}
|
||||
|
||||
double TinyGPSLocation::lat()
|
||||
{
|
||||
updated = false;
|
||||
double ret = rawLatData.deg + rawLatData.billionths / 1000000000.0;
|
||||
return rawLatData.negative ? -ret : ret;
|
||||
}
|
||||
|
||||
double TinyGPSLocation::lng()
|
||||
{
|
||||
updated = false;
|
||||
double ret = rawLngData.deg + rawLngData.billionths / 1000000000.0;
|
||||
return rawLngData.negative ? -ret : ret;
|
||||
}
|
||||
|
||||
void TinyGPSDate::commit()
|
||||
{
|
||||
date = newDate;
|
||||
lastCommitTime = millis();
|
||||
valid = updated = true;
|
||||
}
|
||||
|
||||
void TinyGPSTime::commit()
|
||||
{
|
||||
time = newTime;
|
||||
lastCommitTime = millis();
|
||||
valid = updated = true;
|
||||
}
|
||||
|
||||
void TinyGPSTime::setTime(const char *term)
|
||||
{
|
||||
newTime = (uint32_t)TinyGPSPlus::parseDecimal(term);
|
||||
}
|
||||
|
||||
void TinyGPSDate::setDate(const char *term)
|
||||
{
|
||||
newDate = atol(term);
|
||||
}
|
||||
|
||||
uint16_t TinyGPSDate::year()
|
||||
{
|
||||
updated = false;
|
||||
uint16_t year = date % 100;
|
||||
return year + 2000;
|
||||
}
|
||||
|
||||
uint8_t TinyGPSDate::month()
|
||||
{
|
||||
updated = false;
|
||||
return (date / 100) % 100;
|
||||
}
|
||||
|
||||
uint8_t TinyGPSDate::day()
|
||||
{
|
||||
updated = false;
|
||||
return date / 10000;
|
||||
}
|
||||
|
||||
uint8_t TinyGPSTime::hour()
|
||||
{
|
||||
updated = false;
|
||||
return time / 1000000;
|
||||
}
|
||||
|
||||
uint8_t TinyGPSTime::minute()
|
||||
{
|
||||
updated = false;
|
||||
return (time / 10000) % 100;
|
||||
}
|
||||
|
||||
uint8_t TinyGPSTime::second()
|
||||
{
|
||||
updated = false;
|
||||
return (time / 100) % 100;
|
||||
}
|
||||
|
||||
uint8_t TinyGPSTime::centisecond()
|
||||
{
|
||||
updated = false;
|
||||
return time % 100;
|
||||
}
|
||||
|
||||
void TinyGPSDecimal::commit()
|
||||
{
|
||||
val = newval;
|
||||
lastCommitTime = millis();
|
||||
valid = updated = true;
|
||||
}
|
||||
|
||||
void TinyGPSDecimal::set(const char *term)
|
||||
{
|
||||
newval = TinyGPSPlus::parseDecimal(term);
|
||||
}
|
||||
|
||||
void TinyGPSInteger::commit()
|
||||
{
|
||||
val = newval;
|
||||
lastCommitTime = millis();
|
||||
valid = updated = true;
|
||||
}
|
||||
|
||||
void TinyGPSInteger::set(const char *term)
|
||||
{
|
||||
newval = atol(term);
|
||||
}
|
||||
|
||||
TinyGPSCustom::TinyGPSCustom(TinyGPSPlus &gps, const char *_sentenceName, int _termNumber)
|
||||
{
|
||||
begin(gps, _sentenceName, _termNumber);
|
||||
}
|
||||
|
||||
void TinyGPSCustom::begin(TinyGPSPlus &gps, const char *_sentenceName, int _termNumber)
|
||||
{
|
||||
lastCommitTime = 0;
|
||||
updated = valid = false;
|
||||
sentenceName = _sentenceName;
|
||||
termNumber = _termNumber;
|
||||
memset(stagingBuffer, '\0', sizeof(stagingBuffer));
|
||||
memset(buffer, '\0', sizeof(buffer));
|
||||
|
||||
// Insert this item into the GPS tree
|
||||
gps.insertCustom(this, _sentenceName, _termNumber);
|
||||
}
|
||||
|
||||
void TinyGPSCustom::commit()
|
||||
{
|
||||
strcpy(this->buffer, this->stagingBuffer);
|
||||
lastCommitTime = millis();
|
||||
valid = updated = true;
|
||||
}
|
||||
|
||||
void TinyGPSCustom::set(const char *term)
|
||||
{
|
||||
strncpy(this->stagingBuffer, term, sizeof(this->stagingBuffer));
|
||||
}
|
||||
|
||||
void TinyGPSPlus::insertCustom(TinyGPSCustom *pElt, const char *sentenceName, int termNumber)
|
||||
{
|
||||
TinyGPSCustom **ppelt;
|
||||
|
||||
for (ppelt = &this->customElts; *ppelt != NULL; ppelt = &(*ppelt)->next)
|
||||
{
|
||||
int cmp = strcmp(sentenceName, (*ppelt)->sentenceName);
|
||||
if (cmp < 0 || (cmp == 0 && termNumber < (*ppelt)->termNumber))
|
||||
break;
|
||||
}
|
||||
|
||||
pElt->next = *ppelt;
|
||||
*ppelt = pElt;
|
||||
}
|
@@ -1,278 +0,0 @@
|
||||
/*
|
||||
TinyGPS++ - a small GPS library for Arduino providing universal NMEA parsing
|
||||
Based on work by and "distanceBetween" and "courseTo" courtesy of Maarten Lamers.
|
||||
Suggestion to add satellites, courseTo(), and cardinal() by Matt Monson.
|
||||
Location precision improvements suggested by Wayne Holder.
|
||||
Copyright (C) 2008-2022 Mikal Hart
|
||||
All rights reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef __TinyGPSPlus_h
|
||||
#define __TinyGPSPlus_h
|
||||
|
||||
#if defined(ARDUINO) && ARDUINO >= 100
|
||||
#include "Arduino.h"
|
||||
#else
|
||||
#include "WProgram.h"
|
||||
#endif
|
||||
#include <limits.h>
|
||||
|
||||
#define _GPS_VERSION "1.0.3" // software version of this library
|
||||
#define _GPS_MPH_PER_KNOT 1.15077945
|
||||
#define _GPS_MPS_PER_KNOT 0.51444444
|
||||
#define _GPS_KMPH_PER_KNOT 1.852
|
||||
#define _GPS_MILES_PER_METER 0.00062137112
|
||||
#define _GPS_KM_PER_METER 0.001
|
||||
#define _GPS_FEET_PER_METER 3.2808399
|
||||
#define _GPS_MAX_FIELD_SIZE 15
|
||||
|
||||
struct RawDegrees
|
||||
{
|
||||
uint16_t deg;
|
||||
uint32_t billionths;
|
||||
bool negative;
|
||||
public:
|
||||
RawDegrees() : deg(0), billionths(0), negative(false)
|
||||
{}
|
||||
};
|
||||
|
||||
struct TinyGPSLocation
|
||||
{
|
||||
friend class TinyGPSPlus;
|
||||
public:
|
||||
bool isValid() const { return valid; }
|
||||
bool isUpdated() const { return updated; }
|
||||
uint32_t age() const { return valid ? millis() - lastCommitTime : (uint32_t)ULONG_MAX; }
|
||||
const RawDegrees &rawLat() { updated = false; return rawLatData; }
|
||||
const RawDegrees &rawLng() { updated = false; return rawLngData; }
|
||||
double lat();
|
||||
double lng();
|
||||
|
||||
TinyGPSLocation() : valid(false), updated(false)
|
||||
{}
|
||||
|
||||
private:
|
||||
bool valid, updated;
|
||||
RawDegrees rawLatData, rawLngData, rawNewLatData, rawNewLngData;
|
||||
uint32_t lastCommitTime;
|
||||
void commit();
|
||||
void setLatitude(const char *term);
|
||||
void setLongitude(const char *term);
|
||||
};
|
||||
|
||||
struct TinyGPSDate
|
||||
{
|
||||
friend class TinyGPSPlus;
|
||||
public:
|
||||
bool isValid() const { return valid; }
|
||||
bool isUpdated() const { return updated; }
|
||||
uint32_t age() const { return valid ? millis() - lastCommitTime : (uint32_t)ULONG_MAX; }
|
||||
|
||||
uint32_t value() { updated = false; return date; }
|
||||
uint16_t year();
|
||||
uint8_t month();
|
||||
uint8_t day();
|
||||
|
||||
TinyGPSDate() : valid(false), updated(false), date(0)
|
||||
{}
|
||||
|
||||
private:
|
||||
bool valid, updated;
|
||||
uint32_t date, newDate;
|
||||
uint32_t lastCommitTime;
|
||||
void commit();
|
||||
void setDate(const char *term);
|
||||
};
|
||||
|
||||
struct TinyGPSTime
|
||||
{
|
||||
friend class TinyGPSPlus;
|
||||
public:
|
||||
bool isValid() const { return valid; }
|
||||
bool isUpdated() const { return updated; }
|
||||
uint32_t age() const { return valid ? millis() - lastCommitTime : (uint32_t)ULONG_MAX; }
|
||||
|
||||
uint32_t value() { updated = false; return time; }
|
||||
uint8_t hour();
|
||||
uint8_t minute();
|
||||
uint8_t second();
|
||||
uint8_t centisecond();
|
||||
|
||||
TinyGPSTime() : valid(false), updated(false), time(0)
|
||||
{}
|
||||
|
||||
private:
|
||||
bool valid, updated;
|
||||
uint32_t time, newTime;
|
||||
uint32_t lastCommitTime;
|
||||
void commit();
|
||||
void setTime(const char *term);
|
||||
};
|
||||
|
||||
struct TinyGPSDecimal
|
||||
{
|
||||
friend class TinyGPSPlus;
|
||||
public:
|
||||
bool isValid() const { return valid; }
|
||||
bool isUpdated() const { return updated; }
|
||||
uint32_t age() const { return valid ? millis() - lastCommitTime : (uint32_t)ULONG_MAX; }
|
||||
int32_t value() { updated = false; return val; }
|
||||
|
||||
TinyGPSDecimal() : valid(false), updated(false), val(0)
|
||||
{}
|
||||
|
||||
private:
|
||||
bool valid, updated;
|
||||
uint32_t lastCommitTime;
|
||||
int32_t val, newval;
|
||||
void commit();
|
||||
void set(const char *term);
|
||||
};
|
||||
|
||||
struct TinyGPSInteger
|
||||
{
|
||||
friend class TinyGPSPlus;
|
||||
public:
|
||||
bool isValid() const { return valid; }
|
||||
bool isUpdated() const { return updated; }
|
||||
uint32_t age() const { return valid ? millis() - lastCommitTime : (uint32_t)ULONG_MAX; }
|
||||
uint32_t value() { updated = false; return val; }
|
||||
|
||||
TinyGPSInteger() : valid(false), updated(false), val(0)
|
||||
{}
|
||||
|
||||
private:
|
||||
bool valid, updated;
|
||||
uint32_t lastCommitTime;
|
||||
uint32_t val, newval;
|
||||
void commit();
|
||||
void set(const char *term);
|
||||
};
|
||||
|
||||
struct TinyGPSSpeed : TinyGPSDecimal
|
||||
{
|
||||
double knots() { return value() / 100.0; }
|
||||
double mph() { return _GPS_MPH_PER_KNOT * value() / 100.0; }
|
||||
double mps() { return _GPS_MPS_PER_KNOT * value() / 100.0; }
|
||||
double kmph() { return _GPS_KMPH_PER_KNOT * value() / 100.0; }
|
||||
};
|
||||
|
||||
struct TinyGPSCourse : public TinyGPSDecimal
|
||||
{
|
||||
double deg() { return value() / 100.0; }
|
||||
};
|
||||
|
||||
struct TinyGPSAltitude : TinyGPSDecimal
|
||||
{
|
||||
double meters() { return value() / 100.0; }
|
||||
double miles() { return _GPS_MILES_PER_METER * value() / 100.0; }
|
||||
double kilometers() { return _GPS_KM_PER_METER * value() / 100.0; }
|
||||
double feet() { return _GPS_FEET_PER_METER * value() / 100.0; }
|
||||
};
|
||||
|
||||
struct TinyGPSHDOP : TinyGPSDecimal
|
||||
{
|
||||
double hdop() { return value() / 100.0; }
|
||||
};
|
||||
|
||||
class TinyGPSPlus;
|
||||
class TinyGPSCustom
|
||||
{
|
||||
public:
|
||||
TinyGPSCustom() {};
|
||||
TinyGPSCustom(TinyGPSPlus &gps, const char *sentenceName, int termNumber);
|
||||
void begin(TinyGPSPlus &gps, const char *_sentenceName, int _termNumber);
|
||||
|
||||
bool isUpdated() const { return updated; }
|
||||
bool isValid() const { return valid; }
|
||||
uint32_t age() const { return valid ? millis() - lastCommitTime : (uint32_t)ULONG_MAX; }
|
||||
const char *value() { updated = false; return buffer; }
|
||||
|
||||
private:
|
||||
void commit();
|
||||
void set(const char *term);
|
||||
|
||||
char stagingBuffer[_GPS_MAX_FIELD_SIZE + 1];
|
||||
char buffer[_GPS_MAX_FIELD_SIZE + 1];
|
||||
unsigned long lastCommitTime;
|
||||
bool valid, updated;
|
||||
const char *sentenceName;
|
||||
int termNumber;
|
||||
friend class TinyGPSPlus;
|
||||
TinyGPSCustom *next;
|
||||
};
|
||||
|
||||
class TinyGPSPlus
|
||||
{
|
||||
public:
|
||||
TinyGPSPlus();
|
||||
bool encode(char c); // process one character received from GPS
|
||||
TinyGPSPlus &operator << (char c) {encode(c); return *this;}
|
||||
|
||||
TinyGPSLocation location;
|
||||
TinyGPSDate date;
|
||||
TinyGPSTime time;
|
||||
TinyGPSSpeed speed;
|
||||
TinyGPSCourse course;
|
||||
TinyGPSAltitude altitude;
|
||||
TinyGPSInteger satellites;
|
||||
TinyGPSHDOP hdop;
|
||||
|
||||
static const char *libraryVersion() { return _GPS_VERSION; }
|
||||
|
||||
static double distanceBetween(double lat1, double long1, double lat2, double long2);
|
||||
static double courseTo(double lat1, double long1, double lat2, double long2);
|
||||
static const char *cardinal(double course);
|
||||
|
||||
static int32_t parseDecimal(const char *term);
|
||||
static void parseDegrees(const char *term, RawDegrees °);
|
||||
|
||||
uint32_t charsProcessed() const { return encodedCharCount; }
|
||||
uint32_t sentencesWithFix() const { return sentencesWithFixCount; }
|
||||
uint32_t failedChecksum() const { return failedChecksumCount; }
|
||||
uint32_t passedChecksum() const { return passedChecksumCount; }
|
||||
|
||||
private:
|
||||
enum {GPS_SENTENCE_GPGGA, GPS_SENTENCE_GPRMC, GPS_SENTENCE_OTHER};
|
||||
|
||||
// parsing state variables
|
||||
uint8_t parity;
|
||||
bool isChecksumTerm;
|
||||
char term[_GPS_MAX_FIELD_SIZE];
|
||||
uint8_t curSentenceType;
|
||||
uint8_t curTermNumber;
|
||||
uint8_t curTermOffset;
|
||||
bool sentenceHasFix;
|
||||
|
||||
// custom element support
|
||||
friend class TinyGPSCustom;
|
||||
TinyGPSCustom *customElts;
|
||||
TinyGPSCustom *customCandidates;
|
||||
void insertCustom(TinyGPSCustom *pElt, const char *sentenceName, int index);
|
||||
|
||||
// statistics
|
||||
uint32_t encodedCharCount;
|
||||
uint32_t sentencesWithFixCount;
|
||||
uint32_t failedChecksumCount;
|
||||
uint32_t passedChecksumCount;
|
||||
|
||||
// internal utilities
|
||||
int fromHex(char a);
|
||||
bool endOfTermHandler();
|
||||
};
|
||||
|
||||
#endif // def(__TinyGPSPlus_h)
|
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
TinyGPSPlus - a small GPS library for Arduino providing universal NMEA parsing
|
||||
Based on work by and "distanceBetween" and "courseTo" courtesy of Maarten Lamers.
|
||||
Suggestion to add satellites, courseTo(), and cardinal() by Matt Monson.
|
||||
Location precision improvements suggested by Wayne Holder.
|
||||
Copyright (C) 2008-2013 Mikal Hart
|
||||
All rights reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef __TinyGPSPlus_h
|
||||
#include "TinyGPS++.h"
|
||||
#endif
|
BIN
src/C++/Socket/a.out
Executable file
BIN
src/C++/Socket/a.out
Executable file
Binary file not shown.
53
src/C++/Socket/main.cpp
Normal file
53
src/C++/Socket/main.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#include <iostream>
|
||||
#include <boost/asio.hpp>
|
||||
#include <string>
|
||||
|
||||
using boost::asio::ip::tcp;
|
||||
|
||||
int main() {
|
||||
try {
|
||||
// Create an io_context object
|
||||
boost::asio::io_context io_context;
|
||||
|
||||
// Resolve the server address and port
|
||||
tcp::resolver resolver(io_context);
|
||||
tcp::resolver::results_type endpoints = resolver.resolve("127.0.0.1", "4024");
|
||||
|
||||
// Create and connect the socket
|
||||
tcp::socket socket(io_context);
|
||||
boost::asio::connect(socket, endpoints);
|
||||
|
||||
std::cout << "Connected to the server." << std::endl;
|
||||
|
||||
// Receive initial message from the server
|
||||
boost::asio::streambuf buffer;
|
||||
boost::asio::read_until(socket, buffer, "\n");
|
||||
std::istream is(&buffer);
|
||||
std::string initial_message;
|
||||
std::getline(is, initial_message);
|
||||
std::cout << "Initial message from server: " << initial_message << std::endl;
|
||||
|
||||
// Send and receive messages
|
||||
while (true) {
|
||||
// Send a message to the server
|
||||
std::string message;
|
||||
std::cout << "Enter message: ";
|
||||
std::getline(std::cin, message);
|
||||
message += "\n"; // Add newline to mark the end of the message
|
||||
boost::asio::write(socket, boost::asio::buffer(message));
|
||||
|
||||
// Receive a response from the server
|
||||
boost::asio::streambuf response_buffer;
|
||||
boost::asio::read_until(socket, response_buffer, "\n");
|
||||
std::istream response_stream(&response_buffer);
|
||||
std::string reply;
|
||||
std::getline(response_stream, reply);
|
||||
std::cout << "Reply from server: " << reply << std::endl;
|
||||
}
|
||||
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << "Exception: " << e.what() << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Binary file not shown.
@@ -1,71 +1,17 @@
|
||||
from flask import Flask, Response, request, render_template, jsonify
|
||||
import paho.mqtt.client as mqtt
|
||||
from flask import Flask, render_template
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
kobuki_message = "empty"
|
||||
def on_message(client, userdata, message):
|
||||
global kobuki_message, latest_image
|
||||
if message.topic == "kobuki/data":
|
||||
kobuki_message = str(message.payload.decode("utf-8"))
|
||||
elif message.topic == "kobuki/cam":
|
||||
latest_image = message.payload
|
||||
|
||||
# Create an MQTT client instance
|
||||
mqtt_client = mqtt.Client()
|
||||
mqtt_client.username_pw_set("server", "serverwachtwoordofzo")
|
||||
mqtt_client.connect("localhost", 80, 60)
|
||||
mqtt_client.loop_start()
|
||||
mqtt_client.subscribe("kobuki/data")
|
||||
mqtt_client.subscribe("kobuki/cam")
|
||||
|
||||
mqtt_client.on_message = on_message # this lines needs to be under the function definition otherwise it cant find which function it needs to use
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
return render_template('index.html')
|
||||
|
||||
|
||||
@app.route('/control', methods=["GET","POST"])
|
||||
@app.route('/control', methods=['POST'])
|
||||
def control():
|
||||
if request.authorization and request.authorization.username == 'ishak' and request.authorization.password == 'kobuki':
|
||||
return render_template('control.html')
|
||||
else:
|
||||
return ('Unauthorized', 401, {'WWW-Authenticate': 'Basic realm="Login Required"'})
|
||||
|
||||
@app.route('/move', methods=['POST'])
|
||||
def move():
|
||||
data = request.get_json()
|
||||
direction = data.get("direction")
|
||||
|
||||
# Verstuur de richting via MQTT
|
||||
if direction:
|
||||
mqtt_client.publish("home/commands", direction) # Het topic kan aangepast worden
|
||||
|
||||
return jsonify({"status": "success", "direction": direction})
|
||||
|
||||
|
||||
@app.route('/data', methods=['GET'])
|
||||
def data():
|
||||
return kobuki_message
|
||||
|
||||
|
||||
@app.route('/image')
|
||||
def image():
|
||||
global latest_image
|
||||
if latest_image is not None:
|
||||
return Response(latest_image, mimetype='image/jpeg')
|
||||
else:
|
||||
return "No image available", 404
|
||||
|
||||
|
||||
@app.route('/phpmyadmin/<path:path>')
|
||||
def phpmyadmin_passthrough(path):
|
||||
# Laat Apache deze route direct afhandelen
|
||||
return "", 404
|
||||
|
||||
|
||||
return("hello")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True, port=5000)
|
||||
app.run(debug=True)
|
||||
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 200 KiB |
@@ -1,57 +0,0 @@
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
document.querySelectorAll(".btn").forEach(button => {
|
||||
button.addEventListener("click", function(event) {
|
||||
event.preventDefault(); // prevents page refresh
|
||||
|
||||
// Get the value of the button
|
||||
const direction = event.target.value;
|
||||
|
||||
fetch("/move", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({ direction: direction })
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {script
|
||||
console.log("Success:", data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error("Error:", error);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Fetch data from the server
|
||||
async function fetchData() {
|
||||
const response = await fetch("/data");
|
||||
const data = await response.json();
|
||||
return data;
|
||||
}
|
||||
|
||||
// Parse the data and show it on the website
|
||||
async function parseData() {
|
||||
const data = await fetchData();
|
||||
const sensorDataContainer = document.getElementById("sensor-data");
|
||||
sensorDataContainer.innerHTML = ""; // Clear previous data
|
||||
// For each object in JSON array, create a new paragraph element and append it to the sensorDataContainer
|
||||
for (const [key, value] of Object.entries(data)) {
|
||||
const dataElement = document.createElement("p");
|
||||
dataElement.textContent = `${key}: ${value}`;
|
||||
sensorDataContainer.appendChild(dataElement);
|
||||
}
|
||||
}
|
||||
|
||||
// Update the image
|
||||
function updateImage() {
|
||||
var img = document.getElementById("robot-image");
|
||||
img.src = "/image?" + new Date().getTime(); // Add timestamp to avoid caching
|
||||
}
|
||||
|
||||
// Fetch and display sensor data every 5 seconds
|
||||
setInterval(parseData, 1000);
|
||||
|
||||
// Update the image every 5 seconds
|
||||
setInterval(updateImage, 200);
|
||||
});
|
@@ -1,8 +1,8 @@
|
||||
body {
|
||||
font-family: "Poppins", sans-serif;
|
||||
text-align: -webkit-center;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: 'Poppins', sans-serif;
|
||||
text-align: -webkit-center;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* This is my code for my navbar */
|
||||
@@ -10,23 +10,7 @@ body {
|
||||
.navbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
max-width: 80%;
|
||||
background-color: #fff;
|
||||
border: 1px solid #f0f0f0;
|
||||
border-radius: 50px;
|
||||
align-items: center;
|
||||
margin: 1.5rem auto 0 auto;
|
||||
padding: 0 30px;
|
||||
top: 0%;
|
||||
bottom: auto;
|
||||
left: 0%;
|
||||
right: 0%;
|
||||
}
|
||||
|
||||
.footer{
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
max-width: 80%;
|
||||
max-width: 70rem;
|
||||
background-color: #fff;
|
||||
border: 1px solid #f0f0f0;
|
||||
border-radius: 50px;
|
||||
@@ -45,126 +29,93 @@ body {
|
||||
}
|
||||
|
||||
.connectButton {
|
||||
border-radius: 10px;
|
||||
height: 100%;
|
||||
width: 100px;
|
||||
box-shadow: none;
|
||||
border: none;
|
||||
font-size: 1rem;
|
||||
height: 40px;
|
||||
background-color: #b3ffb3;
|
||||
}
|
||||
border-radius: 10px;
|
||||
height: 100%;
|
||||
width: 100px;
|
||||
box-shadow: none;
|
||||
border: none;
|
||||
font-size: 1rem;
|
||||
height: 40px;
|
||||
background-color: #b3ffb3;
|
||||
}
|
||||
|
||||
/* end navbar */
|
||||
|
||||
.container {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
margin-top: 50px;
|
||||
width: 80%;
|
||||
background-color: white;
|
||||
border-radius: 20px;
|
||||
box-shadow: 0px 8px 16px rgba(0, 0, 0, 0.2);
|
||||
padding: 40px;
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
margin-top: 50px;
|
||||
width: 80%;
|
||||
background-color: white;
|
||||
border-radius: 20px;
|
||||
box-shadow: 0px 8px 16px rgba(0, 0, 0, 0.2);
|
||||
padding: 40px;
|
||||
}
|
||||
.button-section {
|
||||
position: relative;
|
||||
width: 150px;
|
||||
height: 150px;
|
||||
position: relative;
|
||||
width: 150px;
|
||||
height: 150px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.btn {
|
||||
position: absolute;
|
||||
background-color: #007bff;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
font-size: 1.2em;
|
||||
text-align: center;
|
||||
line-height: 60px;
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s ease, background-color 0.2s ease;
|
||||
position: absolute;
|
||||
background-color: #007BFF;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
font-size: 1.2em;
|
||||
text-align: center;
|
||||
line-height: 60px;
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s ease, background-color 0.2s ease;
|
||||
}
|
||||
|
||||
.text{
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.image{
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.sectionHeight{
|
||||
height: 200px;
|
||||
}
|
||||
|
||||
/* Direction buttons */
|
||||
/* Middenknop */
|
||||
.btn:nth-child(1) {
|
||||
/* Left */
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-160%, -50%);
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-125%, -50%);
|
||||
}
|
||||
|
||||
/* Knop boven */
|
||||
.btn:nth-child(2) {
|
||||
/* Up */
|
||||
top: 0;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -35%);
|
||||
top: 0;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
/* Knop rechts */
|
||||
.btn:nth-child(3) {
|
||||
/* Right */
|
||||
top: 50%;
|
||||
right: 0;
|
||||
transform: translate(35%, -50%);
|
||||
top: 50%;
|
||||
right: 0;
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
|
||||
/* Knop onder */
|
||||
.btn:nth-child(4) {
|
||||
/* Down */
|
||||
bottom: 0;
|
||||
left: 50%;
|
||||
transform: translate(-50%, 35%);
|
||||
bottom: 0;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
/* Knop links */
|
||||
.btn:nth-child(5) {
|
||||
/* Stop Button */
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
background-color: red; /* Distinct color for the stop button */
|
||||
width: 60px; /* Slightly larger for emphasis */
|
||||
height: 60px; /* Slightly larger for emphasis */
|
||||
line-height: 60px; /* Center text vertically */
|
||||
top: 50%;
|
||||
left: 0;
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
|
||||
/* Hover effects */
|
||||
.btn:hover {
|
||||
background-color: #0056b3;
|
||||
background-color: #0056b3;
|
||||
/* transform: scale(1.1); */
|
||||
}
|
||||
|
||||
.btn:active {
|
||||
background-color: #004494;
|
||||
background-color: #004494;
|
||||
}
|
||||
|
||||
.stop-button:hover {
|
||||
background-color: darkred; /* Different hover color for the stop button */
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
th,td {
|
||||
border: 1px solid #ddd;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
th {
|
||||
background-color: #f2f2f2;
|
||||
text-align: left;
|
||||
}
|
@@ -1,73 +0,0 @@
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: #f4f4f4;
|
||||
}
|
||||
|
||||
header {
|
||||
background-color: #333;
|
||||
color: #fff;
|
||||
padding: 1rem 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
header h1 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
nav ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
nav ul li {
|
||||
display: inline;
|
||||
margin: 0 1rem;
|
||||
}
|
||||
|
||||
nav ul li a {
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
section {
|
||||
padding: 2rem;
|
||||
margin: 1rem 0;
|
||||
background-color: #fff;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
section h2 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
form label {
|
||||
margin: 0.5rem 0 0.2rem;
|
||||
}
|
||||
|
||||
form input, form textarea {
|
||||
padding: 0.5rem;
|
||||
margin-bottom: 1rem;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
form button {
|
||||
padding: 0.7rem;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
background-color: #333;
|
||||
color: #fff;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
form button:hover {
|
||||
background-color: #555;
|
||||
}
|
@@ -11,6 +11,5 @@
|
||||
{% include 'navbar.html' %}
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
|
||||
</body>
|
||||
</html>
|
@@ -1,51 +0,0 @@
|
||||
{% extends 'base.html' %}
|
||||
{% block head %}
|
||||
<link rel="stylesheet" href="../static/style.css" />
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Kobuki</title>
|
||||
<link rel="stylesheet" href="../static/style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="robot-image">
|
||||
<img src="/image" alt="Kobuki Camera Feed" id="robot-image" />
|
||||
</div>
|
||||
<div class="button-section">
|
||||
<form id="form" action="/move" method="post">
|
||||
<button class="btn" name="direction" value="left">←</button>
|
||||
<button class="btn" name="direction" value="up">↑</button>
|
||||
<button class="btn" name="direction" value="right">→</button>
|
||||
<button class="btn" name="direction" value="down">↓</button>
|
||||
<button class="btn stop-button" name="direction" value="stop">
|
||||
Stop
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<h1>Sensor Data</h1>
|
||||
<div class="data">
|
||||
<table id="sensor-data"> <!-- Do not change -->
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Sensor</th>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- Sensor data rows will be inserted here -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="../static/script.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
{% endblock %}
|
@@ -1,21 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
||||
</head>
|
||||
<body>
|
||||
<footer class="footer">
|
||||
<img src="{{url_for('static', filename='images/logo_kobuki.png')}}" alt="logo" class="imgNav" />
|
||||
<h3>© 2024 Kobuki Robot Project. All rights reserved.</h3>
|
||||
<div class="buttonContainer">
|
||||
<a href="{{ url_for('control') }}" target="_blank">
|
||||
<button class="click connectButton">Controller</button>
|
||||
</a>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
@@ -1,58 +1,19 @@
|
||||
{% extends 'base.html' %} {% block head %}
|
||||
<link rel="stylesheet" href="../static/style.css" />
|
||||
{% endblock %} {% block content %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Kobuki Robot Project</title>
|
||||
<link rel="stylesheet" href="../static/style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<section class="container sectionHeight">
|
||||
<p class="text">
|
||||
The Kobuki Robot Project is an innovative initiative aimed at developing
|
||||
a versatile and intelligent robot platform. Our goal is to create a
|
||||
robot that can navigate autonomously, interact with its environment, and
|
||||
perform various tasks.
|
||||
</p>
|
||||
<img src="{{url_for('static', filename='images/logo.png')}}" alt="logo" class="image" />
|
||||
</section>
|
||||
{%extends 'base.html'%}
|
||||
|
||||
<section class="container sectionHeight" id="about">
|
||||
<h2>About the Project</h2>
|
||||
<p>
|
||||
This project is a collaborative effort involving engineers, researchers,
|
||||
and enthusiasts. The Kobuki robot is equipped with various sensors,
|
||||
including bumpers, cliff sensors, and gyroscopes, to help it navigate
|
||||
and interact with its surroundings.
|
||||
</p>
|
||||
<p>Key features of the Kobuki Robot:</p>
|
||||
<ul>
|
||||
<li>Autonomous navigation</li>
|
||||
<li>Obstacle detection and avoidance</li>
|
||||
<li>Real-time data processing</li>
|
||||
<li>Remote control and monitoring</li>
|
||||
</ul>
|
||||
</section>
|
||||
{%block head%}
|
||||
|
||||
<section class="container" id="contact">
|
||||
<h2>Contact Us</h2>
|
||||
<form id="contact-form" action="/contact" method="post">
|
||||
<label for="name">Name:</label>
|
||||
<input type="text" id="name" name="name" required />
|
||||
<label for="email">Email:</label>
|
||||
<input type="email" id="email" name="email" required />
|
||||
<label for="message">Message:</label>
|
||||
<textarea id="message" name="message" required></textarea>
|
||||
<button type="submit">Send</button>
|
||||
</form>
|
||||
</section>
|
||||
{%endblock%}
|
||||
|
||||
{% include 'footer.html' %}
|
||||
|
||||
<script src="static/script.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
{% endblock %}
|
||||
{%block content%}
|
||||
<div class="container">
|
||||
<div class="image-section">
|
||||
<img src="kobuki.jpg" alt="Kobuki Robot" id="robot-image">
|
||||
</div>
|
||||
<div class="button-section">
|
||||
<button class="btn">1</button>
|
||||
<button class="btn">2</button>
|
||||
<button class="btn">3</button>
|
||||
<button class="btn">4</button>
|
||||
</div>
|
||||
</div>
|
||||
{%endblock%}
|
@@ -11,9 +11,13 @@
|
||||
<img src="{{url_for('static', filename='images/logo_kobuki.png')}}" alt="logo" class="imgNav" />
|
||||
<h3>Kobuki</h3>
|
||||
<div class="buttonContainer">
|
||||
<a href="{{ url_for('control') }}" target="_blank">
|
||||
<button class="click connectButton">Controller</button>
|
||||
<a
|
||||
href="https://gitlab.fdmci.hva.nl/propedeuse-hbo-ict/onderwijs/2023-2024/out-a-se-ti/blok-3/vuupoofeehoo27"
|
||||
target="_blank"
|
||||
>
|
||||
<button class="click connectButton">Placeholder</button>
|
||||
</a>
|
||||
<!-- <a href="./signup.html">sign in</a> -->
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
|
20
src/Python/socket/socketServer.py
Normal file
20
src/Python/socket/socketServer.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import socket
|
||||
|
||||
HOST = "127.0.0.1" # Listen on all available interfaces
|
||||
PORT = 4024 # Port to listen on (non-privileged ports are > 1023)
|
||||
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
s.bind((HOST, PORT))
|
||||
s.listen()
|
||||
print(f"Server listening on {HOST}:{PORT}")
|
||||
conn, addr = s.accept()
|
||||
with conn:
|
||||
print(f"Connected by {addr}")
|
||||
conn.sendall(b"hallo\n")
|
||||
while True:
|
||||
data = conn.recv(2048)
|
||||
if data:
|
||||
print("Received:", repr(data))
|
||||
conn.sendall(b"message received\n")
|
||||
if not data:
|
||||
break
|
@@ -1,7 +0,0 @@
|
||||
import sys
|
||||
import logging
|
||||
|
||||
logging.basicConfig(stream=sys.stderr)
|
||||
sys.path.insert(0, "/home/ishak/rooziinuubii79/src/Python/flask/web")
|
||||
|
||||
from app import app as application
|
@@ -1,7 +0,0 @@
|
||||
allow_anonymous false
|
||||
password_file /etc/mosquitto/passwordfile
|
||||
listener 8080
|
||||
protocol websockets
|
||||
|
||||
listener 1884
|
||||
protocol mqtt
|
@@ -1,22 +0,0 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name 145.92.224.21;
|
||||
|
||||
# Proxy WebSocket connections for MQTT
|
||||
location /ws/ {
|
||||
proxy_pass http://localhost:9001;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
|
||||
# Proxy HTTP connections for Flask
|
||||
location / {
|
||||
proxy_pass http://localhost:5000;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
stream {
|
||||
server {
|
||||
listen 9001;
|
||||
proxy_pass localhost:8080;
|
||||
}
|
||||
}
|
||||
|
@@ -1,11 +0,0 @@
|
||||
# Feedback expert review
|
||||
|
||||
probeer Definition of done zelf te formuleren.
|
||||
beter user stories maken
|
||||
|
||||
# Feedback peer review
|
||||
|
||||
- eventuele coaching op het gebied van technisch en taken
|
||||
- meer duidelijkheid wat wij gaan gebruiken, welke technieken en tools. Hiermee kan je mensen koppelen aan taken zodat iedereen iets heeft gedaan.
|
||||
- meer duidelijkheid van elkaar kwaliteiten en leerdoelen. Hiermee kan je goed inschatten wie wat kan doen en wie wat kan leren.
|
||||
|
@@ -1,42 +0,0 @@
|
||||
# Hoofd en deelvragen
|
||||
|
||||
**Wat is de aanleiding?**
|
||||
De aanleiding is de de behoefte aan veilige communicatie tussen apparaten. Dit is belangrijk omdat onbeveiligde dataoverdracht kan leiden tot datalekken.
|
||||
|
||||
**wat is het probleem/behoefte en waaruit blijkt dat?**
|
||||
Het probleem is dat data die tussen apparaten wordt verstuurd kwetsbaar kan zijn. Dit blijkt nadat wij te horen hebben gekregen dat er niet goed was omgegaan met communicatie tussen apparaten.
|
||||
|
||||
**Wie heeft het probleem/behoefte?**
|
||||
ons groepje, maar ook bijvoorbeeld grote bedrijven waar het heel belangrijk is dat data veilig wordt verstuurd zonder dat het in de verkeerde handen valt.
|
||||
|
||||
**Wanneer is het probleem/behoefte ontstaan?**
|
||||
Het probleem is ontstaan nadat wij te horen hebben gekregen dat er niet goed was omgegaan met communicatie tussen apparaten.
|
||||
|
||||
**Waarom is het een probleem?**
|
||||
Het is een probleem omdat onbeveiligde communicatie kan leiden tot datalekken waaronder privacy. Hiermee kunnen bedrijven in de problemen komen.
|
||||
|
||||
**Waar doet het probleem/behoefte zich voor (afbakening)?**
|
||||
Het probleem komt voor in verschillende sectoren waar data tussen apparaten wordt verstuurd. Dit kan zijn in de zorg, industrie, op kantoor, maar ook met IoT projecten wat je thuis kan hebben.
|
||||
|
||||
## Hoofdvraag
|
||||
|
||||
Welke communicatieprotocol geeft de mogelijkheid om veilig en betrouwbaar te communiceren tussen IoT apparaten?
|
||||
|
||||
## Deelvragen
|
||||
|
||||
1. Wat houdt veilige en betrouwbare communicatie tussen apparaten in?
|
||||
2. Welke protocollen zijn er om veilig en betrouwbaar te communiceren tussen apparaten?
|
||||
3. Wat zijn de voor- en nadelen van de verschillende protocollen?
|
||||
|
||||
## Bronnen
|
||||
|
||||
- Singh, S., & Jyoti. (2024, June 7). Secure Communications Protocols for IoT networks: a survey. https://journal.ijprse.com/index.php/ijprse/article/view/1082
|
||||
- Nguyen, K. T., Laurent, M., Oualha, N., CEA, & Institut Mines-Telecom. (2015). Survey on secure communication protocols for the Internet of Things. In Ad Hoc Networks (Vol. 32, pp. 17–31) [Journal-article]. http://dx.doi.org/10.1016/j.adhoc.2015.01.006
|
||||
- Miorandi, D., Sicari, S., De Pellegrini, F., & Imrich Chlamtac. (2012). Internet of things: Vision, applications and research challenges. In Ad Hoc Networks (Vol. 10, pp. 1497–1516) [Journal-article]. Elsevier B.V. http://dx.doi.org/10.1016/j.adhoc.2012.02.016
|
||||
- Christiano, P. (2023, November 5). Top 9 IoT communication protocols & their features in 2024: An In-Depth guide - ExpertBeacon. Expertbeacon. https://expertbeacon.com/iot-communication-protocol/
|
||||
- Yugha, R., & Chithra, S. (2020). A survey on technologies and security protocols: Reference for future generation IoT. Journal of Network and Computer Applications, 169, 102763. https://doi.org/10.1016/j.jnca.2020.102763
|
||||
- De Mendizábal, I. (2022, June 16). IoT Communication Protocols—IoT Data Protocols. Technical Articles. https://www.allaboutcircuits.com/technical-articles/internet-of-things-communication-protocols-iot-data-protocols/
|
||||
- IoT-technologieën en -protocollen | Microsoft Azure. (n.d.). https://azure.microsoft.com/nl-nl/solutions/iot/iot-technology-protocols
|
||||
- Het IoT verbinden: wat is MQTT en waarin verschilt het van CoAP? (n.d.). https://www.onlogic.com/nl/blog/het-iot-verbinden-wat-is-mqtt-en-waarin-verschilt-het-van-coap/
|
||||
- Nader, K. (2023, October 30). Wat zijn de voordelen van het gebruik van WebSocket voor IoT-communicatie? AppMaster - Ultimate All-in No-code Platform. https://appmaster.io/nl/blog/websocket-voor-iot-communicatie
|
||||
- Sidna, J., Amine, B., Abdallah, N., & Alami, H. E. (2020). Analysis and evaluation of communication Protocols for IoT Applications. Karbala International Journal of Modern Science. https://doi.org/10.1145/3419604.3419754
|
Binary file not shown.
@@ -1,49 +0,0 @@
|
||||
# Smart leerdoelen
|
||||
|
||||
Na de retrospective die ik heb gedaan, heb ik besloten om de volgende smart leerdoelen te stellen:
|
||||
|
||||
1 **Ik wil in de volgende blok meer gaan opletten op mijn teamgenoten om zo goed te weten waar iedereen mee bezig is.**
|
||||
|
||||
**specifiek:**
|
||||
|
||||
ik heb in onze groep de taak als voorzitter alleen merk ik op dit moment dat ik niet goed weet waar iedereen mee bezig is. Dat is niet handig omdat ik dan als voorzitter niet goed kan inschatten of iedereen op schema ligt.
|
||||
|
||||
**meetbaar:**
|
||||
|
||||
Ik wil dat ik aan het einde van de blok meer contact heb gehad met mijn teamgenoten en dat ik weet waar iedereen mee bezig is. Dit zorgt ervoor dat ik beter kan inschatten of iedereen op schema ligt en of ik moet ingrijpen.
|
||||
|
||||
**acceptabel:**
|
||||
|
||||
Dit is acceptabel omdat ik als voorzitter de taak heb om te zorgen dat iedereen op schema ligt en dat iedereen weet wat hij/zij moet doen. Zonder deze informatie kan ik niet goed mijn taak uitvoeren waardoor de teamgenoten niet goed kunnen werken.
|
||||
|
||||
**realistisch:**
|
||||
|
||||
Dit is realistisch omdat ik als voorzitter de taak heb om te zorgen dat iedereen op schema ligt en dat iedereen weet wat hij/zij moet doen.
|
||||
|
||||
**tijdgebonden:**
|
||||
|
||||
Ik wil dit doel behalen aan het einde van de blok. Dit is een realistische tijd omdat ik dan genoeg tijd heb om dit doel te behalen. Ik kan mij later ook nog tijdens de opleiding verbeteren op dit punt.
|
||||
|
||||
---
|
||||
|
||||
2 **Ik wil in de volgende blok meer gaan opletten op mijn eigen documentatie.**
|
||||
|
||||
**specifiek:**
|
||||
|
||||
In tegen stelling tot vorig jaar hou ik nu mijn documentatie niet goed bij. Dit is niet handig omdat ik dan niet goed kan zien wat ik daadwerkelijk heb gedaan en wat ik allemaal heb geleerd. Ook is het fijn dat ik dan kan terug kijken op mijn werk als ik het later nodig heb. Ik wil daarom minimaal 2 keer per week mijn documentatie bijwerken.
|
||||
|
||||
**meetbaar:**
|
||||
|
||||
Ik wil dat ik aan het einde van de blok mijn documentatie goed heb bijgehouden. Dit zorgt ervoor dat ik kan zien wat ik heb gedaan en wat ik allemaal heb geleerd. Ook kan ik dan terug kijken op mijn werk als ik het later nodig heb.
|
||||
|
||||
**acceptabel:**
|
||||
|
||||
Dit is acceptabel omdat ik dan toekomst gericht kan werken. Ik kan dan terug kijken op mijn werk als ik het later nodig heb. Ook kan ik dan zien wat ik heb gedaan en wat ik allemaal heb geleerd.
|
||||
|
||||
**realistisch:**
|
||||
|
||||
Dit is realistisch omdat ik dit vorig jaar ook heb gedaan. Ik weet hoe ik mijn documentatie moet bijhouden en wat ik allemaal moet opschrijven. Mijn eis van 2 keer per week is ook realistisch omdat ik dan genoeg tijd heb om mijn documentatie bij te werken.
|
||||
|
||||
**tijdgebonden:**
|
||||
|
||||
Ik wil dit doel behalen aan het einde van de blok. Dit is een realistische tijd omdat ik dan genoeg tijd heb om mijn documentatie bij te werken.
|
Binary file not shown.
@@ -1,11 +0,0 @@
|
||||
# kobuki
|
||||
# last sprint i have been busy with the website
|
||||
# my job was to make an controller on the website for the kobuki
|
||||
# so that we can control the kobuki with the website
|
||||
# i did this using a protocol called MQTT
|
||||
# mqtt is a protocol that is used to send messages between devices
|
||||
# this is different from the normal protocol that i used last year
|
||||
# it was a bit difficult to get the kobuki to work with the website
|
||||
# next sprint i will be working on a sensor
|
||||
# i will do some research on the different sensors that we can use
|
||||
#
|
Reference in New Issue
Block a user