Skip to content

Instantly share code, notes, and snippets.

View edxmorgan's full-sized avatar
🚀
burdened with glorious purpose

edward.ix edxmorgan

🚀
burdened with glorious purpose
View GitHub Profile
@edxmorgan
edxmorgan / t200.csv
Created February 3, 2025 17:30 — forked from patrickelectric/t200.csv
t200.csv
thrust 16V rpm 16V power 16V current 16V voltage 16V pwm 16V thrust (kgf) 16V efficiency (g/w) 16V thrust 12V rpm 12V power 12V current 12V voltage 12V pwm 12V thrust (kgf) 12V efficiency (g/w) 12V
-9 3200 344.48 21.53 14.98 1100 -4.082336185 11.85072046 -6.62 2960 182.2 15.4 11.83 1100 -3.00278506 16.48070835
-8.9 2767 341.92 21.37 15.25 1110 -4.082336185 11.93944836 -6.58 2870 181.03 15.19 11.92 1110 -2.984641344 16.48699853
-8.7 3245 328.96 20.56 15.33 1120 -4.086872114 12.42361416 -6.34 2837 169.05 14.25 11.86 1120 -2.875779046 17.0114111
-8.44 3269 305.12 19.07 15.35 1130 -3.828324156 12.54694597 -6.09 2784 160.31 13.48 11.89 1130 -2.762380818 17.2314941
-8.23 3269 289.12 18.07 15.35 1140 -3.733069645 12.91183469 -5.8 2750 146.97 12.38 11.87 1140 -2.630838875 17.90051626
-7.98 3186 272.16 17.01 15.35 1150 -3.619671417 13.2997921 -5.59 2693 138.13 11.66 11.85 1150 -2.535584364 18.35650738
-7.59 3141 254.56 15.91 15.35 1160 -3.442770183 13.52439575 -5.23 2655 129.74 10.95 11.85 1160 -2.372290916 18.2849615
@edxmorgan
edxmorgan / pseudoinverse_algorithm.py
Last active January 3, 2025 20:32
numerically stable pseudoinverse algorithm in casadi
import casadi as ca
def qr_eigen(A, iterations=100):
pQ = ca.SX.eye(A.size1())
X = ca.SX(A) # Make a copy in SX
for _ in range(iterations):
Q, R = ca.qr(X) # QR decomposition in CasADi
pQ = ca.mtimes(pQ, Q)
X = ca.mtimes(R, Q)
return ca.diag(X), pQ # (eigenvalues, eigenvectors)
@edxmorgan
edxmorgan / a50_dvl_tcp_client.py
Created December 26, 2024 05:16
a simple dvl-a50 tcp python client
import socket
import json
def receive_json_data(host='192.168.2.95', port=16171):
"""
Connects to a TCP server and receives JSON data.
Args:
host (str): The server's hostname or IP address.
port (int): The port number to connect to.
import asyncio
import aiohttp
import json
import sys
import signal
async def get_vision_position_delta(session, url):
try:
async with session.get(url) as response:
response.raise_for_status() # Raise exception for HTTP errors
import asyncio
import json
from urllib.parse import urlparse, parse_qs
import aiohttp
import websockets
import datetime
import csv
import os
import aiofiles
@edxmorgan
edxmorgan / bayesianEstimator.py
Created December 6, 2024 01:37
Bayesian Parameter updating
import numpy as np
import matplotlib.pyplot as plt
class BayesianParameterEstimator:
def __init__(self, param_min=0.0, param_max=5.0, num_points=500, known_variance=1.0):
"""
Initialize the Bayesian estimator.
:param param_min: Minimum value of the parameter space
:param param_max: Maximum value of the parameter space
@edxmorgan
edxmorgan / CRBI.py
Last active November 8, 2024 17:16
composite rigid body inertia (CRBI) algorithm used in articulated rigid body dynamics for robots with multiple joints.
I, i_X_p = rig_dyn.model()
Ic_i = []
for i in range(0, ss.n_joints):
Ic_i.append(I[i])
for i in range(ss.n_joints-1, -1, -1):
if i != 0:
p_X_i_f = pluck.inverse_spatial_transform(i_X_p[i]).T
Ic_i[i-1] = Ic_i[i-1] + p_X_i_f@Ic_i[i]@i_X_p[i]
@edxmorgan
edxmorgan / mavlogparse.py
Created October 30, 2024 17:02 — forked from ES-Alexander/mavlogparse.py
A MAVLink telemetry (.tlog) file parser - similarish to mavlogdump, but (I think) nicer to use and process afterwards
#!/usr/bin/env python3
''' Mavlink telemetry (.tlog) file parser.
Operates as a generator. Allows csv output or listing useful types/fields.
'''
import json
from pathlib import Path
from fnmatch import fnmatch
from pymavlink import mavutil
@edxmorgan
edxmorgan / mpc_with_input_constraints.m
Created October 30, 2024 01:50
MATLAB Code for Offset-Free MPC Control of Heated Swimming Pool System with input constraints
% MATLAB Code for Offset-Free MPC Control of Heated Swimming Pool System
% Clear workspace and command window
clear; close all; clc;
% System Parameters
A = 0.7788;
B = 0.0442;
C = 1; % Output matrix
@edxmorgan
edxmorgan / mpc.m
Last active October 30, 2024 17:29
MATLAB Code for Offset-Free MPC Control of Heated Swimming Pool System
% MATLAB Code for Offset-Free MPC Control of Heated Swimming Pool System
% Clear workspace and command window
clear; close all; clc;
% System Parameters
A = 0.7788;
B = 0.0442;
C = 1; % Output matrix