I have a combination of a Gyroscope, accelerometer, and magnetometer and I am trying to use the madgwick algorithm to find the roll, pitch, and yaw angle. I found the following code in GutHub and tried to run it in Spyder (Python 3.9.13 (main, Aug 25 2022, 23:51:50) [MSC v.1916 64 bit (AMD64)] Type "copyright", "credits" or "license" for more information. IPython 7.31.1 -- An enhanced Interactive Python. But I am getting the error. "ModuleNotFoundError: No module named 'madgwickahrs"
This is the code:
import numpy as np
from ahrs.filters import QUEST
from ahrs.filters import Madgwick
from madgwickahrs import MadgwickAHRS
gyr = np.array( [1.6, 0.6, 1.5])
acc = np.array( [1.2, 1.9, 1.3])
mag = np.array( [2.1, 1.3, 2.1])
gyr_rad = gyr * (np.pi/180)
heading = MadgwickAHRS()
while True:
ninedofxyz = self._ninedof.read()
heading.update(ninedofxyz[0], ninedofxyz[2], ninedofxyz[1])
ahrs = heading.quaternion.to_euler_angles()
roll = ahrs[0]
pitch = ahrs[1]
yaw = ahrs[2]
Can anyone help me with this error!