Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

120
Views
How to convert LSM9DS1 MEMS sensor data to make euler angles or quaternions

Im trying to make a euler or quaternion angles using the MEMS sensor of LSM9DS1TR (simular to LSM9DS1) PDF File

        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.
            magn_x = data.magn_x_mG,
            magn_y = data.magn_z_mG,
            magn_z = data.magn_y_mG;

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)

With this code i get perfect degree angles. But those are only from -90 to 90. And i want to display an object to show how the sensor is moving. So i started using AHRS but this does not work. When i do

madgwick.update(gyro_x, gyro_y, gyro_z, accel_x, accel_y, accel_z, magn_x, magn_y, magn_z);
        let quat = madgwick.getQuaternion();

I get perfect 1 if i do

Math.sqrt(quat.w*quat.w+quat.x*quat.x+quat.y*quat.y+quat.z*quat.z);

But if convert the quat.x*57.295779513, it goes a bit up, but when i hold it still it doesnt stay at that degree angle, it goes back to something like 1 or 0 zero degrees.

How can i fix this?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!