This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script will create a graph with a light grey grid to see the spacing between values | |
# The axis will be visible only on the bottom and left, and both the axis and labels will | |
# be light blue/green | |
import matplotlib | |
import matplotlib.pyplot as plt | |
matplotlib.use("pgf") | |
matplotlib.rcParams.update( | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def convert_acc(acc): | |
"""Convert raw accelerometer measurements in roll pitch yaw | |
https://stackoverflow.com/questions/3755059/3d-accelerometer-calculate-the-orientation | |
The yaw equation comes from here https://robotics.stackexchange.com/questions/14305/yaw-from-accelerometer-no-so-what-do-these-equations-actually-mean | |
If you have a magnetometer check out https://habr.com/en/post/499190/ | |
Args: | |
acc (np.array): Array containing the three raw measurements on the accelerometer along | |
x, y, z | |
Returns: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Tuple | |
import numpy as np | |
class BaseKF: | |
"""This class can hold either a Kalman filter or an extended kalman filter depending on | |
the way f and h are implemented. | |
""" | |
def __init__(self, z0: np.array, r: np.array, q: np.array, pval=0.1) -> None: | |
self.x_sk = z0 | |
self.n = q.shape[0] # number of state |