Skip to content

Instantly share code, notes, and snippets.

View adamheins's full-sized avatar

Adam Heins adamheins

View GitHub Profile
@adamheins
adamheins / pyb_friction_demo.py
Created November 5, 2023 21:29
PyBullet planar friction demo
import numpy as np
import pybullet as pyb
import pybullet_data
def make_box(
position, half_extents, orientation=(0, 0, 0, 1), mass=1.0, color=(1, 0, 0, 1)
):
collision_uid = pyb.createCollisionShape(
shapeType=pyb.GEOM_BOX,
@adamheins
adamheins / second-ros.sh
Last active September 1, 2020 19:51
Run second ROS, Gazebo, and gzweb instances on a single computer.
# run a secondary ROS and Gazebo instance
#
# when starting ROS master, the new port needs to be specified:
# roscore -p $ROS_PORT
#
# gzweb does not require any environment variables, but the port must be
# specified when gzweb is started:
# npm start -p $GZWEB_PORT
#
# Gazebo does not require any special options when run
@adamheins
adamheins / ros.bash
Last active May 15, 2020 16:13
Code to source different ROS installations
if [ -d /opt/ros/kinetic ]; then
source /opt/ros/kinetic/setup.bash
# path to charlottetown installation
export DSL_ROS_DIR=~/dev/charlottetown
if [ -f "$DSL_ROS_DIR"/extras/devel/setup.bash ]; then
source "$DSL_ROS_DIR"/extras/devel/setup.bash
fi
if [ -f "$DSL_ROS_DIR"/dsl/devel/setup.bash ]; then
@adamheins
adamheins / wifi.bash
Created September 12, 2017 15:54
Script to print wifi network info when using NetworkManager on Ubuntu.
#!/bin/bash
# Get the name of the current network if one is not provided.
if [ -z "$1" ]; then
network_name=$(iwconfig 2>&1 | grep "SSID" | cut -d '"' -f2)
else
network_name=$1
fi
# Probably very system-dependent on Ubuntu and on using NetworkManager.
@adamheins
adamheins / catkin_toplevel.py
Created February 24, 2017 02:44
Prints the root of the current catkin workspace, or prints nothing and exits with non-zero exit code if not in a catkin workspace.
#!/usr/bin/env python
from __future__ import print_function
import os
CMAKELISTS_FILE_NAME = 'CMakeLists.txt'
@adamheins
adamheins / keybase.md
Created October 7, 2016 20:35
Keybase identity proof.

Keybase proof

I hereby claim:

  • I am adamheins on github.
  • I am adamheins (https://keybase.io/adamheins) on keybase.
  • I have a public key whose fingerprint is BE6E 8AB0 440B 2DA4 9880 A284 8393 976B CE8F 5796

To claim this, I am signing this object:

@adamheins
adamheins / t.zsh
Created December 13, 2015 23:55
Simple command line note taking script.
#!/bin/zsh
# Author: Adam Heins
# Date: 2015-10-22
t() {
# Make the ~/.t directory if it does not exist.
[ ! -d ~/.t ] && mkdir ~/.t
if [ -z "$1" ]; then
@adamheins
adamheins / fzf-key-bindings-extension.zsh
Created November 23, 2015 05:13
A modification to the fzf key-bindings file that makes ALT-C both cd to directories and open files.
# ALT-C - cd into the selected directory or open file
fzf-cd-widget() {
local p="${$(command \find -L . \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune \
-o -print 2> /dev/null | sed 1d | cut -b3- | $(__fzfcmd) +m):-.}"
if [ -d "$p" ]; then
cd "$p"
elif [ -f "$p" ]; then
"$EDITOR" < /dev/tty "$p"
else
echo "$p"
@adamheins
adamheins / git.sh
Last active October 31, 2015 02:24
Script to remove a submodule from a git repository.
# Sourced here:
# https://gist.github.com/2491147
#
# Modified by Adam Heins
#
# Usage: git submodule rm [-c] <path/to/submodule>
# You must be in the root of the git repository to use this command. The -c
# (or --clean) option indicates that the submodule files should also be removed
# from the working tree.
@adamheins
adamheins / secrets.py
Created October 8, 2015 23:10
Python function for importing modules from hidden directories and files.
import imp
import os
def secret_import(path):
""" Alternative way to import a module that allows importing of hidden
directories and files. """
if os.path.isdir(path):
name = path.split(os.path.sep)[-1]
if name[0] == '.':
name = name[1:]