我正在使用MPU6050 module测试我的Arduino Mega。我发现Jeff Rowberg为此编写了一个库。我尝试了他提供的this example。但是,在尝试验证草图时,Arduino IDE会产生大量错误。
我已经安装了Jeffs库。 (下图显示了库内容)
这是我得到的错误:
In file included from C:\Users\LordXaX\Documents\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:42,
from sketch_dec08a.cpp:50:
C:\Users\LordXaX\Documents\Arduino\libraries\MPU6050/MPU6050.h:792: warning: only initialized variables can be placed into program memory area
In file included from sketch_dec08a.cpp:50:
C:\Users\LordXaX\Documents\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:89: warning: only initialized variables can be placed into program memory area
C:\Users\LordXaX\Documents\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:89: error: conflicting declaration 'const prog_uchar dmpMemory [1929]'
C:\Users\LordXaX\Documents\Arduino\libraries\MPU6050/MPU6050.h:792: error: 'dmpMemory' has a previous declaration as 'prog_uchar dmpMemory [1929]'
C:\Users\LordXaX\Documents\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:229: warning: only initialized variables can be placed into program memory area
C:\Users\LordXaX\Documents\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:271: warning: only initialized variables can be placed into program memory area
C:\Users\LordXaX\Documents\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:271: error: conflicting declaration 'const prog_uchar dmpUpdates [47]'
C:\Users\LordXaX\Documents\Arduino\libraries\MPU6050/MPU6050.h:931: error: 'dmpUpdates' has a previous declaration as 'uint8_t dmpUpdates [29][9]'
C:\Users\LordXaX\Documents\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:281: error: no 'uint8_t MPU6050::dmpInitialize()' member function declared in class 'MPU6050'
C:\Users\LordXaX\Documents\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:506: error: no 'bool MPU6050::dmpPacketAvailable()' member function declared in class 'MPU6050'
C:\Users\LordXaX\Documents\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:533: error: no 'uint8_t MPU6050::dmpGetAccel(int32_t*, const uint8_t*)' member function declared in class 'MPU6050'
C:\Users\LordXaX\Documents\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:541: error: no 'uint8_t MPU6050::dmpGetAccel(int16_t*, const uint8_t*)' member function declared in class 'MPU6050'
C:\Users\LordXaX\Documents\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:549: error: no 'uint8_t MPU6050::dmpGetAccel(VectorInt16*, const uint8_t*)' member function declared in class 'MPU6050'
C:\Users\LordXaX\Documents\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:557: error: no 'uint8_t MPU6050::dmpGetQuaternion(int32_t*, const uint8_t*)' member function declared in class 'MPU6050'
C:\Users\LordXaX\Documents\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:566: error: no 'uint8_t MPU6050::dmpGetQuaternion(int16_t*, const uint8_t*)' member function declared in class 'MPU6050'
C:\Users\LordXaX\Documents\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:575: error: no 'uint8_t MPU6050::dmpGetQuaternion(Quaternion*, const uint8_t*)' member function declared in class 'MPU6050'
C:\Users\LordXaX\Documents\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:590: error: no 'uint8_t MPU6050::dmpGetGyro(int32_t*, const uint8_t*)' member function declared in class 'MPU6050'
C:\Users\LordXaX\Documents\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:598: error: no 'uint8_t MPU6050::dmpGetGyro(int16_t*, const uint8_t*)' member function declared in class 'MPU6050'
C:\Users\LordXaX\Documents\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:608: error: no 'uint8_t MPU6050::dmpGetLinearAccel(VectorInt16*, VectorInt16*, VectorFloat*)' member function declared in class 'MPU6050'
C:\Users\LordXaX\Documents\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:616: error: no 'uint8_t MPU6050::dmpGetLinearAccelInWorld(VectorInt16*, VectorInt16*, Quaternion*)' member function declared in class 'MPU6050'
C:\Users\LordXaX\Documents\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:628: error: no 'uint8_t MPU6050::dmpGetGravity(VectorFloat*, Quaternion*)' member function declared in class 'MPU6050'
C:\Users\LordXaX\Documents\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:639: error: no 'uint8_t MPU6050::dmpGetEuler(float*, Quaternion*)' member function declared in class 'MPU6050'
C:\Users\LordXaX\Documents\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:645: error: no 'uint8_t MPU6050::dmpGetYawPitchRoll(float*, Quaternion*, VectorFloat*)' member function declared in class 'MPU6050'
C:\Users\LordXaX\Documents\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:658: error: no 'uint8_t MPU6050::dmpProcessFIFOPacket(const unsigned char*)' member function declared in class 'MPU6050'
C:\Users\LordXaX\Documents\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:668: error: no 'uint8_t MPU6050::dmpReadAndProcessFIFOPacket(uint8_t, uint8_t*)' member function declared in class 'MPU6050'
C:\Users\LordXaX\Documents\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:693: error: no 'uint16_t MPU6050::dmpGetFIFOPacketSize()' member function declared in class 'MPU6050'
sketch_dec08a.cpp: In function 'void setup()':
sketch_dec08a.cpp:177: warning: only initialized variables can be placed into program memory area
sketch_dec08a.cpp:181: warning: only initialized variables can be placed into program memory area
sketch_dec08a.cpp:182: warning: only initialized variables can be placed into program memory area
sketch_dec08a.cpp:182: warning: only initialized variables can be placed into program memory area
sketch_dec08a.cpp:185: warning: only initialized variables can be placed into program memory area
sketch_dec08a.cpp:191: warning: only initialized variables can be placed into program memory area
sketch_dec08a:187: error: 'class MPU6050' has no member named 'dmpInitialize'
sketch_dec08a.cpp:197: warning: only initialized variables can be placed into program memory area
sketch_dec08a.cpp:201: warning: only initialized variables can be placed into program memory area
sketch_dec08a:198: error: 'class MPU6050' has no member named 'getIntStatus'
sketch_dec08a.cpp:206: warning: only initialized variables can be placed into program memory area
sketch_dec08a:205: error: 'class MPU6050' has no member named 'dmpGetFIFOPacketSize'
sketch_dec08a.cpp:216: warning: only initialized variables can be placed into program memory area
sketch_dec08a.cpp:218: warning: only initialized variables can be placed into program memory area
sketch_dec08a.cpp: In function 'void loop()':
sketch_dec08a:246: error: 'class MPU6050' has no member named 'getIntStatus'
sketch_dec08a.cpp:260: warning: only initialized variables can be placed into program memory area
sketch_dec08a:263: error: 'class MPU6050' has no member named 'getFIFOBytes'
我如何克服这个问题?
我一直在努力使用这个设备来获得加速度/陀螺仪值。但仍然没有成功。
修改
这是我在尝试编译(验证)时得到的。
答案 0 :(得分:4)
Jeff提供的MPU6050_DMP6示例适用于我。从您的编译错误,似乎您已包含MPU6050.h,而不是MPU6050_6Axis_MotionApps20.h。确保包含正确的。
如果查看library code,您会注意到.dmp_ _ _方法未在MPU6050.cpp文件中实现,而是在MPU6050_6Axis_MotionApps20.h文件中实现。如果这不能解决问题,请发布您的代码。
答案 1 :(得分:2)
尝试将jeffs i2c .cpp和.h文件放入与mpu6050库文件相同的文件夹中,我发现这对我有用,对不起,如果这是一个迟到但希望有用的话:P
答案 2 :(得分:1)
我遇到了同样的问题,事实证明我包括了这两个问题 MPU6050.h和MPU6050_6Axis_MotionApps20.h。我注释掉了MPU6050.h,它现在编译得很好。似乎前者压倒了后者。
答案 3 :(得分:1)
我已经通过将I2Cdev.cpp和I2C.h放在MPU6050库文件夹中解决了编译问题。 (介意:这些是 dev 文件)。这些是杰夫的图书馆,可以在GitHub
找到