Skip to content

Instantly share code, notes, and snippets.

@superjax
superjax / Makefile
Last active February 1, 2024 06:38
Makefile Template for compiling C/C++ for use with STM32 Microcontrollers
# Copyright (c) 2016, James Jackson
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
@superjax
superjax / lookup_table_generator.py
Last active September 5, 2019 06:46
Python lookup table generation script
import numpy as np
import matplotlib.pyplot as plt
from math import sin, pi, asin, tan, atan
def f(x):
return ((1.0 - pow(x / 101325.0, 0.190284)) * 145366.45) * 0.3048
def finv(x):
return 101325.0 * (1 - 2.25577 * 10 ** -5 * x) ** 5.25588
@superjax
superjax / pycharm_keymap.xml
Last active January 27, 2017 04:27
A keymap for pycharm that uses mostly sublime bindings with a smattering of QtCreator bindings as well
<keymap version="1" name="James" parent="$default">
<action id="ActivateRunToolWindow">
<keyboard-shortcut first-keystroke="alt 4" />
<keyboard-shortcut first-keystroke="ctrl r" />
</action>
<action id="CheckinProject" />
<action id="CloseContent">
<keyboard-shortcut first-keystroke="ctrl w" />
</action>
<action id="CollapseAll">
@superjax
superjax / acai.xml
Created January 27, 2017 04:26
Qt Creator good-looking dark syntax theme
<?xml version="1.0" encoding="UTF-8"?>
<style-scheme version="1.0" name="Acai">
<style name="Text" foreground="#ffffff" background="#2d2d2d"/>
<style name="Link" foreground="#0055ff"/>
<style name="Selection" foreground="#000000" background="#aaaaaa"/>
<style name="LineNumber" foreground="#888888" background="#232323"/>
<style name="SearchResult" background="#9e004f"/>
<style name="SearchScope" background="#550000"/>
<style name="Parentheses" foreground="#55ff55"/>
<style name="ParenthesesMismatch" background="#ff00ff"/>
@superjax
superjax / param_parse.py
Created February 5, 2017 00:47
ROSflight parameter file parser and markdown generator
import re
f = open('/home/ultron/Code/ROSflight/src/param.c')
text = f.read()
lines = re.split("\n+", text)
params = []
i = 0
@superjax
superjax / lqr.py
Created April 13, 2017 16:41
LQR Controller for Python
def lqr(A,B,Q,R):
#first, try to solve the ricatti equation
X = np.matrix(solve_continuous_are(A, B, Q, R))
#compute the LQR gain
K = np.matrix(inv(R)*(B.T*X))
eigVals, eigVecs = eig(A-B*K)
return K, X, eigVals
@superjax
superjax / occupancy_grid_mapping_example.py
Last active November 18, 2024 01:29
An occupancy grid mapping example
# This is an implementation of Occupancy Grid Mapping as Presented
# in Chapter 9 of "Probabilistic Robotics" By Sebastian Thrun et al.
# In particular, this is an implementation of Table 9.1 and 9.2
import scipy.io
import scipy.stats
import numpy as np
import matplotlib.pyplot as plt
from tqdm import tqdm
@superjax
superjax / plot_helper.py
Created November 6, 2017 03:59
Python plot helpers
import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse
import numpy as np
def plot_point_cov(points, nstd=2, ax=None, **kwargs):
"""
Plots an `nstd` sigma ellipse based on the mean and covariance of a point
"cloud" (points, an Nx2 array).
Parameters
@superjax
superjax / EKF_SLAM.py
Created November 6, 2017 04:01
EKF_SLAM implementation from Probabilistic Robotics by Sebastian Thrun et al. (look for the plot helper gist for covariance plotting)
import numpy as np
import scipy.linalg
import scipy.stats
import matplotlib.pyplot as plt
import scipy.io
import scipy.sparse
from plot_helper import plot_cov_ellipse
from tqdm import tqdm
def R(theta):
@superjax
superjax / myGRU.py
Created November 10, 2017 03:47
my implementation of a Gated Recurrent Unit in Tensorflow
from tensorflow.python.ops.rnn_cell import RNNCell
from tensorflow.python.ops import math_ops
import tensorflow as tf
class myGRU(RNNCell):
def __init__(self, num_units, forget_bias=1.0,
state_is_tuple=True, activation=None, reuse=None):
super(RNNCell, self).__init__(_reuse=reuse)
self._num_units = num_units
self._forget_bias = forget_bias