Merge branch 'main' of ssh://gitlab.fdmci.hva.nl/propedeuse-hbo-ict/onderwijs/2023-2024/out-a-se-ti/blok-4/muupooviixee66
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
#ifndef Connectivity_h
|
#ifndef MOVEMENTSENSORCODE_CONNECTIVITY_h
|
||||||
#define Connectivity_h
|
#define MOVEMENTSENSORCODE_CONNECTIVITY_h
|
||||||
|
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include <WebSocketsClient.h>
|
#include <WebSocketsClient.h>
|
||||||
@@ -30,4 +30,4 @@ private:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // MOVEMENTSENSORCODE_CONNECTIVITY_h
|
@@ -9,9 +9,10 @@ void setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
SensorManager::RotationQuaternions Rotation = sensorManager.getQuaternions();
|
SensorManager::eulerAngles Rotation = sensorManager.getEulerAngles();
|
||||||
// SensorManager::acceleration rotationAcceleration = sensorManager.getAcelleration();
|
|
||||||
|
|
||||||
|
//static structure
|
||||||
|
// TODO: redo json for esp8266 and in android studio
|
||||||
struct acceleration {
|
struct acceleration {
|
||||||
float x = 9;
|
float x = 9;
|
||||||
float y = 9;
|
float y = 9;
|
||||||
@@ -19,22 +20,22 @@ struct acceleration {
|
|||||||
} accelData;
|
} accelData;
|
||||||
|
|
||||||
if (!ipAquired) {
|
if (!ipAquired) {
|
||||||
serverIp = connectivity.fetchIPAddress(); // Assign the value here
|
serverIp = connectivity.fetchIPAddress(); //Fetch pepper ip address
|
||||||
ipAquired = true;
|
ipAquired = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long lastTime = 0; // will store the last time the code was run
|
unsigned long lastTime = 0; // will store the last time the code was run
|
||||||
unsigned long currentTime = millis();
|
unsigned long currentTime = millis();
|
||||||
if (currentTime - lastTime >= 100) { // 100 ms has passed
|
if (currentTime - lastTime >= 100) { // do everything inside every 100 ms
|
||||||
memset(buffer, 0, BUFFER_SIZE);
|
memset(buffer, 0, BUFFER_SIZE);
|
||||||
sprintf(
|
sprintf(
|
||||||
buffer,
|
buffer,
|
||||||
"{\"deviceId\": %d, \"rotationX\": %f, \"rotationY\": %f, \"rotationZ\": %f, \"accelerationX\": %f, \"accelerationY\": %f, \"accelerationZ\": %f, \"type\": %s}",
|
"{\"deviceId\": %d, \"rotationX\": %f, \"rotationY\": %f, \"rotationZ\": %f, \"accelerationX\": %f, \"accelerationY\": %f, \"accelerationZ\": %f, \"type\": %s}",
|
||||||
DEVICE_ID,
|
DEVICE_ID,
|
||||||
Rotation.i,
|
Rotation.roll,
|
||||||
Rotation.j,
|
Rotation.pitch,
|
||||||
Rotation.k,
|
Rotation.yaw,
|
||||||
Rotation.w,
|
accelData.x,
|
||||||
accelData.y,
|
accelData.y,
|
||||||
accelData.z,
|
accelData.z,
|
||||||
"data");
|
"data");
|
||||||
@@ -45,6 +46,3 @@ struct acceleration {
|
|||||||
lastTime = currentTime;
|
lastTime = currentTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//acceleration.X
|
|
||||||
//acceleration.Y
|
|
||||||
//acceleration.Z
|
|
@@ -1,5 +1,5 @@
|
|||||||
#ifndef SensorManager_h
|
#ifndef MOVEMENTSENSORCODE_SENSORMANAGER_H
|
||||||
#define SensorManager_h
|
#define MOVEMENTSENSORCODE_SENSORMANAGER_H
|
||||||
|
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "SparkFun_BNO080_Arduino_Library.h"
|
#include "SparkFun_BNO080_Arduino_Library.h"
|
||||||
@@ -23,6 +23,8 @@ public:
|
|||||||
acceleration getAcelleration();
|
acceleration getAcelleration();
|
||||||
bool sensorTap();
|
bool sensorTap();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
struct RotationQuaternions {
|
struct RotationQuaternions {
|
||||||
float i;
|
float i;
|
||||||
float j;
|
float j;
|
||||||
@@ -31,9 +33,7 @@ public:
|
|||||||
};
|
};
|
||||||
RotationQuaternions getQuaternions();
|
RotationQuaternions getQuaternions();
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
BNO080 myIMU;
|
BNO080 myIMU;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // MOVEMENTSENSORCODE_SENSORMANAGER_H
|
@@ -8,11 +8,10 @@ Connectivity connectivity;
|
|||||||
WebSocketsClient webSocket;
|
WebSocketsClient webSocket;
|
||||||
#define USE_SERIAL Serial
|
#define USE_SERIAL Serial
|
||||||
|
|
||||||
#define ssid "msi 5556"
|
#define ssid "1235678i"
|
||||||
#define pass "abc12345"
|
#define pass "12345678"
|
||||||
#define BUFFER_SIZE 1024
|
#define BUFFER_SIZE 1024
|
||||||
#define DEVICE_ID 1
|
#define DEVICE_ID 0
|
||||||
#define IP_ADDRESS "192.168.137.12"
|
|
||||||
|
|
||||||
char *buffer = (char *)malloc(sizeof(char) * BUFFER_SIZE);
|
char *buffer = (char *)malloc(sizeof(char) * BUFFER_SIZE);
|
||||||
const char* serverIp = NULL; // Declare serverIp here
|
const char* serverIp = NULL; // Declare serverIp here
|
||||||
|
61
docs/documentation/diagrams/UML-esp8266.md
Normal file
61
docs/documentation/diagrams/UML-esp8266.md
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
# UML esp8266 diagram
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
classDiagram
|
||||||
|
|
||||||
|
Connectivity --> Movement-sensor-code
|
||||||
|
SensorManager --> Movement-sensor-code
|
||||||
|
namespace ESP8266 {
|
||||||
|
|
||||||
|
class Movement-sensor-code {
|
||||||
|
+ struct RotationQuaternion
|
||||||
|
+ PepperIP
|
||||||
|
setup()
|
||||||
|
loop()
|
||||||
|
connectWifi()
|
||||||
|
sensorSetup()
|
||||||
|
getPepperIP()
|
||||||
|
httpPost()
|
||||||
|
}
|
||||||
|
|
||||||
|
class Connectivity {
|
||||||
|
+ void connectWiFi(char* ssid, char* pass)
|
||||||
|
+ void websocketSetup(char* ip, uint16_t port, char* adress)
|
||||||
|
+ void sendData(float roll, float pitch, float yaw);
|
||||||
|
+ int httpPost(const char *serverAddress, const char *serverSubPath, const unsigned short serverPort, const + char *data, const size_t dataLength, const char *contentType)
|
||||||
|
+ const char* fetchIPAddress()
|
||||||
|
|
||||||
|
-ESP8266WiFiMulti wifi;
|
||||||
|
-WiFiClient wifi_client;
|
||||||
|
}
|
||||||
|
|
||||||
|
class SensorManager {
|
||||||
|
+ struct eulerAngles(
|
||||||
|
float roll;
|
||||||
|
float pitch;
|
||||||
|
float yaw;
|
||||||
|
);
|
||||||
|
+ struct acceleration (
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
float z;
|
||||||
|
);
|
||||||
|
+ eulerAngles getEulerAngles()
|
||||||
|
+ acceleration getAcelleration()
|
||||||
|
+ bool sensorTap()
|
||||||
|
|
||||||
|
|
||||||
|
- struct RotationQuaternions (
|
||||||
|
float i;
|
||||||
|
float j;
|
||||||
|
float k;
|
||||||
|
float w;
|
||||||
|
);
|
||||||
|
- RotationQuaternions getQuaternions()
|
||||||
|
|
||||||
|
- BNO080 myIMU
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
Reference in New Issue
Block a user