55 Commits

Author SHA1 Message Date
ishak jmilou.ishak
2bfd11276a importlist changed 2025-01-07 15:00:13 +01:00
ishak jmilou.ishak
bc0b878230 changed to bool 2025-01-07 14:40:55 +01:00
ishak jmilou.ishak
806bb16662 changed startcom function 2025-01-07 14:38:38 +01:00
ishak jmilou.ishak
56f085b73d added parameters 2025-01-07 14:33:12 +01:00
ishak jmilou.ishak
b111e49dff functions for auto reconnect with pi and kobuki 2025-01-07 14:28:06 +01:00
ishak jmilou.ishak
bb1904b125 commentaar naar engels 2025-01-06 09:53:01 +01:00
ishak jmilou.ishak
b29a615681 verslag def versie 2025-01-06 09:52:50 +01:00
ishak jmilou.ishak
1fb7010773 enhance verslag.md with detailed analysis of IoT communication protocols and their reliability 2025-01-03 17:07:46 +01:00
ishak jmilou.ishak
ae03800c23 bijna klaar met deelvragen 2025-01-02 22:47:58 +01:00
ishak jmilou.ishak
490e0536ca took older version of the fetch 2024-12-20 14:31:25 +01:00
ishak jmilou.ishak
2f06927550 fix: correct interval for fetching sensor data to every 5 seconds 2024-12-20 14:10:14 +01:00
ishak jmilou.ishak
5dbbad5fff refactor data display to use table rows for sensor data 2024-12-20 14:08:45 +01:00
ishak jmilou.ishak
bc5f52922b removed image for now 2024-12-19 22:04:58 +01:00
ishak jmilou.ishak
52eff9ec39 return JSON response for /data endpoint 2024-12-19 22:02:36 +01:00
ishak jmilou.ishak
cf1350a3c0 zeker weten dat data word gestuurd 2024-12-19 21:55:51 +01:00
ishak jmilou.ishak
fa1aa6965d updated cmakelist 2024-12-19 20:31:50 +01:00
ishak jmilou.ishak
c5981f763b fixed error 2024-12-19 20:30:55 +01:00
ishak jmilou.ishak
45247b5574 added code from main branch 2024-12-19 20:22:43 +01:00
ishak jmilou.ishak
d8ce5de8f7 removed try catch 2024-12-19 20:05:48 +01:00
ishak jmilou.ishak
a6b1c04ea3 returned global variables 2024-12-19 20:03:36 +01:00
ishak jmilou.ishak
9cd6d3aa79 removed variable 2024-12-19 20:01:09 +01:00
ishak jmilou.ishak
810309c37d front to see if data is correct 2024-12-18 12:45:25 +01:00
ishak jmilou.ishak
ddeeb379cf fixed error from braces 2024-12-18 12:42:15 +01:00
ishak jmilou.ishak
29cfa86b5f returned try catch 2024-12-18 12:36:38 +01:00
ishak jmilou.ishak
f0b87de63d switched to older version 2024-12-18 12:30:41 +01:00
ishak jmilou.ishak
1ecd474ca1 switched to this branch 2024-12-18 12:28:59 +01:00
ishak jmilou.ishak
072b54af04 added kobuki_message 2024-12-17 15:49:32 +01:00
ishak jmilou.ishak
e0560d7162 changed mqtt port 2024-12-17 15:43:05 +01:00
ishak jmilou.ishak
b1d5e8548c got code from other branch 2024-12-17 15:26:19 +01:00
ishak jmilou.ishak
4da91f22ca changed 2024-12-17 15:03:21 +01:00
ishak jmilou.ishak
c4d2888fbf changed order 2024-12-17 14:58:31 +01:00
ishak jmilou.ishak
4307d0a8d5 test if i still get error 2024-12-17 14:57:01 +01:00
ishak jmilou.ishak
12c4e63022 test 2024-12-17 14:48:39 +01:00
ishak jmilou.ishak
9ea6ed5e2d removed in /move 2024-12-17 14:43:13 +01:00
ishak jmilou.ishak
92992288b5 returned function i removed by accident 2024-12-17 14:41:13 +01:00
ishak jmilou.ishak
ef572c6539 made function for db connection 2024-12-17 14:38:16 +01:00
ishak jmilou.ishak
10a7a2b98c add direction to db when pressed button 2024-12-17 14:08:42 +01:00
ishak jmilou.ishak
651dcbc6a5 see if connection is actually made 2024-12-17 14:01:15 +01:00
ishak jmilou.ishak
3c3f8b93db changed data i want to execute 2024-12-17 13:58:18 +01:00
ishak jmilou.ishak
d6c3383ef0 check to see if website is updated 2024-12-17 13:44:35 +01:00
ishak jmilou.ishak
df6a49bbaa test to get db info 2024-12-17 13:42:14 +01:00
ishak jmilou.ishak
c0186f935d start verslag 2024-12-17 13:37:16 +01:00
ishak jmilou.ishak
869f320446 fixed typo 2024-12-12 14:01:35 +01:00
ishak jmilou.ishak
820cb39781 changed mysql package 2024-12-12 14:00:26 +01:00
ishak jmilou.ishak
5c4a0f1e9d busy with sending command to database 2024-12-11 18:45:22 +01:00
ishak jmilou.ishak
e77aa4b2dc try to get data from database 2024-12-11 14:54:33 +01:00
ishak jmilou.ishak
b2432ab9cd removed execute to test if page works 2024-12-11 14:39:47 +01:00
ishak jmilou.ishak
93167e67f6 changed table name 2024-12-09 15:01:29 +01:00
ishak jmilou.ishak
3bb40d5929 Replace MariaDB connection with Flask-MySQLdb integration 2024-12-09 14:59:42 +01:00
ishak jmilou.ishak
9689d70104 Uncommented mariadb conn 2024-12-09 13:12:51 +01:00
ishak jmilou.ishak
01535607fc removed mariadb 2024-12-09 10:14:10 +01:00
ishak jmilou.ishak
f0637f4ba8 final etische aspecten 2024-12-09 10:13:53 +01:00
ishak jmilou.ishak
14a62c022c start van visie op etische aspecten 2024-12-07 22:11:03 +01:00
ishak jmilou.ishak
cd374dab81 rename index route to database and update response message 2024-12-05 13:40:34 +01:00
ishak jmilou.ishak
f9cb54a1cf start db connection 2024-12-04 17:46:40 +01:00
15 changed files with 572 additions and 309 deletions

