无法使用Arduino将IMU传感器数据输入到tflite魔术棒的修改

如何解决无法使用Arduino将IMU传感器数据输入到tflite魔术棒的修改

我正在使用 Arduino 编写代码,用于使用 tflite 模型从来自 Adafruit_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(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;
}

然而, input[i] 中的值立即消失(在设置其值后的第二行)。上面的代码输出

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---

第二个值与将任何值分配给 input[i] 之前打印的值相同。 请帮助将 IMU 数据获取到输入张量的方法

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?