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 / speed_control.py
Created October 16, 2024 04:56 — forked from Williangalvani/speed_control.py
pymavlink speed ardusub
"""
Example of how to set target speed in guided mode with pymavlink
"""
import time
import math
# Import mavutil
from pymavlink import mavutil
# Imports for attitude
from pymavlink.quaternion import QuaternionBase
@edxmorgan
edxmorgan / attitudeControl.py
Created October 16, 2024 04:56 — forked from Williangalvani/attitudeControl.py
Sets attitude for bluerov2 using pymavlink
# Import mavutil
from pymavlink import mavutil
from pymavlink.quaternion import QuaternionBase
import math
import time
import sys
ALT_HOLD_MODE = 2
def is_armed():
try:
@edxmorgan
edxmorgan / target_depth.py
Created October 16, 2024 04:56 — forked from Williangalvani/target_depth.py
set target depth ardusub
#!/usr/bin/env python
# Script to set target depth in Ardusub 3.6 beta
# requires this commit: https://github.com/williangalvani/ardupilot/commit/85a41d5771ba9d64e594dcc0856b6a3906767c3f
from pymavlink import mavutil
# There is very likely a builtin in pymavlink for this, but I didn't find it
ALT_HOLD_MODE = 2
@edxmorgan
edxmorgan / PFC_controller.m
Created October 20, 2024 22:01
A reference trajectory strategy using PFC
% MATLAB Script for Simulating PFC Controller from Example 4.4
% Clear workspace and command window
clear;
close all;
clc;
% Sampling time
Ts = 3; % seconds
@edxmorgan
edxmorgan / video.py
Last active November 8, 2024 19:17
BLUEROV_CAMERA VIDEO STREAM
#!/usr/bin/env python3
import cv2
import gi
import numpy as np
import json
gi.require_version('Gst', '1.0')
from gi.repository import Gst
class Video():
@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
@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 / 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 / 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 / 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