View File

@@ -0,0 +1 @@
# retro sprint 4

View File

@@ -6,7 +6,10 @@ set(CMAKE_CXX_STANDARD 23)
find_library(PAHO_MQTTPP_LIBRARY paho-mqttpp3 PATHS /usr/local/lib) find_library(PAHO_MQTTPP_LIBRARY paho-mqttpp3 PATHS /usr/local/lib)
find_library(PAHO_MQTT_LIBRARY paho-mqtt3a PATHS /usr/local/lib) find_library(PAHO_MQTT_LIBRARY paho-mqtt3a PATHS /usr/local/lib)
include_directories(/usr/local/include) # Find OpenCV package
find_package(OpenCV REQUIRED)
find_package(OpenEXR REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
set(SOURCE_FILES set(SOURCE_FILES
src/KobukiDriver/KobukiParser.cpp src/KobukiDriver/KobukiParser.cpp
@@ -20,4 +23,4 @@ set(SOURCE_FILES
add_executable(kobuki_control ${SOURCE_FILES}) add_executable(kobuki_control ${SOURCE_FILES})
# Link the static libraries # Link the static libraries
target_link_libraries(kobuki_control ${PAHO_MQTTPP_LIBRARY} ${PAHO_MQTT_LIBRARY} pthread) target_link_libraries(kobuki_control ${PAHO_MQTTPP_LIBRARY} ${PAHO_MQTT_LIBRARY} ${OpenCV_LIBS} pthread OpenEXR::OpenEXR)

View File

@@ -68,7 +68,7 @@ int CKobuki::connect(char *comportT) {
HCom = open(comportT, O_RDWR | O_NOCTTY | O_NONBLOCK); HCom = open(comportT, O_RDWR | O_NOCTTY | O_NONBLOCK);
if (HCom == -1) { if (HCom == -1) {
printf("Kobuki nepripojeny\n"); printf("Kobuki connected\n");
return HCom; return HCom;
} else { } else {
set_interface_attribs2(HCom, B115200, set_interface_attribs2(HCom, B115200,
@@ -89,37 +89,40 @@ int CKobuki::connect(char *comportT) {
tcsetattr(HCom, TCSANOW, &settings); // apply the settings*/ tcsetattr(HCom, TCSANOW, &settings); // apply the settings*/
tcflush(HCom, TCOFLUSH); tcflush(HCom, TCOFLUSH);
printf("Kobuki pripojeny\n"); printf("Kobuki connected\n");
return HCom; return HCom;
} }
} }
bool CKobuki::isConnected() {
return (HCom != -1 && tcflush(HCom, TCOFLUSH) == 0);
}
unsigned char *CKobuki::readKobukiMessage() { unsigned char *CKobuki::readKobukiMessage() {
unsigned char buffer[1]; unsigned char buffer[1];
ssize_t Pocet; ssize_t Pocet;
buffer[0] = 0; buffer[0] = 0;
unsigned char *null_buffer(0); unsigned char *null_buffer(0);
// citame kym nezachytime zaciatok spravy
// Read until the start of the message is detected
do { do {
Pocet = read(HCom, buffer, 1); Pocet = read(HCom, buffer, 1);
} while (buffer[0] != 0xAA); } while (buffer[0] != 0xAA);
// mame zaciatok spravy (asi)
// We have the start of the message (possibly)
if (Pocet == 1 && buffer[0] == 0xAA) { if (Pocet == 1 && buffer[0] == 0xAA) {
// citame dalsi byte // Read the next byte
do { do {
Pocet = read(HCom, buffer, 1); Pocet = read(HCom, buffer, 1);
} while (Pocet != 1); // On Linux: -1, on Windows: 0
} while (Pocet != 1); // na linuxe -1 na windowse 0 // If it is the second byte of the header
// a ak je to druhy byte hlavicky
if (Pocet == 1 && buffer[0] == 0x55) { if (Pocet == 1 && buffer[0] == 0x55) {
// precitame dlzku // Read the length
Pocet = read(HCom, buffer, 1); Pocet = read(HCom, buffer, 1);
// ReadFile(hCom, buffer, 1, &Pocet, NULL);
if (Pocet == 1) { if (Pocet == 1) {
// mame dlzku.. nastavime vektor a precitame ho cely // We have the length; initialize a buffer and read the entire message
int readLenght = buffer[0]; int readLenght = buffer[0];
unsigned char *outputBuffer = unsigned char *outputBuffer =
(unsigned char *)calloc(readLenght + 4, sizeof(char)); (unsigned char *)calloc(readLenght + 4, sizeof(char));
@@ -134,7 +137,7 @@ unsigned char *CKobuki::readKobukiMessage() {
pct = pct + (Pocet == -1 ? 0 : Pocet); pct = pct + (Pocet == -1 ? 0 : Pocet);
} while (pct != (readLenght + 1)); } while (pct != (readLenght + 1));
// tu si mozeme ceknut co chodi zo serial intefejsu Kobukiho // Here we can check what data is received from the Kobuki's serial interface
// for(int i=0;i<outputBuffer[0]+2;i++) // for(int i=0;i<outputBuffer[0]+2;i++)
// { // {
// printf("%x ",outputBuffer[i]); // printf("%x ",outputBuffer[i]);
@@ -162,8 +165,8 @@ void CKobuki::setLed(int led1, int led2) {
pocet = write(HCom, &message, 8); pocet = write(HCom, &message, 8);
} }
// tato funkcia nema moc sama o sebe vyznam, payload o tom, ze maju byt externe // this function doesn't have much meaning by itself, the payload about them being external
// napajania aktivne musi byt aj tak v kazdej sprave... // power supplies must be active in every message anyway...
void CKobuki::setPower(int value) { void CKobuki::setPower(int value) {
if (value == 1) { if (value == 1) {
unsigned char message[8] = {0xaa, 0x55, 0x04, 0x0C, 0x02, 0xf0, 0x00, 0xAF}; unsigned char message[8] = {0xaa, 0x55, 0x04, 0x0C, 0x02, 0xf0, 0x00, 0xAF};
@@ -249,9 +252,9 @@ void CKobuki::setSound(int noteinHz, int duration) {
pocet = write(HCom, &message, 9); pocet = write(HCom, &message, 9);
} }
void CKobuki::startCommunication(char *portname, bool CommandsEnabled, bool CKobuki::startCommunication(char *portname, bool CommandsEnabled,
void *userDataL) { void *userDataL) {
connect(portname); if(connect(portname) != -1){
enableCommands(CommandsEnabled); enableCommands(CommandsEnabled);
userData = userDataL; userData = userDataL;
@@ -262,18 +265,19 @@ void CKobuki::startCommunication(char *portname, bool CommandsEnabled,
std::cerr << "Error creating thread: " << pthread_result << std::endl; std::cerr << "Error creating thread: " << pthread_result << std::endl;
} }
} }
}
int CKobuki::measure() { int CKobuki::measure() {
while (stopVlakno == 0) { while (stopVlakno == 0) {
unsigned char *message = readKobukiMessage(); unsigned char *message = readKobukiMessage();
if (message == NULL) { if (message == NULL) {
// printf("vratil null message\n"); // printf("returned null message\n");
continue; continue;
} }
int ok = parser.parseKobukiMessage(parser.data, message); int ok = parser.parseKobukiMessage(parser.data, message);
// maximalne moze trvat callback funkcia 20 ms, ak by trvala viac, nestihame // the maximum callback function can take 20 ms, if it takes longer, we won't be able to do it
// citat // read
if (ok == 0) { if (ok == 0) {
loop(userData, parser.data); loop(userData, parser.data);
} }
@@ -353,7 +357,7 @@ long CKobuki::loop(void *user_data, TKobukiData &Kobuki_data) {
totalLeft += dLeft; totalLeft += dLeft;
totalRight += dRight; totalRight += dRight;
// ak je suma novej a predchadzajucej vacsia ako 65536 tak to pretieklo? // if the sum of the new and previous is greater than 65536 then it overflowed?
directionL = (prevLeftEncoder < Kobuki_data.EncoderLeft ? 1 : -1); directionL = (prevLeftEncoder < Kobuki_data.EncoderLeft ? 1 : -1);
directionR = (prevRightEncoder < Kobuki_data.EncoderRight ? 1 : -1); directionR = (prevRightEncoder < Kobuki_data.EncoderRight ? 1 : -1);
dTimestamp = (Kobuki_data.timestamp < prevTimestamp dTimestamp = (Kobuki_data.timestamp < prevTimestamp
@@ -387,7 +391,7 @@ long CKobuki::loop(void *user_data, TKobukiData &Kobuki_data) {
// tells the kobuki to go a few meters forward or backward, the sign decides // tells the kobuki to go a few meters forward or backward, the sign decides
// the function compensates for walking straight with the controller, internally // the function compensates for walking straight with the controller, internally
// it uses setArcSpeed and uses encoder data as feedback // it uses setArcSpeed and uses encoder data as feedback
void CKobuki::goStraight(long double distance) { void CKobuki::goStraight(long double distance) {
long double u_translation = long double u_translation =
0; // controlled magnitude, speed of the robot in motion 0; // controlled magnitude, speed of the robot in motion

View File

@@ -60,7 +60,7 @@ public:
long loop(void *user_data, TKobukiData &Kobuki_data); long loop(void *user_data, TKobukiData &Kobuki_data);
void startCommunication(char *portname,bool CommandsEnabled,void *userDataL); bool startCommunication(char *portname,bool CommandsEnabled,void *userDataL);
int measure(); //thread function, contains an infinite loop and reads data int measure(); //thread function, contains an infinite loop and reads data
void setLed(int led1 = 0, int led2 = 0); //led1 green/red 2/1, //led2 green/red 2/1 void setLed(int led1 = 0, int led2 = 0); //led1 green/red 2/1, //led2 green/red 2/1
void setTranslationSpeed(int mmpersec); void setTranslationSpeed(int mmpersec);
@@ -80,6 +80,7 @@ public:
void robotSafety(); //overload void robotSafety(); //overload
void sendNullMessage(); void sendNullMessage();
bool safetyActive = false; bool safetyActive = false;
bool isConnected();
KobukiParser parser; KobukiParser parser;

View File

@@ -1,49 +1,91 @@
#include <iostream> #include <iostream>
#include <cmath> #include <cmath>
#include <thread> #include <thread>
#include "KobukiDriver/graph.h"
#include "MQTT/MqttClient.h" #include "MQTT/MqttClient.h"
#include "KobukiDriver/CKobuki.h" #include "KobukiDriver/CKobuki.h"
#include <opencv4/opencv2/opencv.hpp>
#include <opencv4/opencv2/core.hpp>
#include <thread>
using namespace std; using namespace std;
using namespace cv;
CKobuki robot; CKobuki robot;
std::string readMQTT(); std::string readMQTT();
void parseMQTT(std::string message); void parseMQTT(std::string message);
void CapnSend();
void reconnectKobuki();
void monitorKobukiConnection();
// ip, clientID, username, password // ip, clientID, username, password
MqttClient client("mqtt://145.92.224.21:1884", "KobukiRPI", "rpi", "rpiwachtwoordofzo"); // create a client object MqttClient client("ws://145.92.224.21/ws/", "KobukiRPI", "rpi",
"rpiwachtwoordofzo"); // create a client object
std::string message = "stop"; std::string message = "stop";
std::string serializeKobukiData(const TKobukiData &data); std::string serializeKobukiData(const TKobukiData &data);
void sendKobukiData(TKobukiData &data); void sendKobukiData(TKobukiData &data);
void setup() void setup() {
{
unsigned char *null_ptr(0); unsigned char *null_ptr(0);
robot.startCommunication("/dev/ttyUSB0", true, null_ptr); robot.startCommunication("/dev/ttyUSB0", true, null_ptr);
// connect mqtt server and sub to commands // connect mqtt server and sub to commands
client.connect(); client.connect();
client.subscribe("home/commands"); client.subscribe("home/commands");
} }
int main() int main() {
{
setup(); setup();
reconnectKobuki();
std::thread connectionMonitor(monitorKobukiConnection);
std::thread image(CapnSend);
std::thread safety([&]() { robot.robotSafety(&message); }); std::thread safety([&]() { robot.robotSafety(&message); });
std::thread sendMqtt([&]() { sendKobukiData(robot.parser.data); }); std::thread sendMqtt([&]() { sendKobukiData(robot.parser.data); });
while (true) { while (true) {
parseMQTT(readMQTT()); std::string message = readMQTT();
if (!message.empty()) {
parseMQTT(message);
} }
sendMqtt.join();
safety.join();
return 0;
} }
std::string readMQTT() sendMqtt.join();
{ safety.join();
message = client.getLastMessage(); image.join();
if (!message.empty()) }
{
void reconnectKobuki() {
unsigned char *null_ptr(0);
while (true) {
if (robot.startCommunication("/dev/ttyUSB0", true, null_ptr) != -1) {
std::cout << "Kobuki opnieuw verbonden!" << std::endl;
break; // Verlaat de loop als de verbinding succesvol is
} else {
std::cerr << "Kobuki niet verbonden. Probeer opnieuw over 3 seconden..." << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(3));
}
}
}
void monitorKobukiConnection() {
while (true) {
// Check regelmatig of de verbinding actief is
if (!robot.isConnected()) {
std::cerr << "Kobuki verbinding verloren. Reconnectie starten..." << std::endl;
reconnectKobuki();
}
std::this_thread::sleep_for(std::chrono::seconds(5)); // Check iedere 5 seconden
}
}
std::string readMQTT() {
static std::string lastMessage;
std::string message = client.getLastMessage();
if (!message.empty() && message != lastMessage) {
std::cout << "MQTT Message: " << message << std::endl; std::cout << "MQTT Message: " << message << std::endl;
lastMessage = message;
} }
// Add a small delay to avoid busy-waiting // Add a small delay to avoid busy-waiting
@@ -51,47 +93,32 @@ std::string readMQTT()
return message; return message;
} }
void parseMQTT(std::string message) void parseMQTT(std::string message) {
{ if (message == "up") {
if (message == "up") robot.forward(350);
{ } else if (message == "left") {
robot.forward(1024);
}
else if (message == "left")
{
robot.setRotationSpeed(4); robot.setRotationSpeed(4);
} } else if (message == "right") {
else if (message == "right")
{
robot.setRotationSpeed(-4); robot.setRotationSpeed(-4);
} } else if (message == "down") {
else if (message == "down") robot.forward(-350);
{ } else if (message == "stop") {
robot.forward(-800);
}
else if (message == "stop")
{
robot.sendNullMessage(); robot.sendNullMessage();
robot.sendNullMessage(); robot.sendNullMessage();
} } else if (message == "estop") {
else if (message == "estop")
{
robot.forward(-400); robot.forward(-400);
} } else {
else
{
std::cout << "Invalid command" << std::endl; std::cout << "Invalid command" << std::endl;
} }
} }
void logToFile() void logToFile() {
{ while (true) {
while (true)
{
TKobukiData robotData = robot.parser.data; TKobukiData robotData = robot.parser.data;
std::ofstream outputFile("log", std::ios_base::app); // Open file in append mode to not overwrite own content std::ofstream outputFile("log",
if (outputFile.is_open()) std::ios_base::app); // Open file in append mode to
{ // check if the file was opened successfully // not overwrite own content
if (outputFile.is_open()) { // check if the file was opened successfully
// Get current time // Get current time
std::time_t now = std::time(nullptr); std::time_t now = std::time(nullptr);
outputFile << "Timestamp: " << std::ctime(&now); outputFile << "Timestamp: " << std::ctime(&now);
@@ -126,24 +153,30 @@ void logToFile()
outputFile << "GyroAngle: " << robotData.GyroAngle << "\n"; outputFile << "GyroAngle: " << robotData.GyroAngle << "\n";
outputFile << "GyroAngleRate: " << robotData.GyroAngleRate << "\n"; outputFile << "GyroAngleRate: " << robotData.GyroAngleRate << "\n";
outputFile << "CliffSensorRight: " << robotData.CliffSensorRight << "\n"; outputFile << "CliffSensorRight: " << robotData.CliffSensorRight << "\n";
outputFile << "CliffSensorCenter: " << robotData.CliffSensorCenter << "\n"; outputFile << "CliffSensorCenter: " << robotData.CliffSensorCenter
<< "\n";
outputFile << "CliffSensorLeft: " << robotData.CliffSensorLeft << "\n"; outputFile << "CliffSensorLeft: " << robotData.CliffSensorLeft << "\n";
outputFile << "wheelCurrentLeft: " << robotData.wheelCurrentLeft << "\n"; outputFile << "wheelCurrentLeft: " << robotData.wheelCurrentLeft << "\n";
outputFile << "wheelCurrentRight: " << robotData.wheelCurrentRight << "\n"; outputFile << "wheelCurrentRight: " << robotData.wheelCurrentRight
<< "\n";
outputFile << "frameId: " << robotData.frameId << "\n"; outputFile << "frameId: " << robotData.frameId << "\n";
outputFile << "HardwareVersionPatch: " << robotData.extraInfo.HardwareVersionPatch << "\n"; outputFile << "HardwareVersionPatch: "
outputFile << "HardwareVersionMinor: " << robotData.extraInfo.HardwareVersionMinor << "\n"; << robotData.extraInfo.HardwareVersionPatch << "\n";
outputFile << "HardwareVersionMajor: " << robotData.extraInfo.HardwareVersionMajor << "\n"; outputFile << "HardwareVersionMinor: "
outputFile << "FirmwareVersionPatch: " << robotData.extraInfo.FirmwareVersionPatch << "\n"; << robotData.extraInfo.HardwareVersionMinor << "\n";
outputFile << "FirmwareVersionMinor: " << robotData.extraInfo.FirmwareVersionMinor << "\n"; outputFile << "HardwareVersionMajor: "
outputFile << "FirmwareVersionMajor: " << robotData.extraInfo.FirmwareVersionMajor << "\n"; << robotData.extraInfo.HardwareVersionMajor << "\n";
outputFile << "FirmwareVersionPatch: "
<< robotData.extraInfo.FirmwareVersionPatch << "\n";
outputFile << "FirmwareVersionMinor: "
<< robotData.extraInfo.FirmwareVersionMinor << "\n";
outputFile << "FirmwareVersionMajor: "
<< robotData.extraInfo.FirmwareVersionMajor << "\n";
outputFile << "UDID0: " << robotData.extraInfo.UDID0 << "\n"; outputFile << "UDID0: " << robotData.extraInfo.UDID0 << "\n";
outputFile << "UDID1: " << robotData.extraInfo.UDID1 << "\n"; outputFile << "UDID1: " << robotData.extraInfo.UDID1 << "\n";
outputFile << "UDID2: " << robotData.extraInfo.UDID2 << "\n"; outputFile << "UDID2: " << robotData.extraInfo.UDID2 << "\n";
outputFile.close(); outputFile.close();
} } else {
else
{
std::cerr << "Error opening file\n"; std::cerr << "Error opening file\n";
} }
@@ -153,56 +186,101 @@ void logToFile()
void sendIndividualKobukiData(const TKobukiData &data) { void sendIndividualKobukiData(const TKobukiData &data) {
while (true) { while (true) {
client.publishMessage("kobuki/data/timestamp", std::to_string(data.timestamp)); std::cout << "Kobuki Data wordt gepubliceerd naar kobuki/data/timestamp: "
client.publishMessage("kobuki/data/BumperCenter", std::to_string(data.BumperCenter)); << data.timestamp << std::endl;
client.publishMessage("kobuki/data/BumperLeft", std::to_string(data.BumperLeft)); client.publishMessage("kobuki/data/timestamp",
client.publishMessage("kobuki/data/BumperRight", std::to_string(data.BumperRight)); std::to_string(data.timestamp));
client.publishMessage("kobuki/data/WheelDropLeft", std::to_string(data.WheelDropLeft)); client.publishMessage("kobuki/data/BumperCenter",
client.publishMessage("kobuki/data/WheelDropRight", std::to_string(data.WheelDropRight)); std::to_string(data.BumperCenter));
client.publishMessage("kobuki/data/CliffCenter", std::to_string(data.CliffCenter)); client.publishMessage("kobuki/data/BumperLeft",
client.publishMessage("kobuki/data/CliffLeft", std::to_string(data.CliffLeft)); std::to_string(data.BumperLeft));
client.publishMessage("kobuki/data/CliffRight", std::to_string(data.CliffRight)); client.publishMessage("kobuki/data/BumperRight",
client.publishMessage("kobuki/data/EncoderLeft", std::to_string(data.EncoderLeft)); std::to_string(data.BumperRight));
client.publishMessage("kobuki/data/EncoderRight", std::to_string(data.EncoderRight)); 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/PWMleft", std::to_string(data.PWMleft));
client.publishMessage("kobuki/data/PWMright", std::to_string(data.PWMright)); client.publishMessage("kobuki/data/PWMright",
client.publishMessage("kobuki/data/ButtonPress1", std::to_string(data.ButtonPress1)); std::to_string(data.PWMright));
client.publishMessage("kobuki/data/ButtonPress2", std::to_string(data.ButtonPress2)); client.publishMessage("kobuki/data/ButtonPress1",
client.publishMessage("kobuki/data/ButtonPress3", std::to_string(data.ButtonPress3)); 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/Charger", std::to_string(data.Charger));
client.publishMessage("kobuki/data/Battery", std::to_string(data.Battery)); client.publishMessage("kobuki/data/Battery", std::to_string(data.Battery));
client.publishMessage("kobuki/data/overCurrent", std::to_string(data.overCurrent)); client.publishMessage("kobuki/data/overCurrent",
client.publishMessage("kobuki/data/IRSensorRight", std::to_string(data.IRSensorRight)); std::to_string(data.overCurrent));
client.publishMessage("kobuki/data/IRSensorCenter", std::to_string(data.IRSensorCenter)); client.publishMessage("kobuki/data/IRSensorRight",
client.publishMessage("kobuki/data/IRSensorLeft", std::to_string(data.IRSensorLeft)); std::to_string(data.IRSensorRight));
client.publishMessage("kobuki/data/GyroAngle", std::to_string(data.GyroAngle)); client.publishMessage("kobuki/data/IRSensorCenter",
client.publishMessage("kobuki/data/GyroAngleRate", std::to_string(data.GyroAngleRate)); std::to_string(data.IRSensorCenter));
client.publishMessage("kobuki/data/CliffSensorRight", std::to_string(data.CliffSensorRight)); client.publishMessage("kobuki/data/IRSensorLeft",
client.publishMessage("kobuki/data/CliffSensorCenter", std::to_string(data.CliffSensorCenter)); std::to_string(data.IRSensorLeft));
client.publishMessage("kobuki/data/CliffSensorLeft", std::to_string(data.CliffSensorLeft)); client.publishMessage("kobuki/data/GyroAngle",
client.publishMessage("kobuki/data/wheelCurrentLeft", std::to_string(data.wheelCurrentLeft)); std::to_string(data.GyroAngle));
client.publishMessage("kobuki/data/wheelCurrentRight", std::to_string(data.wheelCurrentRight)); client.publishMessage("kobuki/data/GyroAngleRate",
client.publishMessage("kobuki/data/digitalInput", std::to_string(data.digitalInput)); std::to_string(data.GyroAngleRate));
client.publishMessage("kobuki/data/analogInputCh0", std::to_string(data.analogInputCh0)); client.publishMessage("kobuki/data/CliffSensorRight",
client.publishMessage("kobuki/data/analogInputCh1", std::to_string(data.analogInputCh1)); std::to_string(data.CliffSensorRight));
client.publishMessage("kobuki/data/analogInputCh2", std::to_string(data.analogInputCh2)); client.publishMessage("kobuki/data/CliffSensorCenter",
client.publishMessage("kobuki/data/analogInputCh3", std::to_string(data.analogInputCh3)); 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/frameId", std::to_string(data.frameId));
client.publishMessage("kobuki/data/extraInfo/HardwareVersionPatch", std::to_string(data.extraInfo.HardwareVersionPatch)); client.publishMessage("kobuki/data/extraInfo/HardwareVersionPatch",
client.publishMessage("kobuki/data/extraInfo/HardwareVersionMinor", std::to_string(data.extraInfo.HardwareVersionMinor)); std::to_string(data.extraInfo.HardwareVersionPatch));
client.publishMessage("kobuki/data/extraInfo/HardwareVersionMajor", std::to_string(data.extraInfo.HardwareVersionMajor)); client.publishMessage("kobuki/data/extraInfo/HardwareVersionMinor",
client.publishMessage("kobuki/data/extraInfo/FirmwareVersionPatch", std::to_string(data.extraInfo.FirmwareVersionPatch)); std::to_string(data.extraInfo.HardwareVersionMinor));
client.publishMessage("kobuki/data/extraInfo/FirmwareVersionMinor", std::to_string(data.extraInfo.FirmwareVersionMinor)); client.publishMessage("kobuki/data/extraInfo/HardwareVersionMajor",
client.publishMessage("kobuki/data/extraInfo/FirmwareVersionMajor", std::to_string(data.extraInfo.FirmwareVersionMajor)); std::to_string(data.extraInfo.HardwareVersionMajor));
client.publishMessage("kobuki/data/extraInfo/UDID0", std::to_string(data.extraInfo.UDID0)); client.publishMessage("kobuki/data/extraInfo/FirmwareVersionPatch",
client.publishMessage("kobuki/data/extraInfo/UDID1", std::to_string(data.extraInfo.UDID1)); std::to_string(data.extraInfo.FirmwareVersionPatch));
client.publishMessage("kobuki/data/extraInfo/UDID2", std::to_string(data.extraInfo.UDID2)); 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()) { if (!data.gyroData.empty()) {
const auto &latestGyro = data.gyroData.back(); const auto &latestGyro = data.gyroData.back();
client.publishMessage("kobuki/data/gyroData/x", std::to_string(latestGyro.x)); client.publishMessage("kobuki/data/gyroData/x",
client.publishMessage("kobuki/data/gyroData/y", std::to_string(latestGyro.y)); std::to_string(latestGyro.x));
client.publishMessage("kobuki/data/gyroData/z", std::to_string(latestGyro.z)); 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::this_thread::sleep_for(std::chrono::milliseconds(1000));
@@ -210,7 +288,8 @@ void sendIndividualKobukiData(const TKobukiData &data) {
} }
std::string serializeKobukiData(const TKobukiData &data) { std::string serializeKobukiData(const TKobukiData &data) {
std::string json = "{\"timestamp\":" + std::to_string(data.timestamp) + std::string json =
"{\"timestamp\":" + std::to_string(data.timestamp) +
",\"BumperCenter\":" + std::to_string(data.BumperCenter) + ",\"BumperCenter\":" + std::to_string(data.BumperCenter) +
",\"BumperLeft\":" + std::to_string(data.BumperLeft) + ",\"BumperLeft\":" + std::to_string(data.BumperLeft) +
",\"BumperRight\":" + std::to_string(data.BumperRight) + ",\"BumperRight\":" + std::to_string(data.BumperRight) +
@@ -245,12 +324,18 @@ std::string serializeKobukiData(const TKobukiData &data) {
",\"analogInputCh2\":" + std::to_string(data.analogInputCh2) + ",\"analogInputCh2\":" + std::to_string(data.analogInputCh2) +
",\"analogInputCh3\":" + std::to_string(data.analogInputCh3) + ",\"analogInputCh3\":" + std::to_string(data.analogInputCh3) +
",\"frameId\":" + std::to_string(data.frameId) + ",\"frameId\":" + std::to_string(data.frameId) +
",\"extraInfo\":{\"HardwareVersionPatch\":" + std::to_string(data.extraInfo.HardwareVersionPatch) + ",\"extraInfo\":{\"HardwareVersionPatch\":" +
",\"HardwareVersionMinor\":" + std::to_string(data.extraInfo.HardwareVersionMinor) + std::to_string(data.extraInfo.HardwareVersionPatch) +
",\"HardwareVersionMajor\":" + std::to_string(data.extraInfo.HardwareVersionMajor) + ",\"HardwareVersionMinor\":" +
",\"FirmwareVersionPatch\":" + std::to_string(data.extraInfo.FirmwareVersionPatch) + std::to_string(data.extraInfo.HardwareVersionMinor) +
",\"FirmwareVersionMinor\":" + std::to_string(data.extraInfo.FirmwareVersionMinor) + ",\"HardwareVersionMajor\":" +
",\"FirmwareVersionMajor\":" + std::to_string(data.extraInfo.FirmwareVersionMajor) + 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) + ",\"UDID0\":" + std::to_string(data.extraInfo.UDID0) +
",\"UDID1\":" + std::to_string(data.extraInfo.UDID1) + ",\"UDID1\":" + std::to_string(data.extraInfo.UDID1) +
",\"UDID2\":" + std::to_string(data.extraInfo.UDID2) + "},\"gyroData\":["; ",\"UDID2\":" + std::to_string(data.extraInfo.UDID2) + "},\"gyroData\":[";
@@ -270,6 +355,36 @@ std::string serializeKobukiData(const TKobukiData &data) {
void sendKobukiData(TKobukiData &data) { void sendKobukiData(TKobukiData &data) {
while (true) { while (true) {
client.publishMessage("kobuki/data", serializeKobukiData(data)); client.publishMessage("kobuki/data", serializeKobukiData(data));
std::cout << "Sent data" << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(1000)); 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
}
}

View File

@@ -1,27 +1,52 @@
from flask import Flask, request, render_template, jsonify from flask import Flask, request, render_template, jsonify, g
import paho.mqtt.client as mqtt import paho.mqtt.client as mqtt
import mysql.connector
app = Flask(__name__) app = Flask(__name__)
kobuki_message = "empty" # Globale variabelen
def on_message(client, userdata, message): kobuki_message = ""
global kobuki_message #set scope for this variable latest_image = None
# Globale MQTT setup
def on_message(client, message):
global kobuki_message, latest_image
if message.topic == "kobuki/data":
kobuki_message = str(message.payload.decode("utf-8")) kobuki_message = str(message.payload.decode("utf-8"))
print(kobuki_message) elif message.topic == "kobuki/cam":
latest_image = message.payload
# Create an MQTT client instance # Create an MQTT client instance
mqtt_client = mqtt.Client() mqtt_client = mqtt.Client()
mqtt_client.username_pw_set("server", "serverwachtwoordofzo") mqtt_client.username_pw_set("server", "serverwachtwoordofzo")
mqtt_client.connect("localhost", 80, 60) mqtt_client.connect("localhost", 1884, 60)
mqtt_client.loop_start() mqtt_client.loop_start()
mqtt_client.subscribe("kobuki/data") mqtt_client.subscribe("kobuki/data")
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
# Database connectie-functie
def get_db():
if 'db' not in g: # 'g' is specifiek voor een request en leeft zolang een request duurt
g.db = mysql.connector.connect(
host="127.0.0.1",
port=3306,
user="admin",
password="kobuki",
database="kobuki"
)
return g.db
# Sluit de database na elke request
@app.teardown_appcontext
def close_db(error):
db = g.pop('db', None)
if db is not None:
db.close()
@app.route('/') @app.route('/')
def index(): def index():
return render_template('index.html') return render_template('index.html')
@app.route('/control', methods=["GET", "POST"]) @app.route('/control', methods=["GET", "POST"])
def control(): def control():
if request.authorization and request.authorization.username == 'ishak' and request.authorization.password == 'kobuki': if request.authorization and request.authorization.username == 'ishak' and request.authorization.password == 'kobuki':
@@ -36,21 +61,31 @@ def move():
# Verstuur de richting via MQTT # Verstuur de richting via MQTT
if direction: if direction:
mqtt_client.publish("home/commands", direction) # Het topic kan aangepast worden mqtt_client.publish("home/commands", direction)
db_connection = get_db()
cursor = db_connection.cursor()
sql = "INSERT INTO command (command) VALUES (%s)"
value = direction
cursor.execute(sql, (value,))
db_connection.commit()
cursor.close()
db_connection.close()
return jsonify({"status": "success", "direction": direction}) return jsonify({"status": "success", "direction": direction})
@app.route('/data', methods=['GET']) @app.route('/data', methods=['GET'])
def data(): def data():
return kobuki_message return jsonify(kobuki_message)
@app.route('/phpmyadmin/<path:path>')
def phpmyadmin_passthrough(path):
# Laat Apache deze route direct afhandelen
return "", 404
@app.route("/database")
def database():
db = get_db()
cursor = db.cursor()
cursor.execute("SELECT * FROM kobuki_data")
rows = cursor.fetchall()
cursor.close()
return str(rows)
if __name__ == '__main__': if __name__ == '__main__':
app.run(debug=True, port=5000) app.run(debug=True, port=5000)

View File

@@ -1,26 +1,23 @@
// Selecteer alle knoppen en voeg een event listener toe aan elke knop
document.querySelectorAll(".btn").forEach(button => { document.querySelectorAll(".btn").forEach(button => {
button.addEventListener("click", function(event) { button.addEventListener("click", async function(event) { // Maak de functie async
event.preventDefault(); // voorkomt pagina-verversing event.preventDefault(); // voorkomt pagina-verversing
// Haal de waarde van de knop op // Haal de waarde van de knop op
const direction = event.target.value; const direction = event.target.value;
fetch("/move", { try {
const response = await fetch("/move", {
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json" "Content-Type": "application/json"
}, },
body: JSON.stringify({ direction: direction }) body: JSON.stringify({ direction: direction })
}) });
.then(response => response.json()) const data = await response.json();
.then(data => {
console.log("Success:", data); console.log("Success:", data);
}) } catch (error) {
.catch(error => {
console.error("Error:", error); console.error("Error:", error);
}); }
});
// Fetch data from the server // Fetch data from the server
async function fetchData() { async function fetchData() {
@@ -30,7 +27,6 @@ document.querySelectorAll(".btn").forEach(button => {
} }
// Parse the data and show it on the website // Parse the data and show it on the website
async function parseData() {
const data = await fetchData(); const data = await fetchData();
const sensorDataContainer = document.getElementById("sensor-data"); const sensorDataContainer = document.getElementById("sensor-data");
sensorDataContainer.innerHTML = ""; // Clear previous data sensorDataContainer.innerHTML = ""; // Clear previous data
@@ -38,10 +34,8 @@ document.querySelectorAll(".btn").forEach(button => {
for (const [key, value] of Object.entries(data)) { for (const [key, value] of Object.entries(data)) {
const dataElement = document.createElement("p"); const dataElement = document.createElement("p");
dataElement.textContent = `${key}: ${value}`; dataElement.textContent = `${key}: ${value}`;
sensorDataContainer.appendChild(dataElement); sensorDataContainer.appendChild(dataElement); // Voeg het element toe aan de container
} }
}
// Fetch and display sensor data every 5 seconds
setInterval(parseData, 5000);
}); });
});

View File

@@ -12,7 +12,7 @@
<body> <body>
<div class="container"> <div class="container">
<div class="image-section"> <div class="image-section">
<img src="kobuki.jpg" alt="Kobuki Robot" id="robot-image" /> <!-- <img src="kobuki.jpg" alt="Kobuki Robot" id="robot-image" /> -->
</div> </div>
<div class="button-section"> <div class="button-section">
<form id="form" action="/move" method="post"> <form id="form" action="/move" method="post">

View File

@@ -0,0 +1,25 @@
# Etische aspecten van het project
## Visie op de ethische aspecten van het Kobuki-project
Etische aspecten zijn heel belangrijk in het project, al ben ik wel van mening dat je niet alles kan voorkomen en ook kan waarborgen.
## Privacy
Als je bijvoorbeeld kijkt naar het gedeelte privacy, dan is het heel moeilijk om te kijken wat je gaat doen met die gegevens. Ik ga een camera gebruiken op de robot om zo te kijken
waar de robot is en wat hij allemaal ziet. Als de robot in een brandende huis komt en dan een persoon ziet, is het wel belangrijk om die persoon goed te kunnen zien. Je zou dan niet kunnen zeggen dat je die persoon bijvoorbeeld moet vervagen, want je moet wel kunnen zien wat de status is van die persoon.
Ook is het dan belangrijk om te kijken wat je met die gegevens gaat doen, ga je ze opslaan voor eventuele later gebruik of verwijder je ze direct. Het is heel lastig te bepalen wanneer je op zo een moment privacy schendt.
## Betrouwbaarheid
Ik vind dat je de betrouwbaarheid van de robot wel moet waarborgen,
want als ik de robot in een brandend huis stuur en hij valt uit, dan kan dat heel gevaarlijk zijn voor de persoon die in dat huis zit. Daar vind ik dat je meer rekening mee moet houden dan met de privacy van de persoon. Het is de bedoeling dat de robot hulpmedewerkers gaat helpen en niet hun werk moeilijker maakt.
## Impact op hulpverleners & maatschappij
Als meerdere hulpmedewerkers de robot gaan gebruiken en het word een soort van standaard, dan is het wel belangrijk dat de robot betrouwbaar is en dat je erop kan vertrouwen. Het gaat immers om mensenlevens en dat is wel het belangrijkste. Het is uiteindelijk de bedoeling dat de robot hulpverleners zal helpen en niet hun werk lastiger moet maken. Als de robot een standaard hulpmiddel wordt moet hij wel gebruiksvriendelijk zijn en goed kunnen helpen. De robot moet ook zo goed mogelijk werken om zo de vertrouwen te behouden van de mensen. Als de robot fouten blijft maken en niet betrouwbaar is zullen minder mensen het gebruiken. Ik vind dan ook dat de gebruik van de robot heel transparant moet zijn. Hoe word de robot aangestuurd, hoe vergelijkt hij situaties en hoe hij daarmee omgaat.
Als je daar al heel duidelijk in bent bouw je al wat sneller vertrouwen van de mensen op.
Ik vind dat in dit project de ethische aspecten heel belangrijk zijn en dat je daar ook rekening mee moet houden.
Bij betrouwbaarheid en de impact die de robot kan hebben op de maatschappij en de hulpverleners moet je wel goed over nadenken.
Je werkt immers met mensenlevens en dat is wel het belangrijkste. Privacy is ook heel belangrijk, maar ik vind dat je daar wel wat soepeler mee om kan gaan.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -0,0 +1,21 @@
Motivation Letter
16/12/2024
Cognizant Digital StudioAttn. Hayo Rubingh
Subject: Internship Application Cognizant Digital Studio
Dear Mr. Rubingh,
With great enthusiasm, I am applying for the internship position at Cognizant Digital Studio in Amsterdam. As a second-year bachelors student in Technische Informatica(Computer Science) at Hogeschool Van Amsterdam, I am seeking a challenging internship where I can combine my technical skills with my passion for innovation. Cognizants focus IoT, and technology prototypes fits perfectly with my interests .
Throughout my studies, I have gained experience in software development, including Python and JavaScript, and have worked with IoT devices such as Arduino/ESP. What drives me is the opportunity to create and develop new solutions that can make life easier and more efficient. I am particularly interested in the field of IoT and the possibilities it offers for creating smart solutions. I am eager to learn more about the latest technologies and how they can be applied in real-world projects.
I am available to start in February 2025 and look forward to contributing to innovative projects.
I would be delighted to discuss my motivation and experience further in a personal interview. You can find my contact details in my CV. Thank you for considering my application. I am looking forward to hearing from you.
Yours sincerely,
Ishak Jmilou

View File

@@ -0,0 +1,64 @@
![alt text](images/image.png)
# Welke communicatieprotocol geeft de mogelijkheid om veilig en betrouwbaar te communiceren tussen IoT apparaten?
Auteur: Ishak Jmilou
Datum: 17-12-2024
---
## Inleiding
In dit verslag wordt er gekeken naar de verschillende communicatieprotocollen die gebruikt kunnen worden om veilig en betrouwbaar te communiceren tussen IoT apparaten. Er wordt gekeken naar de verschillende protocollen en de voor- en nadelen van elk protocol.
---
# Samenvatting
In dit verslag worden de communicatieprotocollen MQTT, HTTP, WebSockets en CoAP vergeleken op het gebied van veilige en betrouwbare communicatie tussen IoT-apparaten. Veilige communicatie omvat gegevensversleuteling en authenticatie, terwijl betrouwbaarheid verwijst naar het verzenden en ontvangen van gegevens zonder verlies. Op basis van deze overwegingen wordt MQTT aanbevolen voor situaties waar zowel veiligheid als betrouwbaarheid cruciaal zijn in IoT-communicatie.
## 1. Wat houdt veilige en betrouwbare communicatie tussen apparaten in?
Als je werkt met IoT-apparaten, is het belangrijk dat de communicatie tussen deze apparaten veilig en betrouwbaar is. Iot-apparaten verzamelen gegevens over de omgeving en communiceert deze tussen apparaten over het internet. Als deze communicatie niet veilig is, kunnen hackers deze gegevens onderscheppen en gebruiken(Ministerie van Algemene Zaken, 2022). Je wilt voorkomen dat hackers toegang krijgen tot gevoelige informatie zoals persoonlijke gegevens of bedrijfsgeheimen. Daarom is het belangrijk dat de communicatie tussen apparaten veilig en betrouwbaar is. Een protocol is een set regels die bepalen hoe apparaten met elkaar communiceren. Er zijn verschillende protocollen die gebruikt kunnen worden om veilig en betrouwbaar te communiceren tussen IoT-apparaten.
## 2. Welke protocollen zijn er om veilig en betrouwbaar te communiceren tussen apparaten?
Een communicatieprotocol is een set regels die bepalen hoe apparaten met elkaar communiceren(Paul Christiano, 2023). Er is voor elk project een ander protocol dat het beste past. In dit geval is het belangrijk dat de communicatie veilig en betrouwbaar is. De protocollen die ik ga vergelijken zijn MQTT, HTTP, WebSockets en CoAP. Wat belangrijk is om te onderzoeken is hoe de protocollen omgaan met veiligheid en betrouwbaarheid. Veiligheid kan worden bereikt door gegevens te versleutelen en te authenticeren. Betrouwbaarheid kan worden bereikt door gegevens te verzenden en te ontvangen zonder verlies.(Paul Christiano, 2023).
## 3. Wat zijn de voor- en nadelen van de verschillende protocollen?
![alt text](image.png)
Zoals te zien is in de tabel is CoAP minder betrouwbaar dan de andere protocollen. Dit komt, omdat CoAP gebruik maakt van UDP wat ervoor zorgt dat het sneller is maar niet betrouwbaar met de berichten die hij stuurt(Darek Fanton, 2023). Websockets is een goede protocol alleen is het niet altijd geschikt voor lichtgewicht apparaten. HTTP maakt gebruik van TCP wat betrouwbaar is, maar het nadeel van HTTP is dat het elke keer een nieuwe verbinding moet maken. Dit kan een probleem zijn als je veel berichten moet versturen. MQTT is een lichtgewicht protocol dat betrouwbaar is en verschillende niveaus van kwaliteit van de berichten ondersteunt. Het is ook mogelijk om gegevens te versleutelen en te authenticeren met MQTT. Dit maakt het een goede keuze voor veilige en betrouwbare communicatie tussen IoT-apparaten.
## 4. Conclusie
Er zijn verschillende protocollen die goed gebruikt kunnen worden voor IoT apparaten. Aangezien voor mijn project veiligheid en betrouwbaarheid op één staat heb ik gekozen voor MQTT. Dit protocol is lichtgewicht, betrouwbaar en ondersteunt verschillende niveaus van kwaliteit van de berichten. Het is ook mogelijk om gegevens te versleutelen en te authenticeren met MQTT. Dit maakt het een goede keuze voor veilige en betrouwbare communicatie tussen IoT-apparaten.
## literatuurlijst
- 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. 1731) [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. 14971516) [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
- Darek Fanton(2024, Juli 11). 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
- Ministerie van Algemene Zaken. (2022, February 8). Hoe kan ik slimme apparaten veilig gebruiken? Rijksoverheid.nl. https://www.rijksoverheid.nl/onderwerpen/bescherming-van-consumenten/vraag-en-antwoord/hoe-kan-ik-slimme-apparaten-veilig-gebruiken

Binary file not shown.