27 Commits

Author SHA1 Message Date
a46900dfd2 Merge branch 'test_script_movement' 2024-10-31 21:51:04 +01:00
2919e20970 update gitignore 2024-10-31 21:49:17 +01:00
ishak jmilou.ishak
c4a694e601 moved venv to the .gitignore 2024-10-24 14:07:11 +02:00
d78389992e added a comment 2024-10-22 15:33:19 +02:00
7fa04a5c35 made it so we can read indiviual buttons 2024-10-22 15:10:08 +02:00
1175444abf edited cmakelist 2024-10-21 13:09:46 +02:00
79f21f8755 testing 2024-10-21 12:34:03 +02:00
9935375a5a comment 2024-10-21 10:41:57 +02:00
d41e6432b3 fixed safety of robot and that it always drives when its told to drive 2024-10-21 10:41:48 +02:00
b5f5491222 attempt to make function so robot doenst throw itself from a cliff 2024-10-20 17:35:55 +02:00
856d60eea2 Junk removal 2024-10-18 16:22:47 +02:00
6a0024ebb8 rotation sort of works now 2024-10-16 16:43:24 +02:00
0011096977 INfrastructure update 2024-10-14 14:34:45 +02:00
5ead72c47e uitleg welke sensoren gebruiken en waarom 2024-10-14 13:57:48 +02:00
ishak jmilou.ishak
216b28d27c added template user and learning story 2024-10-14 12:10:03 +02:00
b5e619ac0a attempt to make robot rotate 2024-10-09 14:24:23 +02:00
c38491ce20 added to parser so we can read raw sensordata from cliffsensor (thanks anwar) 2024-10-08 15:05:41 +02:00
c9d128ecd1 todo commnets from ferry at expert review 2024-10-08 14:27:38 +02:00
Mees Roelofsz
927126a797 Merge branch 'main' of ssh://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79 2024-10-08 13:53:27 +02:00
Mees Roelofsz
6235af77b9 changed word 2024-10-08 13:53:25 +02:00
9a4cd473a6 added and fixed logger 2024-10-08 13:29:24 +02:00
Mees Roelofsz
acd4b9589c To Be Determined 2024-10-08 13:13:27 +02:00
Mees Roelofsz
c129ae4980 added more tabs 2024-10-08 13:09:45 +02:00
Mees Roelofsz
cdbb538238 decision written out 2024-10-08 13:05:34 +02:00
Mees Roelofsz
26cc0e2041 finished brainstorm 2024-10-08 12:59:34 +02:00
2bee0ffc25 fix nonsense errors 2024-10-08 12:53:22 +02:00
cede3689f4 cleanup and logger creation 2024-10-08 12:39:31 +02:00
10 changed files with 279 additions and 153 deletions

7
.gitignore vendored
View File

@@ -16,6 +16,13 @@ src/C++/Driver/Makefile
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/

View File

@@ -0,0 +1,21 @@
```
Inleiding van de learning story:
Vul hier een korte beschrijving in van de learning story.
Probeer dit direct te koppelen aan het project wat studenten gaan doen.
```
**Wat ga ik leren?**
```
Zet hier een overzicht van de vaardigheden die een student gaat leren.
Als de student alle vinkjes heeft afgevinkt, dan hebben ze dit onderwerp goed begrepen.
```
- [ ] <- Maak op deze manier afvinklijstjes
**Hoe ga ik dit leren?**
```
Zet hier de bronnenlijst.
```
- [ ] <- Maak op deze manier afvinklijstjes

View File

@@ -0,0 +1,32 @@
Als gebruiker wil ik ..., zodat ... (verwijder deze regel, plaats de tekst in de titel)
[beschrijving van de user story en context]
**Taken**
Deze user story is opgedeeld in een aantal taken. Vul onderstaande lijst zelf aan.
- [ ] Taak 1.
- [ ] Taak 2.
- [ ] ...
**Acceptatie criteria**
Acceptatie criteria zijn specifieke eisen waaraan de User Story moet voldoen. Deze zijn meestal uniek per User Story.
- [ ] Acceptatiecriterium 1
- [ ] Acceptatiecriterium 2
- [ ] ...
**Definition of Done**
- [ ] Alle acceptatiecriteria van de user story zijn afgevinkt.
- [ ] 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.

View File

