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
- git:
local-name: ecto
uri: https://github.com/plasmodic/ecto.git
version: master
- git:
local-name: ecto_image_pipeline
uri: https://github.com/plasmodic/ecto_image_pipeline.git
version: master
- git:
local-name: ecto_opencv
@pgorczak
pgorczak / topological_sort.py
Last active August 29, 2015 14:11
Simple Python Topological Sorting
from collections import deque
def topological_sort(dependency_graph):
""" Topological sorting algorithm.
Args:
dependency_graph: A mapping type whose keys represent graph nodes.
Dependencies are indicated by the values which are sets containing
keys for other nodes.
Note: a node with no dependencies is a key indexing an empty set.

Building ROS on OS X

This is a fork of @mikepurvis original ROS indigo installation notes. I tried to find a straightforward way to keep the system Python throughout the build. I ran into some well known issues while building rviz and had to extend the header exclusions for moc a bit more.

Helpful Stuff

catkin build options
  • -p # (parallel jobs)
  • catkin build pkg_name to build a certain package with dependencies
  • --start-with pkg_name skip dependencies up to a certain package
  • the two above combined allow for a quick retry if one package keeps failing
@pgorczak
pgorczak / uniq.py
Created May 2, 2015 12:14
Easy uniq for csv files
#! /usr/bin/env python
import argparse
import csv
import itertools as itt
import sys
parser = argparse.ArgumentParser(description=
'''Eliminate runs of identical values from csv data. Matching lines are
merged to the first occurrence.''')
@pgorczak
pgorczak / my_logger.py
Created August 24, 2015 14:48
Custom ROS Python logger
import logging
import rospy
# Messages sent to my_logger will not be directed to stdout.
# They will show up in rqt_console with my_logger associated to the node.
logging.getLogger('my_logger').addHandler(rospy.impl.rosout.RosOutHandler())
logging.getLogger('my_logger').setLevel(logging.INFO)
@pgorczak
pgorczak / imgmatrix.py
Last active March 21, 2023 16:48
Arrange images of equal dimensions in a grid, using Python and OpenCV.
#! /usr/bin/env python
import argparse
import itertools
import cv2
import numpy as np
if __name__=='__main__':
parser = argparse.ArgumentParser(
@pgorczak
pgorczak / ogre_1.9_libc++.diff
Last active January 28, 2016 17:41
Quick fix for making ogre 1.9 link to libc++ with brew. However, more patching is needed to make pkg-config and the install directories agree.
diff -r 55e89ae88219 CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -326,6 +326,7 @@
# 10.7 is the minimum for libc++ support
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.7)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
# Make sure that the OpenGL render system is selected for non-iOS Apple builds
@pgorczak
pgorczak / connection.h
Last active June 8, 2016 19:39
Text based socket connection, using a UNIX socket in C++. Looks up hostname and port, checks if it can connect, sets timeouts. Corner cases of data spanning across socket reads should be covered.
#ifndef CONNECTION_H
#define CONNECTION_H
#include <netdb.h>
#include <stdexcept>
#include <string>
#include <sstream>
#include <sys/socket.h>
#include <deque>
x, y, z, _, _, _ = kin.transform_to_pose(self.robot.transform)
# Check translation distance
# Ensure numeric stability of angle calculation
r_2 = np.linalg.norm((x, y, z))
if r_2 < 1e-5:
return
# Aim at tip frame with givens rotations
# First about z (yaw, azimuth) - eliminate y
r_1 = np.hypot(x, y)
c_1 = x/r_1
@pgorczak
pgorczak / activate.sh
Created December 8, 2016 20:22
Place this next to your linaro toolchain to cross compile for ARM
ROOT=$(realpath $(dirname $0))
LINARO=$ROOT/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf
# Use the toolchain
export BIN_PREFIX=$LINARO/bin/arm-linux-gnueabihf-
export CC=${BIN_PREFIX}gcc
export CXX=${BIN_PREFIX}g++
# Compile like $CXX hello_world.cpp -o hello