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
27 Commits
test_scrip
...
a46900dfd2
Author | SHA1 | Date | |
---|---|---|---|
a46900dfd2 | |||
2919e20970 | |||
|
c4a694e601 | ||
d78389992e | |||
7fa04a5c35 | |||
1175444abf | |||
79f21f8755 | |||
9935375a5a | |||
d41e6432b3 | |||
b5f5491222 | |||
856d60eea2 | |||
6a0024ebb8 | |||
0011096977 | |||
5ead72c47e | |||
|
216b28d27c | ||
b5e619ac0a | |||
c38491ce20 | |||
c9d128ecd1 | |||
|
927126a797 | ||
|
6235af77b9 | ||
9a4cd473a6 | |||
|
acd4b9589c | ||
|
c129ae4980 | ||
|
cdbb538238 | ||
|
26cc0e2041 | ||
2bee0ffc25 | |||
cede3689f4 |
7
.gitignore
vendored
7
.gitignore
vendored
@@ -16,6 +16,13 @@ src/C++/Driver/Makefile
|
|||||||
src/C++/Driver/vgcore*
|
src/C++/Driver/vgcore*
|
||||||
src/C++/Driver/cmake_install.cmake
|
src/C++/Driver/cmake_install.cmake
|
||||||
src/C++/Driver/Makefile
|
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_
|
src/Python/flask/web/_pycache_
|
||||||
venv
|
venv
|
||||||
build/
|
build/
|
||||||
|
21
.gitlab/issue_templates/Learning Story.md
Normal file
21
.gitlab/issue_templates/Learning Story.md
Normal 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
|
32
.gitlab/issue_templates/User Story.md
Normal file
32
.gitlab/issue_templates/User Story.md
Normal 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.
|
@@ -2,35 +2,51 @@
|
|||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
classDiagram
|
classDiagram
|
||||||
|
Apache <--> Flask
|
||||||
|
Flask <--> MariaDB
|
||||||
|
ESP32 --> RPI : Wired communication
|
||||||
|
RPI <--> Wireguard : MQTT with a VPN connection
|
||||||
|
Wireguard <--> Flask
|
||||||
|
|
||||||
|
|
||||||
VirtualMachine <--> RPI
|
|
||||||
Kobuki <--> RPI
|
|
||||||
namespace Server {
|
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 {
|
class ESP32 {
|
||||||
+data
|
+TVOC()
|
||||||
}
|
+ECO2()
|
||||||
|
+Temperature()
|
||||||
|
+LDR()
|
||||||
|
+Camera()
|
||||||
|
+GPS()
|
||||||
|
+ToF()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@@ -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 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 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 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
|
||||||
|
33
docs/explanation/sensoren.md
Normal file
33
docs/explanation/sensoren.md
Normal 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.
|
@@ -12,7 +12,7 @@
|
|||||||
////*************************************************************************************
|
////*************************************************************************************
|
||||||
#ifndef KOBUKI_CLASS_123456789
|
#ifndef KOBUKI_CLASS_123456789
|
||||||
#define KOBUKI_CLASS_123456789
|
#define KOBUKI_CLASS_123456789
|
||||||
#define PI 3.141592653589793238462643383279502884L /* pi */
|
#define PI 3.141592653589793238462643383279502884L /* pi */
|
||||||
#define MS_INSTRUCTION_DELAY 25
|
#define MS_INSTRUCTION_DELAY 25
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -35,91 +35,6 @@
|
|||||||
|
|
||||||
using namespace std;
|
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);
|
typedef long(*src_callback_kobuki_data) (void *user_data, TKobukiData &Kobuki_data);
|
||||||
|
|
||||||
class CKobuki
|
class CKobuki
|
||||||
@@ -156,10 +71,13 @@ public:
|
|||||||
|
|
||||||
// control functions
|
// control functions
|
||||||
void goStraight(long double distance);
|
void goStraight(long double distance);
|
||||||
void forward(int speedvalue, long double distance);
|
void forward(int speedvalue);
|
||||||
void doRotation(long double th);
|
void doRotation(long double th);
|
||||||
void goToXy(long double xx, long double yy);
|
void goToXy(long double xx, long double yy);
|
||||||
|
void Rotate(int degrees);
|
||||||
std::ofstream odometry_log;
|
std::ofstream odometry_log;
|
||||||
|
void robotSafety();
|
||||||
|
void sendNullMessage();
|
||||||
KobukiParser parser;
|
KobukiParser parser;
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
#include "KobukiParser.h"
|
#include "KobukiParser.h"
|
||||||
#include <iostream>
|
#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 KobukiParser::parseKobukiMessage(TKobukiData &output, unsigned char *data) {
|
||||||
int rtrnvalue = checkChecksum(data);
|
int rtrnvalue = checkChecksum(data);
|
||||||
if (rtrnvalue != 0) {
|
if (rtrnvalue != 0) {
|
||||||
@@ -108,7 +108,7 @@ void KobukiParser::parseBasicData(TKobukiData &output, unsigned char *data, int
|
|||||||
checkedValue += 2;
|
checkedValue += 2;
|
||||||
output.BumperCenter = (data[checkedValue] & 0x02) >> 1;
|
output.BumperCenter = (data[checkedValue] & 0x02) >> 1;
|
||||||
output.BumperLeft = (data[checkedValue] & 0x04) >> 2;
|
output.BumperLeft = (data[checkedValue] & 0x04) >> 2;
|
||||||
output.BumperRight = data[checkedValue] & 0x01;
|
output.BumperRight = data[checkedValue] & 0x01;
|
||||||
checkedValue++;
|
checkedValue++;
|
||||||
output.WheelDropLeft = (data[checkedValue] & 0x02) >> 1;
|
output.WheelDropLeft = (data[checkedValue] & 0x02) >> 1;
|
||||||
output.WheelDropRight = data[checkedValue] & 0x01;
|
output.WheelDropRight = data[checkedValue] & 0x01;
|
||||||
@@ -125,7 +125,9 @@ void KobukiParser::parseBasicData(TKobukiData &output, unsigned char *data, int
|
|||||||
checkedValue++;
|
checkedValue++;
|
||||||
output.PWMright = data[checkedValue];
|
output.PWMright = data[checkedValue];
|
||||||
checkedValue++;
|
checkedValue++;
|
||||||
output.ButtonPress = data[checkedValue];
|
output.ButtonPress1 = data[checkedValue] & 0x01;
|
||||||
|
output.ButtonPress2 = data[checkedValue] & 0x02;
|
||||||
|
output.ButtonPress3 = data[checkedValue] & 0x04;
|
||||||
checkedValue++;
|
checkedValue++;
|
||||||
output.Charger = data[checkedValue];
|
output.Charger = data[checkedValue];
|
||||||
checkedValue++;
|
checkedValue++;
|
||||||
@@ -151,13 +153,13 @@ void KobukiParser::parseGyroData(TKobukiData &output, unsigned char *data, int &
|
|||||||
checkedValue += 5; // 3 unused
|
checkedValue += 5; // 3 unused
|
||||||
}
|
}
|
||||||
|
|
||||||
void KobukiParser::parseCliffSensorData(TKobukiData &output, unsigned char *data, int &checkedValue){
|
void KobukiParser::parseCliffSensorData(TKobukiData &output, unsigned char *data, int &checkedValue) {
|
||||||
output.CliffSensorRight = data[checkedValue];
|
output.CliffSensorRight = (data[checkedValue] << 8) | data[checkedValue + 1];
|
||||||
checkedValue++;
|
checkedValue += 2;
|
||||||
output.CliffSensorCenter = data[checkedValue];
|
output.CliffSensorCenter = (data[checkedValue] << 8) | data[checkedValue + 1];
|
||||||
checkedValue++;
|
checkedValue += 2;
|
||||||
output.CliffSensorLeft = data[checkedValue];
|
output.CliffSensorLeft = (data[checkedValue] << 8) | data[checkedValue + 1];
|
||||||
checkedValue++;
|
checkedValue += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KobukiParser::parseWheelCurrentData(TKobukiData &output, unsigned char *data, int &checkedValue){
|
void KobukiParser::parseWheelCurrentData(TKobukiData &output, unsigned char *data, int &checkedValue){
|
||||||
|
@@ -19,7 +19,8 @@ struct TKobukiData {
|
|||||||
int CliffCenter, CliffLeft, CliffRight;
|
int CliffCenter, CliffLeft, CliffRight;
|
||||||
int EncoderLeft, EncoderRight;
|
int EncoderLeft, EncoderRight;
|
||||||
int PWMleft, PWMright;
|
int PWMleft, PWMright;
|
||||||
int ButtonPress, Charger, Battery, overCurrent;
|
int ButtonPress1, ButtonPress2, ButtonPress3;
|
||||||
|
int Charger, Battery, overCurrent;
|
||||||
int IRSensorRight, IRSensorCenter, IRSensorLeft;
|
int IRSensorRight, IRSensorCenter, IRSensorLeft;
|
||||||
int GyroAngle, GyroAngleRate;
|
int GyroAngle, GyroAngleRate;
|
||||||
int CliffSensorRight, CliffSensorCenter, CliffSensorLeft;
|
int CliffSensorRight, CliffSensorCenter, CliffSensorLeft;
|
||||||
|
@@ -42,38 +42,105 @@ std::string readMQTT()
|
|||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int movement()
|
int movement()
|
||||||
{
|
{
|
||||||
int text;
|
int text;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
cin >> text;
|
cout << "gimme input: ";
|
||||||
|
cin >> text;
|
||||||
|
|
||||||
if (text == 1)
|
if (text == 1)
|
||||||
{
|
{
|
||||||
robot.forward(1024, 1);
|
robot.forward(400);
|
||||||
}
|
}
|
||||||
else if (text == 2)
|
else if (text == 2)
|
||||||
{
|
{
|
||||||
// 1 is full circle
|
// 1 is full circle
|
||||||
robot.doRotation(0.25);
|
robot.Rotate(90);
|
||||||
}
|
}
|
||||||
else if (text == 3)
|
else if (text == 3)
|
||||||
{
|
{
|
||||||
// Add your code here for text == 3
|
// Add your code here for text == 3
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
robot.doRotation(text);
|
robot.doRotation(text);
|
||||||
throw "NaN";
|
throw "NaN";
|
||||||
}
|
}
|
||||||
catch (const char *msg)
|
catch (const char *msg)
|
||||||
{
|
{
|
||||||
cerr << msg << endl;
|
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
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user