Closed AlexFundorin closed 3 years ago
While I would like to say I'm a good programmer (more of a hobby) much of my coding is not perfect but does compile when some of the official rules are ignored :) -fpermissive is: When you've written something that isn't allowed by the language standard (and therefore can't really be well-defined behavior, which is reason enough to not do it) but happens to map to some kind of executable if fed naïvely to the compiling engine
I compile with the -fpermissive option as if I didn't I would be troubleshooting forever lol Please feel free to help me correct my coding errors to better this library.
A lot of errors in the DMP_image.h and lib I just removed some:
/ These defines are copied from dmpDefaultMPU6050.c in the general MPL releases. These defines may change for each DMP image, so be sure to modify these values when switching to a new image. /
/ The mounting matrix below tells the MPL how to rotate the raw data from the driver(s). The matrix below reflects the axis orientation of the MPU-6050 on the nav6 circuit board. /
/ for your understanding this is the Gyro orentation Hard coded into the MPU With this instance of the DMP static signed char gyro_orientation[9] = { 1, 0, 0, 0, 1, 0, 0, 0, 1 }; /
/* This is a pre Configured Version of the Embedded MotionDriver 6.12 Firmware instance.
// Helper Math Classes class Quaternion { public: float w; float x; float y; float z;
Quaternion() { w = 1.0f; x = 0.0f; y = 0.0f; z = 0.0f; } Quaternion(float n) { setQuaternion(n[0], n[1], n[2], n[3]); } Quaternion(long n) { setQuaternion((float)n[0], (float)n[1], (float)n[2], (float)n[3]); } Quaternion setQuaternion(float n) { setQuaternion(n[0], n[1], n[2], n[3]); } Quaternion setQuaternion(long n) { setQuaternion((float)n[0], (float)n[1], (float)n[2], (float)n[3]); } Quaternion(float nw, float nx, float ny, float nz) { setQuaternion(nw, nx, ny, nz); } Quaternion setQuaternion(float nw, float nx, float ny, float nz) { w = nw; x = nx; y = ny; z = nz; } Quaternion getProduct(Quaternion q) { // Quaternion multiplication is defined by: // (Q1 Q2).w = (w1w2 - x1x2 - y1y2 - z1z2) // (Q1 Q2).x = (w1x2 + x1w2 + y1z2 - z1y2) // (Q1 Q2).y = (w1y2 - x1z2 + y1w2 + z1x2) // (Q1 Q2).z = (w1z2 + x1y2 - y1x2 + z1w2 return Quaternion( wq.w - xq.x - yq.y - zq.z, // new w wq.x + xq.w + yq.z - zq.y, // new x wq.y - xq.z + yq.w + zq.x, // new y wq.z + xq.y - yq.x + zq.w); // new z }
Quaternion getConjugate() { return Quaternion(w, -x, -y, -z); }
float getMagnitude() { return sqrt(ww + xx + yy + zz); }
//Quaternion :: normalize() { Quaternion normalize() { float m = getMagnitude(); // w /= m; // x /= m; // y /= m; // z /= m; //return this; return Quaternion( w /= m, // new w x /= m, // new x y /= m, // new y z /= m); // new z }
Quaternion getNormalized() { Quaternion r(w, x, y, z); r.normalize(); return r; } };
class VectorInt16 { public: int16_t x; int16_t y; int16_t z;
VectorInt16() { x = 0; y = 0; z = 0; }
VectorInt16(int16_t nx, int16_t ny, int16_t nz) { x = nx; y = ny; z = nz; }
float getMagnitude() { return sqrt((float)x(float)x + (float)y(float)y + (float)z*(float)z); }
//VectorInt16 :: normalize() { VectorInt16 normalize() { float m = getMagnitude(); // x /= m; // y /= m; // z /= m; //return this; return VectorInt16(x /= m,y /= m,z /= m); }
VectorInt16 getNormalized() { VectorInt16 r(x, y, z); r.normalize(); return r; }
VectorInt16 rotate(Quaternion *q) { // http://www.cprogramming.com/tutorial/3d/quaternions.html // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/transforms/index.htm // http://content.gpwiki.org/index.php/OpenGL:Tutorials:Using_Quaternions_to_represent_rotation // ^ or: http://webcache.googleusercontent.com/search?q=cache:xgJAp3bDNhQJ:content.gpwiki.org/index.php/OpenGL:Tutorials:Using_Quaternions_to_represent_rotation&hl=en&gl=us&strip=1
// P_out = q * P_in * conj(q)
// - P_out is the output vector
// - q is the orientation quaternion
// - P_in is the input vector (a*aReal)
// - conj(q) is the conjugate of the orientation quaternion (q=[w,x,y,z], q*=[w,-x,-y,-z])
Quaternion p(0, x, y, z);
// quaternion multiplication: q * p, stored back in p
p = q -> getProduct(p);
// quaternion multiplication: p * conj(q), stored back in p
p = p.getProduct(q -> getConjugate());
// p quaternion is now [0, x', y', z']
// x = p.x; // y = p.y; // z = p.z; // return this; return VectorInt16(p.x,p.y,p.z); }
VectorInt16 getRotated(Quaternion *q) { VectorInt16 r(x, y, z); r.rotate(q); return r; } };
class VectorFloat { public: float x; float y; float z;
VectorFloat() { x = 0; y = 0; z = 0; }
VectorFloat(float nx, float ny, float nz) { x = nx; y = ny; z = nz; }
float getMagnitude() { return sqrt(xx + yy + z*z); }
VectorFloat normalize() { float m = getMagnitude(); // x /= m; // y /= m; // z /= m; // return this; return VectorFloat( x /= m,y /= m,z /= m); }
VectorFloat getNormalized() { VectorFloat r(x, y, z); r.normalize(); return r; }
VectorFloat rotate(Quaternion *q) { Quaternion p(0, x, y, z);
// quaternion multiplication: q * p, stored back in p
p = q -> getProduct(p);
// quaternion multiplication: p * conj(q), stored back in p
p = p.getProduct(q -> getConjugate());
// p quaternion is now [0, x', y', z']
// x = p.x; // y = p.y; // z = p.z; //return this; return VectorFloat( p.x,p.y,p.z); }
VectorFloat getRotated(Quaternion *q) { VectorFloat r(x, y, z); r.rotate(q); return r; } };
Thank you williamesp2015, I quickly scanned through Your attached code and transferred the changes I spotted to the project. Please see if I missed any. Thanks again Z
Hello. I still find some errors in DMP_Image.h. I could not even compile the example file. Here I copy the errors I have received:
In file included from /Users/diego/Documents/Arduino/libraries/Simple_MPU6050-master/Simple_MPU6050.h:7:0, from /Users/diego/Documents/Arduino/libraries/Simple_MPU6050-master/Examples/Simple_MPU6050_Example/Simple_MPU6050_Example.ino:3: /Users/diego/Documents/Arduino/libraries/Simple_MPU6050-master/DMP_Image.h: In member function 'int VectorInt16::normalize()': /Users/diego/Documents/Arduino/libraries/Simple_MPU6050-master/DMP_Image.h:581:44: error: cannot convert 'VectorInt16' to 'int' in return return VectorInt16(x /= m,y /= m,z /= m); ^ In file included from /Users/diego/Documents/Arduino/libraries/Simple_MPU6050-master/Simple_MPU6050.h:7:0, from /Users/diego/Documents/Arduino/libraries/Simple_MPU6050-master/Examples/Simple_MPU6050_Example/Simple_MPU6050_Example.ino:3: /Users/diego/Documents/Arduino/libraries/Simple_MPU6050-master/DMP_Image.h: In member function 'int VectorInt16::rotate(Quaternion)': /Users/diego/Documents/Arduino/libraries/Simple_MPU6050-master/DMP_Image.h:613:35: error: cannot convert 'VectorInt16' to 'int' in return return VectorInt16(p.x,p.y,p.z); ^ /Users/diego/Documents/Arduino/libraries/Simple_MPU6050-master/DMP_Image.h: In member function 'int VectorFloat::normalize()': /Users/diego/Documents/Arduino/libraries/Simple_MPU6050-master/DMP_Image.h:651:45: error: cannot convert 'VectorFloat' to 'int' in return return VectorFloat( x /= m,y /= m,z /= m); ^ /Users/diego/Documents/Arduino/libraries/Simple_MPU6050-master/DMP_Image.h: In member function 'int VectorFloat::rotate(Quaternion)': /Users/diego/Documents/Arduino/libraries/Simple_MPU6050-master/DMP_Image.h:674:37: error: cannot convert 'VectorFloat' to 'int' in return return VectorFloat( p.x,p.y,p.z); ^ exit status 1 Error compiling for board Arduino Uno.
Hi, I still have errors with the compilation:
In file included from C:\Users\PC\Documents\Arduino\sketch_sep18c\sketch_sep18c.ino:3:0: C:\Users\PC\Documents\Arduino\libraries\Simple_MPU6050-master/MPU_WriteMacros.h:313:0: warning: "EXT_I2C_ST1_READ_BYTE" redefined
C:\Users\PC\Documents\Arduino\libraries\Simple_MPU6050-master/MPU_WriteMacros.h:309:0: note: this is the location of the previous definition
C:\Users\PC\Documents\Arduino\libraries\Simple_MPU6050-master/MPU_WriteMacros.h:413:0: warning: "AKM_POWER_DOWN" redefined
C:\Users\PC\Documents\Arduino\libraries\Simple_MPU6050-master/MPU_WriteMacros.h:363:0: note: this is the location of the previous definition
C:\Users\PC\Documents\Arduino\libraries\Simple_MPU6050-master/MPU_WriteMacros.h:415:0: warning: "AKM_FUSE_ROM_ACCESS" redefined
C:\Users\PC\Documents\Arduino\libraries\Simple_MPU6050-master/MPU_WriteMacros.h:369:0: note: this is the location of the previous definition
In file included from C:\Users\PC\Documents\Arduino\sketch_sep18c\sketch_sep18c.ino:1:0:
C:\Users\PC\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:575:28: warning: ISO C++ forbids declaration of 'normalize' with no type [-fpermissive]
VectorInt16 :: normalize() {
^
C:\Users\PC\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:575:3: warning: extra qualification 'VectorInt16::' on member 'normalize' [-fpermissive]
VectorInt16 :: normalize() {
^~~
C:\Users\PC\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:590:38: warning: ISO C++ forbids declaration of 'rotate' with no type [-fpermissive]
VectorInt16 :: rotate(Quaternion q) {
^
C:\Users\PC\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:590:3: warning: extra qualification 'VectorInt16::' on member 'rotate' [-fpermissive]
VectorInt16 :: rotate(Quaternion q) {
^~~
C:\Users\PC\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h: In member function 'int VectorInt16::normalize()':
C:\Users\PC\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:581:44: error: cannot convert 'VectorInt16' to 'int' in return
return VectorInt16(x /= m,y /= m,z /= m);
^
In file included from C:\Users\PC\Documents\Arduino\sketch_sep18c\sketch_sep18c.ino:1:0:
C:\Users\PC\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h: In member function 'int VectorInt16::rotate(Quaternion)':
C:\Users\PC\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:613:35: error: cannot convert 'VectorInt16' to 'int' in return
return VectorInt16(p.x,p.y,p.z);
^
C:\Users\PC\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h: At global scope:
C:\Users\PC\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:645:28: warning: ISO C++ forbids declaration of 'normalize' with no type [-fpermissive]
VectorFloat :: normalize() {
^
C:\Users\PC\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:645:3: warning: extra qualification 'VectorFloat::' on member 'normalize' [-fpermissive]
VectorFloat :: normalize() {
^~~
C:\Users\PC\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:660:38: warning: ISO C++ forbids declaration of 'rotate' with no type [-fpermissive]
VectorFloat :: rotate(Quaternion q) {
^
C:\Users\PC\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:660:3: warning: extra qualification 'VectorFloat::' on member 'rotate' [-fpermissive]
VectorFloat :: rotate(Quaternion q) {
^~~
C:\Users\PC\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h: In member function 'int VectorFloat::normalize()':
C:\Users\PC\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:651:45: error: cannot convert 'VectorFloat' to 'int' in return
return VectorFloat( x /= m,y /= m,z /= m);
^
C:\Users\PC\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h: In member function 'int VectorFloat::rotate(Quaternion)':
C:\Users\PC\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:674:37: error: cannot convert 'VectorFloat' to 'int' in return
return VectorFloat( p.x,p.y,p.z);
^
In file included from C:\Users\PC\Documents\Arduino\sketch_sep18c\sketch_sep18c.ino:4:0:
C:\Users\PC\Documents\Arduino\libraries\Simple_MPU6050-master/Simple_MPU6050.h: At global scope:
C:\Users\PC\Documents\Arduino\libraries\Simple_MPU6050-master/Simple_MPU6050.h:21:5: warning: 'typedef' was ignored in this declaration
typedef struct SensorList_s {
^~~
C:\Users\PC\Documents\Arduino\libraries\Simple_MPU6050-master/Simple_MPU6050.h:33:5: warning: 'typedef' was ignored in this declaration
typedef union AccelGyro_u {
^~~
exit status 1
Error compilando para la tarjeta Arduino Nano.
Hola. Todavía encuentro algunos errores en DMP_Image.h. Ni siquiera pude compilar el archivo de ejemplo. Aquí copio los errores que he recibido:
En archivo incluido de /Users/diego/Documents/Arduino/libraries/Simple_MPU6050-master/Simple_MPU6050.h:7:0, de /Users/ diego/Documents/Arduino/libraries/ Simple_MPU6050- master/Examples/ Simple_MPU6050_Example : 3: /Users/diego/Documents/Arduino/libraries/Simple_MPU6050-master/DMP_Image.h: En la función miembro 'int VectorInt16 :: normalize ()': / Users / diego / Documents / Arduino / libraries / Simple_MPU6050-master / DMP_Image.h: 581: 44: error: no se puede convertir 'VectorInt16' a 'int' a cambio return VectorInt16 (x / = m, y / = m, z / = m); ^ En archivo incluido de /Users/diego/Documents/Arduino/libraries/Simple_MPU6050-master/Simple_MPU6050.h:7:0, de /Users/diego/Documents/Arduino/libraries/Simple_MPU6050-master/Examples/Simple_MPU6050_Example/Simple_MPU6050_Example.ino:3: / Users/ diego/ Documents/ Arduino/ libraries/ Simple_Masterh/ DU6050 miembro VectorInt16 :: rotate (Quaternion ) ': /Users/diego/Documents/Arduino/libraries/Simple_MPU6050-master/DMP_Image.h:613:35: error: no se puede convertir' VectorInt16 'a' int 'a cambio return VectorInt16 (px , py, pz); ^ /Users/diego/Documents/Arduino/libraries/Simple_MPU6050-master/DMP_Image.h: En la función miembro 'int VectorFloat :: normalize ()': / Users / diego / Documents / Arduino / libraries / Simple_MPU6050-master / DMP_Image. h: 651: 45: error: no se puede convertir 'VectorFloat' a 'int' ^ /Users/diego/Documents/Arduino/libraries/Simple_MPU6050-master/DMP_Image.h: En la función miembro 'int VectorFloat :: rotate (Quaternion )': / Users / diego / Documents / Arduino / libraries / Simple_MPU6050-master / DMP_Image.h: 674: 37: error: no se puede convertir 'VectorFloat' a 'int' a cambio return VectorFloat (px, py, pz); ^ estado de salida 1 Error al compilar para la placa Arduino Uno.
Hola por favor me podrias ayudar a resolver ese problema, me pasale exactamente igual no encuentro forma de solucionarlo :(
Try the latest version of the library i just uploaded Z
On Sat, Oct 2, 2021 at 4:34 PM Piero15 @.***> wrote:
Hola. Todavía encuentro algunos errores en DMP_Image.h. Ni siquiera pude compilar el archivo de ejemplo. Aquí copio los errores que he recibido:
En archivo incluido de /Users/diego/Documents/Arduino/libraries/Simple_MPU6050-master/Simple_MPU6050.h:7:0, de /Users/ diego/Documents/Arduino/libraries/ Simple_MPU6050- master/Examples/ Simple_MPU6050_Example : 3: /Users/diego/Documents/Arduino/libraries/Simple_MPU6050-master/DMP_Image.h: En la función miembro 'int VectorInt16 :: normalize ()': / Users / diego / Documents / Arduino / libraries / Simple_MPU6050-master / DMP_Image.h: 581: 44: error: no se puede convertir 'VectorInt16' a 'int' a cambio return VectorInt16 (x / = m, y / = m, z / = m); ^ En archivo incluido de /Users/diego/Documents/Arduino/libraries/Simple_MPU6050-master/Simple_MPU6050.h:7:0, de /Users/diego/Documents/Arduino/libraries/Simple_MPU6050-master/Examples/Simple_MPU6050_Example/Simple_MPU6050_Example.ino:3: / Users/ diego/ Documents/ Arduino/ libraries/ Simple_Masterh/ DU6050 miembro VectorInt16 :: rotate (Quaternion ) ': /Users/diego/Documents/Arduino/libraries/Simple_MPU6050-master/DMP_Image.h:613:35: error: no se puede convertir' VectorInt16 'a' int 'a cambio return VectorInt16 (px , py, pz); ^ /Users/diego/Documents/Arduino/libraries/Simple_MPU6050-master/DMP_Image.h: En la función miembro 'int VectorFloat :: normalize ()': / Users / diego / Documents / Arduino / libraries / Simple_MPU6050-master / DMP_Image. h: 651: 45: error: no se puede convertir 'VectorFloat' a 'int' ^ /Users/diego/Documents/Arduino/libraries/Simple_MPU6050-master/DMP_Image.h: En la función miembro 'int VectorFloat :: rotate (Quaternion )': / Users / diego / Documents / Arduino / libraries / Simple_MPU6050-master / DMP_Image.h: 674: 37: error: no se puede convertir 'VectorFloat' a 'int' a cambio return VectorFloat (px, py, pz); ^ estado de salida 1 Error al compilar para la placa Arduino Uno.
Hola por favor me podrias ayudar a resolver ese problema, me pasale exactamente igual no encuentro forma de solucionarlo :(
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ZHomeSlice/Simple_MPU6050/issues/1#issuecomment-932829011, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABA5GYKBWMS6LMWBRZRU65DUE6CGXANCNFSM4IQWAKTQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Why do I get lots of compilation errors like this: