dead code removal
This commit is contained in:
@@ -5,56 +5,24 @@
|
|||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
Serial.println("startup");
|
Serial.println("startup");
|
||||||
|
//connect to internet and start sensor
|
||||||
connectivity.connectWiFi(ssid, pass);
|
connectivity.connectWiFi(ssid, pass);
|
||||||
sensorManager.sensorSetup();
|
sensorManager.sensorSetup();
|
||||||
|
|
||||||
//ws server address, port and URL
|
|
||||||
// webSocket.begin("145.28.160.108", 8001, "");
|
|
||||||
// try every 500 again if connection has failed
|
|
||||||
// webSocket.setReconnectInterval(500);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
SensorManager::eulerAngles eulerRotation = sensorManager.getEulerAngles();
|
SensorManager::eulerAngles eulerRotation = sensorManager.getEulerAngles();
|
||||||
|
|
||||||
// Subtract offset
|
|
||||||
// rotation.i -= offset.i;
|
|
||||||
// rotation.j -= offset.j;
|
|
||||||
// rotation.k -= offset.k;
|
|
||||||
// rotation.w -= offset.w;
|
|
||||||
|
|
||||||
// Convert quaternion to Euler angles in radians
|
|
||||||
|
|
||||||
|
|
||||||
// Convert to degrees
|
|
||||||
// float rollDegrees = roll * 180.0f / PI;
|
|
||||||
// float pitchDegrees = pitch * 180.0f / PI;
|
|
||||||
// float yawDegrees = yaw * 180.0f / PI;
|
|
||||||
|
|
||||||
Serial.print(eulerRotation.roll);
|
Serial.print(eulerRotation.roll);
|
||||||
Serial.print(" ");
|
Serial.print(" ");
|
||||||
Serial.print(eulerRotation.pitch);
|
Serial.print(eulerRotation.pitch);
|
||||||
Serial.print(" ");
|
Serial.print(" ");
|
||||||
Serial.print(eulerRotation.yaw);
|
Serial.print(eulerRotation.yaw);
|
||||||
sendData(eulerRotation.roll, eulerRotation.pitch, eulerRotation.yaw);
|
|
||||||
|
|
||||||
Serial.println();
|
Serial.println();
|
||||||
// webSocket.loop();
|
|
||||||
}
|
|
||||||
// if (Serial.available()) {
|
|
||||||
// String command = Serial.readStringUntil('\n');
|
|
||||||
// command.trim(); // remove any trailing whitespace
|
|
||||||
// if (command == "setZeroPoint") {
|
|
||||||
// setZeroPoint();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// void setZeroPoint() {
|
|
||||||
// offset = sensorManager.readLoop();
|
|
||||||
// }
|
|
||||||
|
|
||||||
void sendData(float roll, float pitch, float yaw){
|
String message = "{\"Sensor\": 1, \"roll\":\"" + String(eulerRotation.roll) + "\",\"pitch\":\"" + String(eulerRotation.pitch) + "\",\"yaw\":\"" + String(eulerRotation.yaw) + "\"}";
|
||||||
String message = "{\"Sensor\": 1, \"roll\":\"" + String(roll) + "\",\"pitch\":\"" + String(pitch) + "\",\"yaw\":\"" + String(yaw) + "\"}";
|
int messageLength = message.length();
|
||||||
webSocket.sendTXT(message);
|
Serial.println(message);
|
||||||
|
Serial.println(connectivity.httpPost("192.168.137.146", "/", 3445, message.c_str(), message.length(), "json"));
|
||||||
}
|
}
|
@@ -15,20 +15,20 @@ void SensorManager::sensorSetup() {
|
|||||||
//start sensorfunction and start autocalibration
|
//start sensorfunction and start autocalibration
|
||||||
//once calibration is enabled it attempts to every 5 min
|
//once calibration is enabled it attempts to every 5 min
|
||||||
|
|
||||||
Wire.setClock(400000); //Increase I2C data rate to 400kHz
|
Wire.setClock(400000);
|
||||||
myIMU.calibrateAll(); //Turn on cal for Accel, Gyro, and Mag
|
myIMU.calibrateAll();
|
||||||
myIMU.enableGyroIntegratedRotationVector(100); //send data every 100ms
|
myIMU.enableGyroIntegratedRotationVector(100); //send data every 100ms
|
||||||
myIMU.enableMagnetometer(100); //Send data update every 100ms
|
myIMU.enableMagnetometer(100); //Send data update every 100ms
|
||||||
myIMU.saveCalibration(); //Saves the current dynamic calibration data (DCD) to memory
|
myIMU.saveCalibration(); //Saves the current dynamic calibration data (DCD) to memory
|
||||||
myIMU.requestCalibrationStatus(); //Sends command to get the latest calibration status
|
myIMU.requestCalibrationStatus(); //Sends command to get the latest calibration status
|
||||||
|
//Never seen this work in serial console
|
||||||
if (myIMU.calibrationComplete() == true) {
|
if (myIMU.calibrationComplete() == true) {
|
||||||
Serial.println("Calibration data successfully stored");
|
Serial.println("Calibration data successfully stored");
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.println(F("magnetometer rotation enabled"));
|
Serial.println(F("magnetometer rotation enabled"));
|
||||||
}
|
}
|
||||||
|
//get sensordata
|
||||||
SensorManager::RotationQuintillions SensorManager::getQuintillions() {
|
SensorManager::RotationQuintillions SensorManager::getQuintillions() {
|
||||||
if (myIMU.dataAvailable() == true) {
|
if (myIMU.dataAvailable() == true) {
|
||||||
float i = myIMU.getQuatI();
|
float i = myIMU.getQuatI();
|
||||||
@@ -48,7 +48,7 @@ SensorManager::RotationQuintillions SensorManager::getQuintillions() {
|
|||||||
return rotation;
|
return rotation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//calculate Quintillions to Euler angles from -1π to +1π
|
||||||
SensorManager::eulerAngles SensorManager::getEulerAngles() {
|
SensorManager::eulerAngles SensorManager::getEulerAngles() {
|
||||||
SensorManager::RotationQuintillions rotation = getQuintillions();
|
SensorManager::RotationQuintillions rotation = getQuintillions();
|
||||||
float roll = atan2(2.0f * (rotation.w * rotation.i + rotation.j * rotation.k), 1.0f - 2.0f * (rotation.i * rotation.i + rotation.j * rotation.j));
|
float roll = atan2(2.0f * (rotation.w * rotation.i + rotation.j * rotation.k), 1.0f - 2.0f * (rotation.i * rotation.i + rotation.j * rotation.j));
|
||||||
@@ -57,3 +57,5 @@ SensorManager::eulerAngles SensorManager::getEulerAngles() {
|
|||||||
eulerAngles EulerAngles = { roll, pitch, yaw };
|
eulerAngles EulerAngles = { roll, pitch, yaw };
|
||||||
return EulerAngles;
|
return EulerAngles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SensorManager::bool
|
Reference in New Issue
Block a user