kriswiner / LSM9DS0

LSM9DS0 9DOF sensor AHRS sketch
39 stars 16 forks source link

I'm getting an error that I can't understand #1

Closed gbernal closed 10 years ago

gbernal commented 10 years ago

Hi, I'm trying out your library, but when I try to compile I get the following error LSM9DS0_AHRS.ino: In function 'void setup()': LSM9DS0_AHRS:217: error: 'class LSM9DS0' has no member named 'setAccelABW' LSM9DS0_AHRS:217: error: 'class LSM9DS0' has no member named 'A_ABW_50'

I see the function setAccelABW in the cpp file, as well A_ABW_in the .h file. Why is arduino IDE yelling at me?

kriswiner commented 10 years ago

I've seen this kind of thing before. You have to make sure there is no other LSM9DS0 .cpp and .h file in your library folder. If you had downloaded Jim's library before the changes I made you could be pointing at the other previous library without the new setAccelABW function.

Kris

-----Original Message----- From: gbernal [mailto:notifications@github.com] Sent: April 18, 2014 10:36 AM To: kriswiner/LSM9DS0 Subject: [LSM9DS0] I'm getting an error that I can't understand (#1)

Hi, I'm trying out your library, but when I try to compile I get the following error LSM9DS0_AHRS.ino: In function 'void setup()': LSM9DS0_AHRS:217: error: 'class LSM9DS0' has no member named 'setAccelABW' LSM9DS0_AHRS:217: error: 'class LSM9DS0' has no member named 'A_ABW_50'

I see the function setAccelABW in the cpp file, as well A_ABW_in the .h file. Why is arduino IDE yelling at me?

Reply to this email directly or view it on GitHub https://github.com/kriswiner/LSM9DS0/issues/1 . https://github.com/notifications/beacon/6698410__eyJzY29wZSI6Ik5ld3NpZXM6Qm VhY29uIiwiZXhwaXJlcyI6MTcxMzQ2MTc0NiwiZGF0YSI6eyJpZCI6MzAzMzkzMzB9fQ==--8555 9d8f3127c3eb89fff23705a27a27d0b49faa.gif

gbernal commented 10 years ago

You are correct, I just renamed your library and it compiles fine now.

Thank you!

kriswiner commented 10 years ago

I'm glad you got it working. Please let me know how you like it and if you think it needs any improvements.

Kris

kriswiner commented 10 years ago

Odd that you are getting no data returned since my version is only a slightly modified form of the simple sketch that uses the same library. One difference is that I am using the interrupts like Jim in his more advanced sketch. If you don't have them, you will never read any data!

kriswiner commented 10 years ago

I just ran my sketch and when I pulled out the interrupts nothing happened, I still kept getting data, so its not that. But its possible there is something different about using the Teensy. I don't know. Can you get the sketch to work on a 3.3 V Pro Mini?

gbernal commented 10 years ago

Yes, I didn't realize about the interrupts until I had already commented here, I tried to delete the message, but I guess you always receive the email.: ) On a similar note, these are the values that I see now, oddly I get no acceleration and other values Heading: -71.88 Pitch, Roll: 0.00, 0.00 ax = 0.00 ay = 0.00 az = 0.00 mg gx = 0.53 gy = 1.01 gz = -6.70 deg/s mx = -537.29 my = -175.84 mz = 25.09 mG Yaw, Pitch, Roll: 0.00, 0.00, 0.00 q0 = 1.00 qx = 0.00 qy = 0.00 qz = 0.00 deltat = 0.0011

kriswiner commented 10 years ago

I just hooked up my LSM9DS0 to a Teensy 3.1 and verified the sketch works, all the sensors report with sensible values and I am getting serial output. The yaw, pitch, and roll are strange though. I wonder if the floating point arithmetic is somehow different on the Teensy 3.1!

gbernal commented 10 years ago

Thank you for your help Kris, I hooked up my LSM9DS0 to another Teensy 3.1 and I do see all values now. Pitch, Roll: 2.97, -49.31 ax = 63.96 ay = -696.35 az = 731.32 mg gx = -1.48 gy = 1.29 gz = -4.57 deg/s mx = -26.73 my = 218.51 mz = 480.77 mG Yaw, Pitch, Roll: 52.52, 1.36, -15.18 q0 = 0.82 qx = -0.12 qy = -0.07 qz = 0.56 deltat = 0.0014 Heading: 96.50 Pitch, Roll: 3.01, -49.92 ax = 64.09 ay = -696.66 az = 722.53 mg gx = -1.22 gy = 1.39 gz = -4.36 deg/s mx = -24.54 my = 215.27 mz = 434.63 mG Yaw, Pitch, Roll: 52.90, 1.34, -15.09 q0 = 0.81 qx = -0.11 qy = -0.07 qz = 0.57 deltat = 0.0014 Heading: 96.22 Pitch, Roll: 3.00, -49.90 ax = 63.66 ay = -694.46 az = 721.86 mg gx = -0.69 gy = 1.19 gz = -4.87 deg/s mx = -23.80 my = 218.38 mz = 465.94 mG Yaw, Pitch, Roll: 53.19, 1.18, -15.08 q0 = 0.81 qx = -0.11 qy = -0.07 qz = 0.57 deltat = 0.0025

kriswiner commented 10 years ago

That's more like what I would expect. But I am not getting that on my Teensy! The sensor data values are fine but the quaternion is changing very slowly. I looks like the math has been changed. What did you do differently? Or is it the case that the Teensy display a lot of variability in its processor functions?!

gbernal commented 10 years ago

I didn't do anything. I just uploaded your sketch into a Teensy with nothing attached to it. I can upload a larger logged if you would like me to.

kriswiner commented 10 years ago

Well now I've got a problem, since the Teensy is not behaving like I expect. It's always something...

gbernal commented 10 years ago

Maybe PaulStoffregen can help with the arithmetic? He was able to help me adjust the library for the HMC6343 to work with Teensy.

kriswiner commented 10 years ago

Did you say one of your Teensys worked and one did not?

gbernal commented 10 years ago

Yes, but it was because I milled a pcb shield to interface between Teensy and my electromyograph. Pin 2 connection was iffy, now the two Teensy work the same.

kriswiner commented 10 years ago

I just hooked up a new Teensy and I am having the same problem. The quaternian is changing very very slowly. How can we be having such a different response?

gbernal commented 10 years ago

Hmmm, One thing I'm doing is powering the 9dof with it's own 3.5 battery. Not sure if this is making a difference.

Here it is a larger log of the data that I'm receiving. The 9dof is just setting still on my desk

Heading: 105.31 Pitch, Roll: -8.16, -6.76 ax = -156.01 ay = -131.84 az = 977.60 mg gx = 1.35 gy = 0.87 gz = -9.33 deg/s mx = -16.30 my = 59.51 mz = 427.98 mG Yaw, Pitch, Roll: 63.36, 4.84, 35.34 q0 = 0.72 qx = 0.20 qy = 0.23 qz = 0.62 deltat = 0.0035 Heading: 103.10 Pitch, Roll: -8.09, -6.83 ax = -156.19 ay = -134.09 az = 981.87 mg gx = 1.49 gy = 1.31 gz = -8.50 deg/s mx = -14.22 my = 61.10 mz = 439.21 mG Yaw, Pitch, Roll: 63.67, 4.89, 36.13 q0 = 0.72 qx = 0.20 qy = 0.24 qz = 0.62 deltat = 0.0035 Heading: 104.87 Pitch, Roll: -8.13, -6.86 ax = -156.01 ay = -134.03 az = 978.45 mg gx = 2.00 gy = 0.37 gz = -9.23 deg/s mx = -15.99 my = 60.24 mz = 424.32 mG Yaw, Pitch, Roll: 63.21, 5.96, 33.09 q0 = 0.73 qx = 0.18 qy = 0.23 qz = 0.62 deltat = 0.0035 Heading: 105.62 Pitch, Roll: -7.96, -6.71 ax = -155.27 ay = -133.24 az = 988.83 mg gx = 1.29 gy = 0.96 gz = -9.45 deg/s mx = -17.15 my = 61.34 mz = 417.48 mG Yaw, Pitch, Roll: 63.41, 6.12, 33.93 q0 = 0.72 qx = 0.18 qy = 0.23 qz = 0.62 deltat = 0.0035 Heading: 107.01 Pitch, Roll: -8.01, -6.84 ax = -155.33 ay = -134.89 az = 984.07 mg gx = 1.91 gy = 0.68 gz = -9.32 deg/s mx = -18.86 my = 61.65 mz = 432.56 mG Yaw, Pitch, Roll: 63.70, 6.14, 34.62 q0 = 0.72 qx = 0.19 qy = 0.24 qz = 0.63 deltat = 0.0035 Heading: 106.07 Pitch, Roll: -8.14, -6.91 ax = -157.23 ay = -135.80 az = 981.32 mg gx = 1.20 gy = 1.05 gz = -8.36 deg/s mx = -18.13 my = 62.93 mz = 407.71 mG Yaw, Pitch, Roll: 63.91, 6.32, 35.46 q0 = 0.72 qx = 0.19 qy = 0.24 qz = 0.63 deltat = 0.0035 Heading: 106.23 Pitch, Roll: -8.04, -6.90 ax = -155.76 ay = -135.80 az = 983.03 mg gx = 1.38 gy = 1.11 gz = -9.19 deg/s mx = -18.55 my = 63.72 mz = 421.94 mG Yaw, Pitch, Roll: 63.48, 7.09, 32.43 q0 = 0.73 qx = 0.17 qy = 0.23 qz = 0.63 deltat = 0.0035 Heading: 105.03 Pitch, Roll: -8.12, -6.77 ax = -157.17 ay = -133.61 az = 983.89 mg gx = 1.61 gy = 0.86 gz = -9.24 deg/s mx = -16.54 my = 61.58 mz = 407.29 mG Yaw, Pitch, Roll: 63.71, 7.17, 33.22 q0 = 0.72 qx = 0.17 qy = 0.24 qz = 0.63 deltat = 0.0035 Heading: 106.95 Pitch, Roll: -8.02, -6.69 ax = -156.62 ay = -133.18 az = 989.20 mg gx = 2.50 gy = 1.04 gz = -9.20 deg/s mx = -19.04 my = 62.50 mz = 415.47 mG Yaw, Pitch, Roll: 63.93, 7.31, 34.06 q0 = 0.72 qx = 0.18 qy = 0.24 qz = 0.63 deltat = 0.0035 Heading: 104.44 Pitch, Roll: -8.15, -6.85 ax = -157.17 ay = -134.52 az = 981.14 mg gx = 1.86 gy = 0.49 gz = -9.30 deg/s mx = -15.75 my = 61.16 mz = 415.34 mG Yaw, Pitch, Roll: 64.24, 7.36, 34.92 q0 = 0.72 qx = 0.18 qy = 0.25 qz = 0.63 deltat = 0.0035 Heading: 105.19 Pitch, Roll: -8.09, -6.74 ax = -156.62 ay = -132.93 az = 984.25 mg gx = 2.04 gy = 1.02 gz = -9.83 deg/s mx = -16.42 my = 60.49 mz = 407.17 mG Yaw, Pitch, Roll: 63.61, 8.10, 31.82 q0 = 0.73 qx = 0.16 qy = 0.23 qz = 0.63 deltat = 0.0035 Heading: 103.03 Pitch, Roll: -7.94, -6.84 ax = -155.52 ay = -135.99 az = 989.38 mg gx = 2.09 gy = 0.65 gz = -9.59 deg/s mx = -14.22 my = 61.46 mz = 418.33 mG Yaw, Pitch, Roll: 63.89, 8.17, 32.69 q0 = 0.72 qx = 0.16 qy = 0.24 qz = 0.63 deltat = 0.0035 Heading: 103.92 Pitch, Roll: -8.11, -6.83 ax = -156.43 ay = -134.16 az = 981.99 mg gx = 1.24 gy = 1.14 gz = -9.10 deg/s mx = -16.36 my = 65.98 mz = 440.73 mG Yaw, Pitch, Roll: 64.11, 8.27, 33.62 q0 = 0.72 qx = 0.17 qy = 0.24 qz = 0.63 deltat = 0.0035 Heading: 103.25 Pitch, Roll: -8.06, -6.87 ax = -154.97 ay = -134.22 az = 979.68 mg gx = 1.85 gy = 0.69 gz = -9.41 deg/s mx = -14.53 my = 61.71 mz = 411.44 mG Yaw, Pitch, Roll: 64.35, 8.40, 34.52 q0 = 0.72 qx = 0.17 qy = 0.25 qz = 0.63 deltat = 0.0035 Heading: 106.00 Pitch, Roll: -8.06, -6.84 ax = -155.33 ay = -134.09 az = 981.26 mg gx = 1.67 gy = 0.50 gz = -8.88 deg/s mx = -17.40 my = 60.67 mz = 414.67 mG Yaw, Pitch, Roll: 63.75, 8.95, 31.38 q0 = 0.73 qx = 0.15 qy = 0.24 qz = 0.63 deltat = 0.0035 Heading: 107.26 Pitch, Roll: -8.10, -6.87 ax = -155.58 ay = -134.28 az = 979.00 mg gx = 1.59 gy = 0.79 gz = -8.95 deg/s mx = -19.47 my = 62.68 mz = 415.41 mG Yaw, Pitch, Roll: 64.00, 9.13, 32.31 q0 = 0.72 qx = 0.15 qy = 0.24 qz = 0.63 deltat = 0.0035 Heading: 106.01 Pitch, Roll: -8.03, -6.85 ax = -155.33 ay = -134.89 az = 983.22 mg gx = 1.76 gy = 0.65 gz = -8.70 deg/s mx = -17.15 my = 59.75 mz = 418.76 mG Yaw, Pitch, Roll: 64.28, 9.15, 33.07 q0 = 0.72 qx = 0.16 qy = 0.25 qz = 0.63 deltat = 0.0035 Heading: 107.84 Pitch, Roll: -8.14, -6.82 ax = -157.10 ay = -134.22 az = 981.99 mg gx = 1.29 gy = 0.84 gz = -9.20 deg/s mx = -20.63 my = 64.09 mz = 415.65 mG Yaw, Pitch, Roll: 64.52, 9.29, 34.03 q0 = 0.72 qx = 0.16 qy = 0.25 qz = 0.63 deltat = 0.0035 Heading: 106.76 Pitch, Roll: -8.12, -6.78 ax = -156.68 ay = -133.36 az = 982.18 mg gx = 1.61 gy = 0.93 gz = -9.20 deg/s mx = -17.70 my = 58.78 mz = 418.76 mG Yaw, Pitch, Roll: 63.80, 9.82, 30.98 q0 = 0.73 qx = 0.14 qy = 0.24 qz = 0.63

kriswiner commented 10 years ago

Yours isn't working right either. The pitch and roll reported via quaternions should be pretty much the same as that calculated with the simpler approach. Also, your gyros should not be registering 9 deg/s rotation. If you slowly spin the sensor around while it is sitting on the table (rotate about the z-axis), does the yaw respond quickly to the change in x- and y-axis orientation? Mine does not...unless I am using the Pro Mini.

gbernal commented 10 years ago

You are right, It takes a few seconds to increase or decrease. Darn..

gbernal commented 10 years ago

I'm doing a project where I'm collecting data( muscle activity, speed) from master craftsman and I'm hopping to use that data to see if you can shorten the time at early stages of learning hand crafts. I'm taking three EMG channels and visualizing the data on a arm band. On the arm band there are three led strips that will provide visual feedback as to how much effort you are doing and other comparators. I was hopping to visualize the motion in which the arm is moving when the master craftsman is working on a pottery wheel (up ward motion). Do you have any thoughts as to which of these sensor data will be more helpful to me ? I have been thinking to generate a vector and try to calculate angular motion, something along those lines, I'm diving deep into this subject trying to get my head around all these concepts that I have't use in a while.

kriswiner commented 10 years ago

I you (we) can get the Teensy to behave, or if you switch to a 3.3 V 8 MHz Pro Mini Arduino microcontroller, the quaternion sensor-fused absolute orientation output at ~150 Hz is just what you want. It is easy to convert the quaternions into a rotation matrix to track arm orintation relative to a fixed frame of reference. In addition, you might want to incorporate a good pressure sensor like the BMP085 to track strictly up and down movement; these pressure sensors can detect changes in altitude of 10s of centimeters or better. I'll ask Paul what might be wrong with the Teensy math.

gbernal commented 10 years ago

Sounds good, Thank you for the advice. I hope Paul has the answer (He seems to have all the answers, he is 4 for 4 so far haha)

gbernal commented 10 years ago

Hi Kris,

I think I have found (or been told) what the cause of the issue might be. Given both the AVR processor (such as the Arduino Pro) and the Teensy 3.x do software emulation of floating point, and the Teensy is a 32-bit processor, and the clock speed is 12 times faster, you would expect the Teensy to run much faster.

In glancing at the code, I see calls to the various math functions (sqrt, atan,and atan2). These are done in double precision rather the single precision that most of the rest of the calculations are done in. If you do stuff in double precision, it takes more time to calculate the excess mantissa bits that are then thrown away (and the conversion between single precision and double precision adds to the cost). Try changing the calls to sqrtf, atanf, and atan2f, and see if it speeds things up. On the AVR processors, this is not an issue, since the 'double' type is mapped to 'float', so you are using the single precision versions of the library any way.

The other thought might be the processor is more optimized to 32-bit integers over 16-bit integers, and changing the int16_t types to int32_t might help (but you don't want to use int32_t on the AVR, so there you might want to have a type guarded by #ifdef to select the optimal type). However, compared to the floating point which predominates the calculations, I think this is a second order effect. I would check out the math functions first.

I have done some test adding "f" at the end of all the math functions and changing from int16_t to int32_t and it does seem to change the outputs. however I don't have an arduino pro 8mhz to compare the outputs.

Could you double check this with your setup? Thanks in advanced _G