Skip to content

Instantly share code, notes, and snippets.

View cohnt's full-sized avatar

Thomas Cohn cohnt

View GitHub Profile
@cohnt
cohnt / regions.pickle
Last active January 31, 2024 21:49
GcsTrajectoryOptimization::GetGraphvizString Crash
@cohnt
cohnt / bad_hpolyhedron.py
Last active January 29, 2024 19:50
HPolyhedron where MaximumVolumeInscribedEllipsoid Fails
import numpy as np
from pydrake.all import HPolyhedron
A=np.array([[ 1.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00 ],\
[ 0.000000000000000000e+00, 0.000000000000000000e+00, -1.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00 ],\
[ 0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, -1.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00 ],\
[ 0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, -1.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00 ],\
[ 0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e
@cohnt
cohnt / main.py
Last active July 23, 2024 14:32
Toppra Failure Example
import numpy as np
from pydrake.all import (
StartMeshcat,
PiecewisePolynomial,
Toppra,
DiagramBuilder,
AddMultibodyPlantSceneGraph,
Parser,
LoadModelDirectivesFromString,
ProcessModelDirectives
@cohnt
cohnt / error.py
Last active March 19, 2025 17:52
Segmentation Fault in KinematicTrajectoryOptimization when Using MinimumDistanceConstraint 1
#!/usr/bin/env python
# coding: utf-8
# # Kinematic Trajectory Optimization
#
# This notebook provides examples to go along with the [textbook](http://manipulation.csail.mit.edu/trajectories.html). I recommend having both windows open, side-by-side!
#
# In[ ]:
@cohnt
cohnt / break2.py
Created April 27, 2023 13:56
Simpler Terrible Linear System
# Built off of commit hash 8ddd6672b1
import numpy as np
from pydrake.all import ContinuousAlgebraicRiccatiEquation
A = np.fromstring("0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 \
0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.00000000
@cohnt
cohnt / break.py
Last active April 26, 2023 23:57
Terrible Linear System
# Built off of commit hash 8ddd6672b1
import numpy as np
from pydrake.all import ContinuousAlgebraicRiccatiEquation
A = np.fromstring("0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.0000000000
@cohnt
cohnt / user.bazelrc
Created April 21, 2023 17:47
user.bazelrc File for My Drake Installation
# Use proprietary solvers
build --config gurobi
build --config mosek
build --config snopt
# Experimenting with alphashapes to generate 2D worlds with randomly sized and shaped obstacles.
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Polygon
from descartes import PolygonPatch
import alphashape
n_points = 200
alpha = 25.
@cohnt
cohnt / k-clustering_comparison.py
Last active June 23, 2022 14:51
Comparison of k-means, k-medians, and k-medoids clustering on a toy dataset with 2 clusters and an outlier.
import numpy as np
from pyclustering.cluster.kmeans import kmeans, kmeans_visualizer
from pyclustering.cluster.kmedians import kmedians
from pyclustering.cluster.kmedoids import kmedoids
from pyclustering.cluster import cluster_visualizer
sample = np.array([
[0, 0],
import numpy as np
import matplotlib.pyplot as plt
mean = np.array([2, 2])
cov = 0.5 * np.array([[1, 0.9], [0.9, 1]])
x, y = np.random.multivariate_normal(mean, cov, 75).T
from sklearn.decomposition import PCA
pca = PCA(n_components=2)