Code Monkey home page Code Monkey logo

Comments (23)

arthurvanl avatar arthurvanl commented on June 25, 2024

Oke nvm i made a mistake, i added accel before i shouldve added gyro.
But it still does not work entirely.

        const madgwick = new AHRS({
            /*
             * The sample interval, in Hz.
             *
             * Default: 20
             */
            sampleInterval: 10,
          
            /*
             * Choose from the `Madgwick` or `Mahony` filter.
             *
             * Default: 'Madgwick'
             */
            algorithm: 'Mahony',
          
            /*
             * The filter noise value, smaller values have
             * smoother estimates, but have higher latency.
             * This only works for the `Madgwick` filter.
             *
             * Default: 0.4
             */
            beta: 0.4,
          
            /*
             * The filter noise values for the `Mahony` filter.
             */
            kp: 0.5, // Default: 0.5
            ki: 0, // Default: 0.0
          
            /*
             * When the AHRS algorithm runs for the first time and this value is
             * set to true, then initialisation is done.
             *
             * Default: false
             */
            doInitialisation: false,
          });

          madgwick.update(gyro_x, gyro_y, gyro_z, accel_x, accel_y, accel_z, magn_x, magn_y, magn_z);
          let quat= madgwick.getQuaternion();
        //   console.log(axes.pitch*57.295779513, axes.roll*57.295779513, axes.heading*57.295779513);
        console.log(quat)

When i do this, it goes back to its first value, and that should not be the case.

from ahrs.

psiphi75 avatar psiphi75 commented on June 25, 2024

I don't know what you mean "it goes back to its first value". You have turned of doInitialisation, this means you will need run to the uptate() function many times (around 100) until you get sensible values.

Unless you understand quarternions, I don't think you would want the print out the quaternion. The Euler angles make more sense.

from ahrs.

arthurvanl avatar arthurvanl commented on June 25, 2024

So if i turn my object the euler angles goes to like 1.2 or something and if i hold it still it goes back to 0.1 or something. It doesnt stay at the angle. I get data every 10 Hz because i use Serialport and i get there data every 10 Hz from

from ahrs.

psiphi75 avatar psiphi75 commented on June 25, 2024

What do your raw input and output values look like? I'd also suggest using the Madgwick filter.

from ahrs.

arthurvanl avatar arthurvanl commented on June 25, 2024

My raw input is from 1350 to -1350 or something

from ahrs.

psiphi75 avatar psiphi75 commented on June 25, 2024

I need more detail. 1350 is what? What are your raw x,y,z values for the accelerometer, gyroscope and magnetometer input? The values that you put into update().

from ahrs.

arthurvanl avatar arthurvanl commented on June 25, 2024
    madgwick.update(gyro_x, gyro_y, gyro_z, accel_x, accel_y, accel_z, magn_x, magn_y, magn_z);

This is what i put in, i have the chip LSM9DS1TR (simular to LSM9DS1)

from ahrs.

arthurvanl avatar arthurvanl commented on June 25, 2024

This is what i found

The LSM9DS1 is a high-resolution (16-bit) 9-axis motion sensor (accelerometer, gyroscope, and magnetometer) in a 3 mm x 3.5 mm LGA 28 pin package. Coupled with the fine 24-bit Measurement Specialties MS5611 altimeter, the Teensy 3.1 add-on/breakout board offers 10 degrees of freedom in a compact size for many motion control applications.

from ahrs.

psiphi75 avatar psiphi75 commented on June 25, 2024

Thank you, but what the actual values of gyro_x, gyro_y, gyro_z, accel_x, accel_y, accel_z, magn_x, magn_y, and magn_z?
For example accel_z might be something like 1.0.

from ahrs.

arthurvanl avatar arthurvanl commented on June 25, 2024

Its an integer, its never a float (by default values)

from ahrs.

psiphi75 avatar psiphi75 commented on June 25, 2024

from ahrs.

arthurvanl avatar arthurvanl commented on June 25, 2024

afbeelding
here u go

from ahrs.

psiphi75 avatar psiphi75 commented on June 25, 2024

Finally. Those values are not going to work. You need to convert them to the correct units. Your LSM9DS1 spec documentation will detail what units it outputs. See the Units section in the Readme.

from ahrs.

arthurvanl avatar arthurvanl commented on June 25, 2024

So i should devide the accelerometer by 9.81 and gyroscope by 0.07 (dps)

from ahrs.

arthurvanl avatar arthurvanl commented on June 25, 2024
        let accel_x = data.accel_x_mg/9.81, //velocity
            accel_y = data.accel_z_mg/9.81, //velocity
            accel_z = data.accel_y_mg/9.81, //velocity
            gyro_x = data.gyro_x_dps*0.07/57.295779513, //degrees per radians.
            gyro_y = data.gyro_z_dps*0.07/57.295779513, //degrees per radians.
            gyro_z = data.gyro_y_dps*0.07/57.295779513, //degrees per radians.

So i should do this?

from ahrs.

psiphi75 avatar psiphi75 commented on June 25, 2024

Your LSM9DS1 spec documentation will detail what "units" it outputs and you need to convert that to units suitable for this AHRS implementation.

Just multiplying the numbers "randomly" will not fix the issue.

from ahrs.

psiphi75 avatar psiphi75 commented on June 25, 2024

This is not the place to ask about the LSM9DS1 output. I'm closing this issue, since this is not a bug in AHRS.

from ahrs.

arthurvanl avatar arthurvanl commented on June 25, 2024

I tried using this one
https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&ved=2ahUKEwjor5SsydPzAhUnhf0HHcGBDLcQFnoECAYQAQ&url=https%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Fdatasheet%2Flsm9ds1.pdf&usg=AOvVaw3OWQldgPvlyX6jm-vp5niR

But im not understanding what i should change it to

from ahrs.

arthurvanl avatar arthurvanl commented on June 25, 2024

Also if i do this

let thetaM = Math.atan2(accel_x, Math.sqrt(accel_y*accel_y+accel_z*accel_z));
        let phiM = Math.atan2(accel_y, Math.sqrt(accel_x*accel_x+accel_z*accel_z))
        console.log(thetaM*57.295779513, phiM*57.295779513)

I get correct angles

from ahrs.

psiphi75 avatar psiphi75 commented on June 25, 2024

Please understand, I'm not here to support you for unrelated issues. This forum is for logging bugs against AHRS. If you have questions like this you can go to stackoverflow.com, or similar.

from ahrs.

arthurvanl avatar arthurvanl commented on June 25, 2024

its kinda a bug tho, because it works with that formula and not with your thing

from ahrs.

arthurvanl avatar arthurvanl commented on June 25, 2024

afbeelding
This are my units, so i divide them correctly

from ahrs.

psiphi75 avatar psiphi75 commented on June 25, 2024

This is my last comment on this thread. The units you have shown me are wrong. The page you show me tells me you don't understand the problem. Your problem is with the output of the LSM9SD1, not this library. You should use "duckduckgo" and search for "LSM9DS1 tutorial".

The units of required by AHRS is are as follows:

  • gyroscope: in radians per second, so when stationary these average around zero, typically around +/-0.001 just due to noise. When you constantly rotate it 180 degrees in 1 second one axis will go up to PI/2.0.
  • accelerometer - in g, so the values when stationary will range from -1.0 to 1.0. Such that sqrt(a_x*a_x + a_y*a_y + a_z*a_z) is around 1.0.
  • Magnetometer - values are proportional to the Earth's magnetic field. These units you have look reasonable.

from ahrs.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.