@@ -2,35 +2,51 @@
```mermaid
classDiagram
Apache <--> Flask
Flask <--> MariaDB
ESP32 --> RPI : Wired communication
RPI <--> Wireguard : MQTT with a VPN connection
Wireguard <--> Flask
VirtualMachine <--> RPI
Kobuki <--> RPI
namespace Server {
class VirtualMachine {
+Apache()
+Flask()
+SocketServer()
+MariaDB()
Python/C++
Database
Website
class Wireguard {
+VPN()
}
class Apache {
+ReverseProxy()
}
class MariaDB {
+Database()
}
class Flask {
Python
+Webserver()
+endpoints communication()
}
}
namespace robot {
class RPI {
Receiver
Sensors
C++
+SocketClient()
+Kobuki()
}
namespace Kobuki {
class RPI {
+KobukiCommunication()
+ESP32Communication()
C++
}
class Kobuki {
+data
}
class ESP32 {
+TVOC()
+ECO2()
+Temperature()
+LDR()
+Camera()
+GPS()
+ToF()
}
}
```
```

View File

@@ -22,3 +22,32 @@ The ideas we came up with where:
- A mobile scarecrow that will ride around a farm scaring birds, checking for optimal growing conditions using sensors, and checking (and possibly fighting) pests.
- A robot that would be sent into buildings with a gasleak and check where the leak is the strongest and thus where it would most likely be coming from. (also possible lighting mechanic for controlled explosions in case of preventable disasters without loss of a human life)
- A mobile fire extinguisher placed in buildings or terrains that are prone to fires. The robot would be able to detect fires and extinguish them before they get out of hand. Or control the fire before the fire department arrives.
- A mobile solar panel that moves to the spot with the harshest sunlight (without a certain area). After which it would plug itself into a battery and charge it. This battery could then be used to power a building or a car.
- A robot that is dropped in dangerous environments to scout the area and report back to the people who sent it. This could be used in warzones, dangerous buildings, or other dangerous environments.
It scouts for stuff in the air using air sensors, it scouts for stuff on the ground using cameras, and it scouts for possible hazards like fire using infrared and other sensors.
### Decision
In the end we decided to go with the final idea. This was partially due to the fact that it merges some of the most interresting aspect of the other ideas. We think that this is the most fitting with our goal oof minimizing the loss of human life because it can be used in not just fires or gasleaks but also in warzones and other dangerous environments. This makes it so that it has way more usecases than the other ideas and the buyer has enough with just these robots to cover a lot of dangerous situations.
## Realization & Plan
### Hardware
#### Sensors
placeholder
#### IC's
placeholder
#### Motors
placeholder
#### Batteries
placeholder
### Software

View File

@@ -0,0 +1,33 @@
# Wat gaan we maken
## Sensoren
* Camera
* GPS module
* Temparatuur sensor
* TVOC sensor
* ECO2 sensor
* LDR sensor
* Time of Flight sensor
## 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
realiseren van een verkenningsrobot die zelfstandig een gevaarlijke omgeving in kaart kan brengen.

View File

@@ -12,7 +12,7 @@
////*************************************************************************************
#ifndef KOBUKI_CLASS_123456789
#define KOBUKI_CLASS_123456789
#define PI 3.141592653589793238462643383279502884L /* pi */
#define PI 3.141592653589793238462643383279502884L /* pi */
#define MS_INSTRUCTION_DELAY 25
#include <stdio.h>
@@ -35,91 +35,6 @@
using namespace std;
// typedef struct
// {
// unsigned short x;
// unsigned short y;
// unsigned short z;
// }TRawGyroData;
// typedef struct
// {
// //Hardware Version
// unsigned char HardwareVersionMajor;
// unsigned char HardwareVersionMinor;
// unsigned char HardwareVersionPatch;
// //Firmware Version
// unsigned char FirmwareVersionMajor;
// unsigned char FirmwareVersionMinor;
// unsigned char FirmwareVersionPatch;
// //Unique Device IDentifier(UDID)
// unsigned int UDID0;
// unsigned int UDID1;
// unsigned int UDID2;
// //Controller Info
// unsigned char PIDtype;
// unsigned int PIDgainP;
// unsigned int PIDgainI;
// unsigned int PIDgainD;
// }TExtraRequestData;
// typedef struct
// {
// //---basic package
// unsigned short timestamp;
// //bumpers
// bool BumperLeft;
// bool BumperCenter;
// bool BumperRight;
// //cliff
// bool CliffLeft;
// bool CliffCenter;
// bool CliffRight;
// // wheel drop
// bool WheelDropLeft;
// bool WheelDropRight;
// //wheel rotation
// unsigned short EncoderRight;
// unsigned short EncoderLeft;
// unsigned char PWMright;
// unsigned char PWMleft;
// //buttons
// unsigned char ButtonPress;// 0 no, 1 2 4 for button 0 1 2 (7 is all three)
// //power
// unsigned char Charger;
// unsigned char Battery;
// unsigned char overCurrent;
// //---docking ir
// unsigned char IRSensorRight;
// unsigned char IRSensorCenter;
// unsigned char IRSensorLeft;
// //---Inertial Sensor Data
// signed short GyroAngle;
// unsigned short GyroAngleRate;
// //---Cliff Sensor Data
// unsigned short CliffSensorRight;
// unsigned short CliffSensorCenter;
// unsigned short CliffSensorLeft;
// //---Current
// unsigned char wheelCurrentLeft;
// unsigned char wheelCurrentRight;
// //---Raw Data Of 3D Gyro
// unsigned char frameId;
// std::vector<TRawGyroData> gyroData;
// //---General Purpose Input
// unsigned short digitalInput;
// unsigned short analogInputCh0;
// unsigned short analogInputCh1;
// unsigned short analogInputCh2;
// unsigned short analogInputCh3;
// //---structure with data that appears only on request
// TExtraRequestData extraInfo;
// }TKobukiData;
typedef long(*src_callback_kobuki_data) (void *user_data, TKobukiData &Kobuki_data);
class CKobuki
@@ -156,10 +71,13 @@ public:
// control functions
void goStraight(long double distance);
void forward(int speedvalue, long double distance);
void forward(int speedvalue);
void doRotation(long double th);
void goToXy(long double xx, long double yy);
void Rotate(int degrees);
std::ofstream odometry_log;
void robotSafety();
void sendNullMessage();
KobukiParser parser;

View File

@@ -1,6 +1,6 @@
#include "KobukiParser.h"
#include <iostream>
//moet checkenvalue gebruiken of moet kijken naar de payloadlength welke dingen er extra zijn
int KobukiParser::parseKobukiMessage(TKobukiData &output, unsigned char *data) {
int rtrnvalue = checkChecksum(data);
if (rtrnvalue != 0) {
@@ -108,7 +108,7 @@ void KobukiParser::parseBasicData(TKobukiData &output, unsigned char *data, int
checkedValue += 2;
output.BumperCenter = (data[checkedValue] & 0x02) >> 1;
output.BumperLeft = (data[checkedValue] & 0x04) >> 2;
output.BumperRight = data[checkedValue] & 0x01;
output.BumperRight = data[checkedValue] & 0x01;
checkedValue++;
output.WheelDropLeft = (data[checkedValue] & 0x02) >> 1;
output.WheelDropRight = data[checkedValue] & 0x01;
@@ -125,7 +125,9 @@ void KobukiParser::parseBasicData(TKobukiData &output, unsigned char *data, int
checkedValue++;
output.PWMright = data[checkedValue];
checkedValue++;
output.ButtonPress = data[checkedValue];
output.ButtonPress1 = data[checkedValue] & 0x01;
output.ButtonPress2 = data[checkedValue] & 0x02;
output.ButtonPress3 = data[checkedValue] & 0x04;
checkedValue++;
output.Charger = data[checkedValue];
checkedValue++;
@@ -151,13 +153,13 @@ void KobukiParser::parseGyroData(TKobukiData &output, unsigned char *data, int &
checkedValue += 5; // 3 unused
}
void KobukiParser::parseCliffSensorData(TKobukiData &output, unsigned char *data, int &checkedValue){
output.CliffSensorRight = data[checkedValue];
checkedValue++;
output.CliffSensorCenter = data[checkedValue];
checkedValue++;
output.CliffSensorLeft = data[checkedValue];
checkedValue++;
void KobukiParser::parseCliffSensorData(TKobukiData &output, unsigned char *data, int &checkedValue) {
output.CliffSensorRight = (data[checkedValue] << 8) | data[checkedValue + 1];
checkedValue += 2;
output.CliffSensorCenter = (data[checkedValue] << 8) | data[checkedValue + 1];
checkedValue += 2;
output.CliffSensorLeft = (data[checkedValue] << 8) | data[checkedValue + 1];
checkedValue += 2;
}
void KobukiParser::parseWheelCurrentData(TKobukiData &output, unsigned char *data, int &checkedValue){

View File

@@ -19,7 +19,8 @@ struct TKobukiData {
int CliffCenter, CliffLeft, CliffRight;
int EncoderLeft, EncoderRight;
int PWMleft, PWMright;
int ButtonPress, Charger, Battery, overCurrent;
int ButtonPress1, ButtonPress2, ButtonPress3;
int Charger, Battery, overCurrent;
int IRSensorRight, IRSensorCenter, IRSensorLeft;
int GyroAngle, GyroAngleRate;
int CliffSensorRight, CliffSensorCenter, CliffSensorLeft;

View File

@@ -42,38 +42,105 @@ std::string readMQTT()
return message;
}
int movement()
{
int text;
while (true)
{
cin >> text;
int text;
while (true)
{
cout << "gimme input: ";
cin >> text;
if (text == 1)
{
robot.forward(1024, 1);
}
else if (text == 2)
{
// 1 is full circle
robot.doRotation(0.25);
}
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;
}
}
}
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;
}
}
}
}
void logToFile()
{
while (true)
{
TKobukiData robotData = robot.parser.data;
std::ofstream outputFile("log", std::ios_base::app); // Open file in append mode to not overwrite own content
if (outputFile.is_open())
{ // check if the file was opened successfully
// Get current time
std::time_t now = std::time(nullptr);
outputFile << "Timestamp: " << std::ctime(&now);
// Write data to the file
outputFile << "analogInputCh0: " << robotData.analogInputCh0 << "\n";
outputFile << "analogInputCh1: " << robotData.analogInputCh1 << "\n";
outputFile << "analogInputCh2: " << robotData.analogInputCh2 << "\n";
outputFile << "analogInputCh3: " << robotData.analogInputCh3 << "\n";
outputFile << "digitalInput: " << robotData.digitalInput << "\n";
outputFile << "timestamp: " << robotData.timestamp << "\n";
outputFile << "BumperCenter: " << robotData.BumperCenter << "\n";
outputFile << "BumperLeft: " << robotData.BumperLeft << "\n";
outputFile << "BumperRight: " << robotData.BumperRight << "\n";
outputFile << "WheelDropLeft: " << robotData.WheelDropLeft << "\n";
outputFile << "WheelDropRight: " << robotData.WheelDropRight << "\n";
outputFile << "CliffCenter: " << robotData.CliffCenter << "\n";
outputFile << "CliffLeft: " << robotData.CliffLeft << "\n";
outputFile << "CliffRight: " << robotData.CliffRight << "\n";
outputFile << "EncoderLeft: " << robotData.EncoderLeft << "\n";
outputFile << "EncoderRight: " << robotData.EncoderRight << "\n";
outputFile << "PWMleft: " << robotData.PWMleft << "\n";
outputFile << "PWMright: " << robotData.PWMright << "\n";
outputFile << "ButtonPress: " << robotData.ButtonPress1 << "\n";
outputFile << "ButtonPress: " << robotData.ButtonPress2 << "\n";
outputFile << "ButtonPress: " << robotData.ButtonPress3 << "\n";
outputFile << "Charger: " << robotData.Charger << "\n";
outputFile << "Battery: " << robotData.Battery << "\n";
outputFile << "overCurrent: " << robotData.overCurrent << "\n";
outputFile << "IRSensorRight: " << robotData.IRSensorRight << "\n";
outputFile << "IRSensorCenter: " << robotData.IRSensorCenter << "\n";
outputFile << "IRSensorLeft: " << robotData.IRSensorLeft << "\n";
outputFile << "GyroAngle: " << robotData.GyroAngle << "\n";
outputFile << "GyroAngleRate: " << robotData.GyroAngleRate << "\n";
outputFile << "CliffSensorRight: " << robotData.CliffSensorRight << "\n";
outputFile << "CliffSensorCenter: " << robotData.CliffSensorCenter << "\n";
outputFile << "CliffSensorLeft: " << robotData.CliffSensorLeft << "\n";
outputFile << "wheelCurrentLeft: " << robotData.wheelCurrentLeft << "\n";
outputFile << "wheelCurrentRight: " << robotData.wheelCurrentRight << "\n";
outputFile << "frameId: " << robotData.frameId << "\n";
outputFile << "HardwareVersionPatch: " << robotData.extraInfo.HardwareVersionPatch << "\n";
outputFile << "HardwareVersionMinor: " << robotData.extraInfo.HardwareVersionMinor << "\n";
outputFile << "HardwareVersionMajor: " << 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 << "UDID1: " << robotData.extraInfo.UDID1 << "\n";
outputFile << "UDID2: " << robotData.extraInfo.UDID2 << "\n";
outputFile.close();
}
else
{
std::cerr << "Error opening file\n";
}
std::this_thread::sleep_for(std::chrono::seconds(2)); // Sleep for 2 seconds
}
}