Skip to content

Instantly share code, notes, and snippets.

View martinstarkov's full-sized avatar
🐢

Martin martinstarkov

🐢
View GitHub Profile
@martinstarkov
martinstarkov / BayesThrottleTest.ino
Last active October 29, 2021 12:45
Arduino program which throttles the thrust of an EDF.
/*
* @return - The sign of a number.
*/
template <typename T> int Sign(T val) {
return (T(0) < val) - (val < T(0));
}
class Throttle {
public:
using thrust = int;
#include <unordered_map>
#include <string>
#include <cassert>
#include <chrono>
using milliseconds = std::chrono::milliseconds;
using seconds = std::chrono::seconds;
struct Vector3 {
int x;
@martinstarkov
martinstarkov / Matlab System Identification.m
Created May 19, 2024 17:16
Matlab System Identification
%D = load('filename here.mat');
%data = D.data_TRT;
rng default
t = linspace(0, 60, 1000);
a = 5;
gamma = 0.1;
w = 100;
@martinstarkov
martinstarkov / map_generator.py
Created May 21, 2024 13:56
Gate and Map Generator
from PIL import Image
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt
im_level = Image.open('C:/Users/Martin/Desktop/map_generator/level_1.png', 'r')
im_height = Image.open('C:/Users/Martin/Desktop/map_generator/height_map.png', 'r')
im_height_r = im_height.convert('RGBA')
im_level_r = im_level.convert('RGBA')
@martinstarkov
martinstarkov / system_identify_no_input.m
Last active May 29, 2024 01:19
System Identification (no input)
input = false;
data = load('/MATLAB Drive/Examples/run_2_noinput.mat').run_2;
if (input)
data = load('/MATLAB Drive/Examples/ramp_1_60.mat').ramp_1_60;
%data = load('/MATLAB Drive/Examples/stairs_p_45.mat').stairs_p_45;
end
@martinstarkov
martinstarkov / system_identify_model.m
Created May 23, 2024 12:44
System Identitication Model
data = load('/MATLAB Drive/Examples/ramp_2_60.mat').ramp_2_60;
h = 0.01; % time step
offset = 1; % time offset in data array
t = data(1, offset:end); % time
x_1 = data(2, offset:end); % pitch
u_1 = data(6, offset:end); % pitch input
x_2 = gradient(x_1, t); % pitch velocity
c_known = [-10.6657 0.0045 0.0609 2.8575 1.2201];
@martinstarkov
martinstarkov / system_identify_sinusoidal.m
Last active May 30, 2024 17:37
Fitting sinusoidal data
input = true;
data = load('/MATLAB Drive/data/no_input_lift_to_maxdeg60_60_2.mat').IO_data;
if (input)
data = load('/MATLAB Drive/data/04_06_08_00_stair_60_2.mat').IO_data;
end
t = data(1, :);
h = t(5) - t(4); % time step
----------------
GateEvent.dco
(Type int)
(Type bool)
(Event GateEvent
(int id (Default -1))
(int event_type (Default -1))
@martinstarkov
martinstarkov / system_identify_ramp.m
Last active May 29, 2024 01:18
System Identification Ramp
input = true;
data = load('/MATLAB Drive/Examples/run_2_noinput.mat').run_2;
if (input)
data = load('/MATLAB Drive/Examples/ramp_1_60.mat').ramp_1_60;
%data = load('/MATLAB Drive/Examples/stairs_p_45.mat').stairs_p_45;
end
@martinstarkov
martinstarkov / system_identify_stairs.m
Last active May 29, 2024 01:15
System Identification Stairs
input = true;
data = load('/MATLAB Drive/Examples/run_2_noinput.mat').run_2;
if (input)
%data = load('/MATLAB Drive/Examples/ramp_1_60.mat').ramp_1_60;
data = load('/MATLAB Drive/Examples/stairs_p_45.mat').stairs_p_45;
end