SDCards liegen jetzt beim Paketshop, da mein anderes Prjekt eh gerade einen Dämpfer abbekommen hat kann ich heute nochmal hieran arbeiten.
@HaWe Messdaten habe ich unter Python übrigens schon erfolgreich ausgelesen, es kondensiert sich zu folgendem Code in C(ungetestet, das wollte ich heute ausprobieren, wenn ich dazu komme):
Code:
#include "ip_connection.h"
#include "brick_imu_v2.h"
typedef struct
{
float w;
float x;
float y;
float z;
}quaternion_s;
quaternion_s q;
// Create IP connection
IPConnection ipcon;
ipcon_create(&ipcon);
// Create device object
IMUV2 imu;
imu_v2_create(&imu, UID, &ipcon);
// Connect to brickd
if(ipcon_connect(&ipcon, HOST, PORT) < 0) {
fprintf(stderr, "Could not connect\n");
return 1;
}
// Don't use device before ipcon is connected
// Get current quaternion
int16_t w, x, y, z;
if(imu_v2_get_quaternion(&imu, &w, &x, &y, &z) < 0) {
fprintf(stderr, "Could not get quaternion, probably timeout\n");
return 1;
}
q.w = w/16383.0;
q.x = x/16383.0;
q.y = y/16383.0;
q.z = z/16383.0;
float yaw = atan2(2.0*(q.y*q.z + q.w*q.x), q.w*q.w - q.x*q.x - q.y*q.y + q.z*q.z);
float pitch = asin(-2.0*(q.x*q.z - q.w*q.y));
float roll = atan2(2.0*(q.x*q.y + q.w*q.z), q.w*q.w + q.x*q.x - q.y*q.y - q.z*q.z);