Skip to content

Instantly share code, notes, and snippets.

@dpkoch
dpkoch / wifi_power_save_off.sh
Created July 18, 2018 22:18
Turn off WiFi power saving (great for TX2)
iw dev wlan0 set power_save off
@dpkoch
dpkoch / 10-ftdi-latency.rules
Created April 4, 2018 17:37
Set FTDI driver latency to minimum value
SUBSYSTEMS=="usb-serial", DRIVERS=="ftdi_sio", ENV{ACTION}=="add", RUN+="/bin/sh -c '/bin/echo 1 > /sys/bus/usb-serial/devices/%k/latency_timer'"
@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
@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()
#!/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):
#ifndef CIRCULAR_BUFFER_H
#define CIRCULAR_BUFFER_H
#include <stdlib.h>
template <class T>
class CircularBuffer
{
private:
T* data;
@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');
@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 / 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 / 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