Skip to content

Instantly share code, notes, and snippets.

@dpkoch
dpkoch / header_symbols.c
Created May 9, 2015 03:15
Generates header symbol definitions for including in an EAGLE library
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#define TRUE 1
#define FALSE 0
static const char SYMBOL_OPEN[] = "<symbol name=\"HEADER-%dPOS\">\n";
static const char SYMBOL_CLOSE[] = "</symbol>\n";
@dpkoch
dpkoch / myprospectus.tex
Last active January 1, 2019 20:47
A simple LaTeX document class for a prospectus
\documentclass{prospectus}
\usepackage[T1]{fontenc} % looks better than default font encoding
\usepackage{lmodern} % need a newer font to work with T1 font encoding
\usepackage{graphicx} % for including images
% standard document info
\title{My Prospectus Title}
\author{My Name}
\date{\today}
@dpkoch
dpkoch / clean-latex.sh
Last active October 5, 2016 00:24
Bash script for removing generated LaTeX files
#!/bin/bash
EXTENSIONS=".aux .log .nav .out .snm .synctex.gz .toc .bbl .blg -blx.bib .bcf .run.xml .acn .acr .alg .glg .glo .gls .ist .lof .lot .auxlock .synctex.gz(busy) .vrb .fls .fdb_latexmk .latexmk"
MAXDEPTH="-maxdepth 1"
if [ "$1" = "-r" ] || [ "$1" = "-R" ]; then
MAXDEPTH=""
fi
find . $MAXDEPTH -type f -name "*.tex" | while read FILE
@dpkoch
dpkoch / rk4.m
Created May 21, 2015 23:01
MATLAB Runge-Kutta 4th-order integration function
function y = rk4(f, y, t, dt, varargin)
%RK4 Runge-Kutta 4th order integration
% RK4(F,Y,T,DT,...) integrates the differential equation y' = f(t,y) from
% time T to time T+DT, where Y is the value of the solution vector at
% time T. F is a function handle. For a scalar T and a vector Y, F(T,Y)
% must return a column vector corresponding to f(t,y). Additional
% arguments will be passed to the function F(T,Y,...).
k1 = f(t, y, varargin{:});
k2 = f(t + dt/2, y + k1*dt/2, varargin{:});
@dpkoch
dpkoch / extract_group.m
Last active August 29, 2015 14:24
Extracts data for a specified group from a PX4 log file
function group = extract_group(logfile, label)
%EXTRACT_GROUP Extracts data for the specified group from a PX4 log file
% EXTRACT_GROUP(LOGFILE,LABEL) extracts data for the group LABEL from the
% PX4 log file LOGFILE, and returns a struct whose fields are the members
% of that group. The returned struct also has a field TIME_StartTime
% containing the timestamps for the data.
index = find(logfile == '.', 1, 'last');
if isempty(index)
basename = logfile;
@dpkoch
dpkoch / bag2struct.m
Last active February 2, 2016 19:31
MATLAB script for formatting data from a matlab_rosbag ros.Bag object as a struct
function [data, meta] = bag2struct(bag, varargin)
%BAG2STRUCT Formats data from topics in a rosbag file into a struct
% DATA = BAG2STRUCT(BAG) returns a struct containing data for each of the
% topics in BAG, where BAG is an object of class 'ros.Bag'.
%
% [DATA,META] = BAG2STRUCT(BAG) additionally returns a struct containing
% the metadata for each topic in the bag.
%
% Example
% bag = ros.Bag.load('rosbag.bag');
#ifndef CIRCULAR_BUFFER_H
#define CIRCULAR_BUFFER_H
#include <stdlib.h>
template <class T>
class CircularBuffer
{
private:
T* data;
#!/usr/bin/env python
import rospy
from sensor_msgs.msg import Imu
import numpy as np
import matplotlib.pyplot as plt
class Timing():
def __init__(self):
@dpkoch
dpkoch / plot_bag.py
Created March 21, 2017 22:58
Script for plotting rosbag topics. Depends on pybag.
#!/usr/bin/env python
import sys
import pybag
import matplotlib.pyplot as plt
def initialize_plot(num_fields):
config = {}
config['fig'] = plt.figure()
@dpkoch
dpkoch / prerelease_tests.sh
Last active June 3, 2017 05:58
Script for running ROS prerelease scripts for the rosflight repository on different architectures
#!/bin/bash
if [ -z $1 ]; then
echo "USAGE: $0 branch"
exit 1
fi
BRANCH=$1
EXIT_CODE=0