Skip to content

Instantly share code, notes, and snippets.

View jhurliman's full-sized avatar
🐨

John Hurliman jhurliman

🐨
View GitHub Profile
@jhurliman
jhurliman / SettingsManager.ts
Last active June 16, 2022 19:29
Foxglove Studio high-level settings API
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/
import { produce } from "immer";
import {
SettingsTreeAction,
SettingsTreeNode,
SettingsTreeRoots,
@jhurliman
jhurliman / ros2-galactic-src.Dockerfile
Created September 13, 2022 16:51
Build ROS2 Galactic from source in an Ubuntu 20.04 container
FROM ubuntu:focal
ARG USER=jhurliman
ARG BASE_DIR=/home/$USER/Documents/Code/ros2/ros2_galactic
SHELL ["/bin/bash", "-c"]
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y locales
RUN locale-gen en_US en_US.UTF-8
@jhurliman
jhurliman / LruCache.ts
Created September 28, 2022 20:55
LRU cache in TypeScript
class LruCache<T> {
private values = new Map<string, T>();
constructor(private maxEntries = 10) {}
public get(key: string): T | undefined {
const entry = this.values.get(key);
if (entry != undefined) {
this.values.delete(key);
this.values.set(key, entry);
@jhurliman
jhurliman / WebGLCompute.ts
Created October 4, 2022 01:12
WebGL2 compute shaders using transform feedback
/**
* Matches against GLSL shader outputs.
*/
const VARYING_REGEX = /[^\w](?:varying|out)\s+\w+\s+(\w+)\s*;/g
/**
* Adds line numbers to a string with an optional starting offset.
*/
const lineNumbers = (source: string, offset = 0): string => source.replace(/^/gm, () => `${offset++}:`)
@jhurliman
jhurliman / rosbag2-benchmark-humble-tx2.csv
Created October 4, 2022 07:02
rosbag2 benchmark results - ROS2 Humble on NVIDIA Jetson TX2
We can make this file beautiful and searchable if this error is corrected: It looks like row 8 should actually have 9 columns, instead of 4 in line 7.
messages,batch_size,plugin_config,name,avg_byte_throughput,max_arena_size,max_in_use_size,max_mmap_size,close_time
large,small,mcap_default,messages=large;batch_size=small;plugin_config=mcap_default,198406545.84777477,999424,1896784,1007616,0.001389235
large,small,mcap_nocrc,messages=large;batch_size=small;plugin_config=mcap_nocrc,198753701.76083803,999424,1895968,1007616,0.00135346
large,small,mcap_zstd,messages=large;batch_size=small;plugin_config=mcap_zstd,196985836.29268298,999424,1896112,1007616,0.001433238
large,small,mcap_nochunking,messages=large;batch_size=small;plugin_config=mcap_nochunking,195853825.78654373,999424,1896112,1007616,0.001555497
large,small,sqlite_default,messages=large;batch_size=small;plugin_config=sqlite_default,232529684.43262097,1409024,2166544,0,0.000428092
large,small,sqlite_resilient,messages=large;batch_size=small;plugin_config=sqlite_resilient,169399347.25798884,1404928,2161056,0,0.004874539
large,medium,mcap_default,messages=large;batch_size=medium;plugin_config=mcap_defaul
@jhurliman
jhurliman / rosbag2-benchmark-humble-nano2gb.csv
Created October 4, 2022 20:32
rosbag2 benchmark results - ROS2 Humble on NVIDIA Jetson Nano 2GB
We can make this file beautiful and searchable if this error is corrected: It looks like row 8 should actually have 9 columns, instead of 5 in line 7.
messages,batch_size,plugin_config,name,avg_byte_throughput,max_arena_size,max_in_use_size,max_mmap_size,close_time
large,small,mcap_default,messages=large;batch_size=small;plugin_config=mcap_default,360230333.3234964,999424,1677968,1007616,0.000673866
large,small,mcap_nocrc,messages=large;batch_size=small;plugin_config=mcap_nocrc,360378541.6077541,1003520,1677456,1007616,0.000643136
large,small,mcap_zstd,messages=large;batch_size=small;plugin_config=mcap_zstd,359844528.64106107,999424,1677280,1007616,0.000597093
large,small,mcap_nochunking,messages=large;batch_size=small;plugin_config=mcap_nochunking,360667650.147003,999424,1677280,1007616,0.00059126
large,small,sqlite_default,messages=large;batch_size=small;plugin_config=sqlite_default,335139326.56812894,1134592,2165904,0,0.000458133
large,small,sqlite_resilient,messages=large;batch_size=small;plugin_config=sqlite_resilient,223319138.0299207,1134592,2161408,0,0.00205389
large,medium,mcap_default,messages=large;batch_size=medium;plugin_config=mcap_default,359
@jhurliman
jhurliman / killgpu.sh
Created May 4, 2023 03:53
Shell alias to kill all processes using the GPU. Only for headless NVIDIA GPU machines!
alias killgpu='nvidia-smi --query-compute-apps=pid --format=csv,noheader | xargs --no-run-if-empty sudo kill'
@jhurliman
jhurliman / start-tensorboard.sh
Created May 4, 2023 16:44
Run a tensorboard docker service
#!/usr/bin/env bash
docker run --init \
-d \
--restart unless-stopped \
--hostname jupiter.martian.ag \
--log-opt max-size=50m \
-p 6006:6006 \
-e DOCKER_USER=$(id -un) \
-e DOCKER_USER_ID=$(id -u) \
@jhurliman
jhurliman / sample_near_center_of_mass.py
Created July 26, 2023 17:10
[Python] sample_near_center_of_mass(mask, num_samples, distance)
from scipy.ndimage import center_of_mass
from typing import List
Vec2 = Tuple[float, float]
def sample_near_center_of_mass(
mask: NDArray[np.uint8], num_samples: int = 10, distance: float = 5
) -> List[Vec2]:
"""
"""
Convert a tab-separated text file list of timestamped body marker positions
from <https://accad.osu.edu/research/motion-lab/mocap-system-and-data> into an
MCAP file.
"""
import argparse
import csv
import json
import typing as tp