我正在尝试制作一个自平衡机器人,但编译时存在错误。我不知道如何解决它

I am trying to make a self balancing robot, but there is an error in compiling. I don't know how to fix it

本文关键字:存在 编译 错误 何解决 我不知道 解决 平衡机 平衡 一个 机器人      更新时间:2023-10-16
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.

心理调试:datapacketMPU6050::dmpGetAccel的参数,你正在尝试将四个字节组合成一个单词。

您需要在uint32_ts 而不是uint8_ts 内进行算术,否则您总是会溢出值。

更改窗体的所有行

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] });