我正在尝试制作一个自平衡机器人,但编译时存在错误。我不知道如何解决它
I am trying to make a self balancing robot, but there is an error in compiling. I don't know how to fix it
Arduino: 1.8.5 (Windows 8.1), Board: "Arduino/Genuino Uno"
In file included from C:UsersMemay FamilyDownloadsHow_to_Make_Balancing_Robot_at_homeHow_to_Make_Balancing_Robot_at_home.ino:11:0:
C:UsersMemay FamilyDocumentsArduinolibrariesMPU6050/MPU6050_6Axis_MotionApps20.h: In member function 'uint8_t MPU6050::dmpGetAccel(int32_t*, const uint8_t*)':
C:UsersMemay FamilyDocumentsArduinolibrariesMPU6050/MPU6050_6Axis_MotionApps20.h:580:31: warning: left shift count >= width of type
data[0] = ((packet[28] << 24) + (packet[29] << 16) + (packet[30] << 8) + packet[31]);
^
C:UsersMemay FamilyDocumentsArduinolibrariesMPU6050/MPU6050_6Axis_MotionApps20.h:580:52: warning: left shift count >= width of type
data[0] = ((packet[28] << 24) + (packet[29] << 16) + (packet[30] << 8) + packet[31]);
^
C:UsersMemay FamilyDocumentsArduinolibrariesMPU6050/MPU6050_6Axis_MotionApps20.h:581:31: warning: left shift count >= width of type
data[1] = ((packet[32] << 24) + (packet[33] << 16) + (packet[34] << 8) + packet[35]);
^
C:UsersMemay FamilyDocumentsArduinolibrariesMPU6050/MPU6050_6Axis_MotionApps20.h:581:52: warning: left shift count >= width of type
data[1] = ((packet[32] << 24) + (packet[33] << 16) + (packet[34] << 8) + packet[35]);
^
C:UsersMemay FamilyDocumentsArduinolibrariesMPU6050/MPU6050_6Axis_MotionApps20.h:582:31: warning: left shift count >= width of type
data[2] = ((packet[36] << 24) + (packet[37] << 16) + (packet[38] << 8) + packet[39]);
^
C:UsersMemay FamilyDocumentsArduinolibrariesMPU6050/MPU6050_6Axis_MotionApps20.h:582:52: warning: left shift count >= width of type
data[2] = ((packet[36] << 24) + (packet[37] << 16) + (packet[38] << 8) + packet[39]);
^
C:UsersMemay FamilyDocumentsArduinolibrariesMPU6050/MPU6050_6Axis_MotionApps20.h: In member function 'uint8_t MPU6050::dmpGetQuaternion(int32_t*, const uint8_t*)':
C:UsersMemay FamilyDocumentsArduinolibrariesMPU6050/MPU6050_6Axis_MotionApps20.h:604:30: warning: left shift count >= width of type
data[0] = ((packet[0] << 24) + (packet[1] << 16) + (packet[2] << 8) + packet[3]);
^
C:UsersMemay FamilyDocumentsArduinolibrariesMPU6050/MPU6050_6Axis_MotionApps20.h:604:50: warning: left shift count >= width of type
data[0] = ((packet[0] << 24) + (packet[1] << 16) + (packet[2] << 8) + packet[3]);
^
C:UsersMemay FamilyDocumentsArduinolibrariesMPU6050/MPU6050_6Axis_MotionApps20.h:605:30: warning: left shift count >= width of type
data[1] = ((packet[4] << 24) + (packet[5] << 16) + (packet[6] << 8) + packet[7]);
^
C:UsersMemay FamilyDocumentsArduinolibrariesMPU6050/MPU6050_6Axis_MotionApps20.h:605:50: warning: left shift count >= width of type
data[1] = ((packet[4] << 24) + (packet[5] << 16) + (packet[6] << 8) + packet[7]);
^
C:UsersMemay FamilyDocumentsArduinolibrariesMPU6050/MPU6050_6Axis_MotionApps20.h:606:30: warning: left shift count >= width of type
data[2] = ((packet[8] << 24) + (packet[9] << 16) + (packet[10] << 8) + packet[11]);
^
C:UsersMemay FamilyDocumentsArduinolibrariesMPU6050/MPU6050_6Axis_MotionApps20.h:606:50: warning: left shift count >= width of type
data[2] = ((packet[8] << 24) + (packet[9] << 16) + (packet[10] << 8) + packet[11]);
^
C:UsersMemay FamilyDocumentsArduinolibrariesMPU6050/MPU6050_6Axis_MotionApps20.h:607:31: warning: left shift count >= width of type
data[3] = ((packet[12] << 24) + (packet[13] << 16) + (packet[14] << 8) + packet[15]);
^
C:UsersMemay FamilyDocumentsArduinolibrariesMPU6050/MPU6050_6Axis_MotionApps20.h:607:52: warning: left shift count >= width of type
data[3] = ((packet[12] << 24) + (packet[13] << 16) + (packet[14] << 8) + packet[15]);
^
C:UsersMemay FamilyDocumentsArduinolibrariesMPU6050/MPU6050_6Axis_MotionApps20.h: In member function 'uint8_t MPU6050::dmpGetGyro(int32_t*, const uint8_t*)':
C:UsersMemay FamilyDocumentsArduinolibrariesMPU6050/MPU6050_6Axis_MotionApps20.h:637:31: warning: left shift count >= width of type
data[0] = ((packet[16] << 24) + (packet[17] << 16) + (packet[18] << 8) + packet[19]);
^
C:UsersMemay FamilyDocumentsArduinolibrariesMPU6050/MPU6050_6Axis_MotionApps20.h:637:52: warning: left shift count >= width of type
data[0] = ((packet[16] << 24) + (packet[17] << 16) + (packet[18] << 8) + packet[19]);
^
C:UsersMemay FamilyDocumentsArduinolibrariesMPU6050/MPU6050_6Axis_MotionApps20.h:638:31: warning: left shift count >= width of type
data[1] = ((packet[20] << 24) + (packet[21] << 16) + (packet[22] << 8) + packet[23]);
^
C:UsersMemay FamilyDocumentsArduinolibrariesMPU6050/MPU6050_6Axis_MotionApps20.h:638:52: warning: left shift count >= width of type
data[1] = ((packet[20] << 24) + (packet[21] << 16) + (packet[22] << 8) + packet[23]);
^
C:UsersMemay FamilyDocumentsArduinolibrariesMPU6050/MPU6050_6Axis_MotionApps20.h:639:31: warning: left shift count >= width of type
data[2] = ((packet[24] << 24) + (packet[25] << 16) + (packet[26] << 8) + packet[27]);
^
C:UsersMemay FamilyDocumentsArduinolibrariesMPU6050/MPU6050_6Axis_MotionApps20.h:639:52: warning: left shift count >= width of type
data[2] = ((packet[24] << 24) + (packet[25] << 16) + (packet[26] << 8) + packet[27]);
^
Sketch uses 15978 bytes (49%) of program storage space. Maximum is 32256 bytes.
Global variables use 634 bytes (30%) of dynamic memory, leaving 1414 bytes for local variables. Maximum is 2048 bytes.
avrdude: ser_open(): can't open device "\.COM5": The system cannot find the file specified.
Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
心理调试:data
和packet
是MPU6050::dmpGetAccel
的参数,你正在尝试将四个字节组合成一个单词。
您需要在uint32_t
s 而不是uint8_t
s 内进行算术,否则您总是会溢出值。
更改窗体的所有行
data[n] = ((packet[m] << 24) + (packet[m+1] << 16) + (packet[m+2] << 8) + packet[m+3]);
自
data[n] = ((uint32_t{ packet[m] } << 24) + (uint32_t{ packet[m+1] } << 16) + (uint32_t{ packet[m+2] } << 8) + uint32_t{ packet[m+3] });
相关文章:
- 检查编译时是否存在静态函数
- 我正在尝试制作一个自平衡机器人,但编译时存在错误。我不知道如何解决它
- Microsoft Visual Studio 2019交叉编译CMake库 - 有效,但存在SEG错误
- 使用c++的gSOAP中的stdsoap2.cpp中存在编译错误
- 为什么 GCC 和 clang 之间编译的 c++17 lambda 存在差异?
- 为什么以下代码片段存在编译错误
- 如何在C++编译时检查运算符的特定重载是否存在
- 编译时日志/ilogb 是否存在
- 编译示例 Cinder 项目时存在大量未解决的外部问题
- C 编译时间检查模板类型中是否存在方法
- 使用SFINAE检测编译时间是否存在过载的独立式功能
- 使用clang编译时regex-segfault,可能存在编译器错误
- .so中存在的符号已编译.o引用了它,但链接失败
- 为什么Visual Studio 2015在Juce存在时无法编译带有"noexcept"的STL库?
- 编译时,复制构造函数/复制分配和正常功能调用优化之间是否存在任何区别
- 为什么复制此类中的构造函数、运算符=和引用存在编译问题
- C++.继承和初始化成员变量存在编译错误
- C++通过引用修改函数中的结构值(可能存在编译顺序问题)
- 避免基于模板运算符的存在编译某些行
- Arduino库中存在编译错误