Skip to content

Instantly share code, notes, and snippets.

View pgorczak's full-sized avatar

Philipp Gorczak pgorczak

  • German Maritime Search and Rescue Service
  • Dortmund, Germany
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pgorczak
pgorczak / gqrx_audio_stream.py
Created October 21, 2021 15:42
Simple solution for streaming audio from Gqrx to Firefox.
""" Simple solution for streaming audio from Gqrx to Firefox.
Requires the opusenc command line tool.
This program uses the fact that Opus files can be concatenated to form a valid
stream and that Firefox can play these streams natively. The drawback is the
overhead created by repeatedly inserting containers and metadata into the
stream.
- Check https://fastapi.tiangolo.com/tutorial/ to see how to run the server.
from pydrake.symbolic import Variable
from pydrake.systems.analysis import Simulator
from pydrake.systems.controllers import PidController
from pydrake.systems.framework import BasicVector, DiagramBuilder, LeafSystem
from pydrake.systems.primitives import SymbolicVectorSystem
k = 1
s = 1
m = 1
from pydrake.symbolic import Variable
from pydrake.systems.analysis import Simulator
from pydrake.systems.controllers import PidController
from pydrake.systems.framework import DiagramBuilder
from pydrake.systems.primitives import SymbolicVectorSystem
x, xd = Variable('x'), Variable('xdot')
f = Variable('f')
state = [x, xd]
k = 1
@pgorczak
pgorczak / README.md
Last active March 7, 2019 14:20
Helper class for exporting video from openFrameworks.

Video export for openFrameworks

This is a small helper that uses ffmpeg to record h264 video from openFrameworks.

It starts ffmpeg in a subprocess, so ffmpeg should be available on your system. Tested on Linux but probably works on macOS too.

How to use

@pgorczak
pgorczak / get_single_msg.py
Last active February 8, 2019 13:56
Utility function that gets a single message from a ROS topic
import threading
import rospy
def get_single_msg(topic, type_, timeout=None):
""" Utility function that gets a single message from a ROS topic.
Args:
topic: ROS topic (string).
@pgorczak
pgorczak / msg_types.py
Created November 22, 2018 10:41
How to resolve a ROS message down to a dictionary of base types—mostly extracted from https://github.com/ros/genmsg
from collections import OrderedDict
import os
import json
import genmsg
import rosmsg
import rospkg
def load_specs(context, search_path, msg):
@pgorczak
pgorczak / simple-sync.bash
Last active October 9, 2018 15:39
Simplest script that auto-syncs a folder to a remote destination
#!/bin/bash
# Args: source destination
# Needs rsync and inotify-tools
# Hidden files and folders are excluded via regex (inotifywait) and patterns (rsync)
while true; do
rsync -avz --exclude ".*" --exclude ".*/" $1 $2
inotifywait -r -e modify,attrib,close_write,move,create,delete --exclude="\/\." $1
done
@pgorczak
pgorczak / mesh.py
Created October 1, 2018 19:06
Quick example publishing a mesh for mesh_tools (https://github.com/uos/mesh_tools)
import numpy as np
import geometry_msgs.msg as geo_msgs
import rospy
import mesh_msgs.msg as mesh_msgs
def publish_mesh(pub):
mesh = mesh_msgs.TriangleMeshStamped()
@pgorczak
pgorczak / dragon_pointcloud.py
Created August 16, 2018 16:26
Demo for fast numpy to ROS PointCloud2 conversion. Draws a colorful Dragon Curve :)
import numpy as np
from matplotlib.cm import get_cmap
import rospy
import sensor_msgs.msg as sensor_msgs
import std_msgs.msg as std_msgs
def point_cloud(points, parent_frame):
""" Creates a point cloud message.