无法使用Arduino将IMU传感器数据输入到tflite(修改魔杖)
我正在用Arduino编写代码,用于使用tflite模型从Adafru LSM6DSOX传感器的IMU数据中识别手势。我正在使用以下功能读取数据:无法使用Arduino将IMU传感器数据输入到tflite(修改魔杖),arduino,tensorflow-lite,adafruit,imu,arduino-nano,Arduino,Tensorflow Lite,Adafruit,Imu,Arduino Nano,我正在用Arduino编写代码,用于使用tflite模型从Adafru LSM6DSOX传感器的IMU数据中识别手势。我正在使用以下功能读取数据: bool got_data = ReadAccelerometer(error_reporter, model_input->data.f, input_length); 此函数读取50 x 6传感器值,并将其复制到模型的输入层: float save_data[300] = {0.0}; bool ReadAccelerometer(tf
bool got_data = ReadAccelerometer(error_reporter, model_input->data.f, input_length);
此函数读取50 x 6传感器值,并将其复制到模型的输入层:
float save_data[300] = {0.0};
bool ReadAccelerometer(tflite::ErrorReporter* error_reporter, float* input, int length) {
for (int i = 0; i < 50; ++i) {
sensors_event_t accel;
sensors_event_t gyro;
sensors_event_t temp;
sox.getEvent(&accel, &gyro, &temp);
const float xa = accel.acceleration.x;
const float ya = accel.acceleration.y;
const float za = accel.acceleration.z;
const float xg = gyro.gyro.x;
const float yg = gyro.gyro.y;
const float zg = gyro.gyro.z;
save_data[begin_index++] = xa;
save_data[begin_index++] = ya;
save_data[begin_index++] = za;
save_data[begin_index++] = xg;
save_data[begin_index++] = yg;
save_data[begin_index++] = zg;
// If we reached the end of the circle buffer, reset
if (begin_index >= 300) {
begin_index = 0;
}
}
// Copy the requested number of bytes to the provided input tensor
for (int i = 0; i < length; ++i) {
input[i] = save_data[i];
Serial.print(input[i]);
Serial.print("---");
Serial.print(input[i]);
Serial.print("---");
}
return true;
}
第二个值与将任何值指定给输入[i]之前打印的值相同。
请帮助找到将IMU数据输入到输入张量的方法
5.83---0.00---
-1.96---0.00---
7.97---0.00---
-0.63---0.00---
0.77---0.00---
0.12---0.00---
5.88---0.00---
-2.05---0.00---
7.98---0.00---
-0.51---0.00---
0.75---0.00---
-0.21---0.00---
5.83---0.00---
-2.07---0.00---
7.99---0.00---
0.55---0.00---
-1.19---0.00---
-0.04---0.00---
5.88---0.00---
-2.01---0.00---
7.91---0.00---
0.59---0.00---
0.02---0.00---
-0.19---0.00---
5.96---0.00---
-2.05---0.00---
7.87---0.00---
-0.40---0.00---
0.75---0.00---
-0.30---0.00---
6.07---0.00---
-1.98---0.00---
7.87---0.00---
-0.52---0.00---
-0.54---0.00---
-0.09---0.00---
5.95---0.00---
-2.02---0.00---
7.91---0.00---
0.21---0.00---
-0.19---0.00---
0.01---0.00---
5.85---0.00---
-2.08---0.00---
8.07---0.00---
0.43---0.00---
0.67---0.00---
0.16---0.00---
5.90---0.00---
-2.07---0.00---
7.94---0.00---
-0.00---0.00---
-0.17---0.00---
0.10---0.00---
5.88---0.00---
-2.11---0.00---
8.05---0.00---
-0.25---0.00---
-0.67---0.00---
0.17---0.00---
5.85---0.00---
-2.08---0.00---
7.98---0.00---
-0.07---0.00---
0.38----0.00---
0.02----1.49---
6.02---ovf---
-2.09---ovf---
8.02---0.00---
0.19---ovf---
0.05---ovf---
0.00---ovf---
5.93---ovf---
-2.03---ovf---
7.93---0.00---
0.12---0.00---
-0.50---ovf---
-0.13---ovf---
5.97---ovf---
-2.08----0.00---
7.90---48.07---
-0.04---0.00---
0.07---ovf---
-0.11---ovf---
5.88---ovf---
-2.03---0.00---
7.81---48.17---
-0.12---0.00---
0.34---ovf---
-0.18---61443.26---
5.77---ovf---
-2.01---ovf---
7.94---ovf---
-0.02---ovf---
-0.24----0.00---
-0.03---ovf---
5.94---61441.25---
-2.09---ovf---
7.89---ovf---
0.02---ovf---
-0.24---ovf---