I need to rotate acceleration data with the quaternion result of a ahrs. Initially, I tried to implement a very simple attitude estimator in C# (IMU Attitude Estimation from Angular Velocity rotates by roughly half the expected value. Why?), but that didn't produce the results I need. Hence, I decided to give the ahrs package in Python a try. Before actually feeding the system sensor data, though, I just want to understand the handling. Therefore, I am just rotating a vector (up = [0.,1.,0.]) with a Quaternion by 90 degree around the z axis. What I expect is a vector that points along the negative x-axis. What I get is the positive z-axis. Can anyone explain what I am missing?
# -*- coding: utf-8 -*-
"""
Created on Tue Jul 5 16:17:04 2022
"""
from ahrs.filters import Madgwick
from ahrs import Quaternion
from ahrs import DEG2RAD # Helper variable to convert angles to radians
import numpy as np
angles = np.array([0.0, 0.0, 90.0])*DEG2RAD
q = Quaternion(rpy=angles)
print(q)
up = [0.,1.,0.]
left = q.rotate(up)
print (left)
Result
!next
[ 0.00000000e+00 -2.22044605e-16 1.00000000e+00]
--Return--