Skip to content

Instantly share code, notes, and snippets.

@danzimmerman
danzimmerman / abq_cmap_cmd.py
Last active July 25, 2017 18:04
Prints an Abaqus python console command to add a named matplotlib colormap to a running Abaqus session. Tested with Abaqus/Viewer 6.13-4.
#Prints out an Abaqus console command to add a matplotlib colormap to a running Abaqus Viewer session
#Tested with Abaqus/Viewer 6.13-4
#change COLORMAP_NAME for different options
import matplotlib.cm as cm
COLORMAP_NAME = 'magma_r'
chosen_cmap = cm.get_cmap(COLORMAP_NAME)
cols = chosen_cmap(xrange(0,255,16))
clist = []
for col in cols:
f = [0.85:0.01:1.085]
t = 0:1/50:120-1/50;
sinmat = zeros(length(f),length(t));
[xs ys zs] = sphere(40);
xs = 0.05*xs;
ys = 0.05*ys;
zs = 0.05*zs;
[F,T] = meshgrid(f,t);
L = 10;
xmat = sin(2*pi*F.*T);
@danzimmerman
danzimmerman / From_Source_Simplified.md
Last active August 8, 2020 17:37
Notes about installing PyNEC in an Anaconda Virtual Environment

DOES NOT WORK!!! Windows 10 Instructions - PyNEC From Source in Anaconda 3 virtual environment with WSL2 + Ubuntu + VS2019

First of all, you need to follow the original installation instructions for PyNEC with respect to things you need to install on your computer.

This includes installing swig and C/C++ compilers. I have Visual Studio 2019 Community Edition installed, which gives me the MSVC compiler tools. I installed swig 4.0.2 and added it to my PATH.

When I tried the rest of the instructions, I couldn't get build.sh to work. Presumably I need to install make for Windows to get this to work? I think I also had trouble with the softlink. Will try again later with git bash trying to apply some of the things I learned here. However, I got it installed using the instructions below.

These modified instructions use Windows Subsystem for Linux for the make and configure steps, and

@danzimmerman
danzimmerman / .inputrc
Last active August 8, 2020 20:33
Linux arrow-key history-search thing I always want
# Key bindings, up/down arrow searches through history
# From https://unix.stackexchange.com/questions/5366/command-line-completion-from-command-history
"\e[A": history-search-backward
"\e[B": history-search-forward
"\eOA": history-search-backward
"\eOB": history-search-forward

I'm using the BOOST_DLL_ALIAS / boost_import_alias() machinery following this recipe to load a DLL library I developed in C++. It's been working great for me.

The library functionality is all in a single class Foo. There's a factory method Foo::Create() that returns a boost::shared_ptr to a new Foo, and a single BOOST_DLL_ALIAS in the project that exports Foo::Create() to a DLL symbol CreateFoo. The project is compiled to FooLibrary.dll and can be loaded and used from C++ exactly as described in the docs.

I want to be able to access the functionality from Python as well, so I defined a pybind11 interface using the PYBIND11_MODULE macro. The module's __init__ is bound to Foo::Create() though I've also tried it bound to a different factory function with the same results. When I compile with the pybind interface, I can

@danzimmerman
danzimmerman / c_cpp_properties.json
Created January 19, 2021 15:22
ROS C++ Intellisense for VS Code
{
"configurations": [
{
"browse": {
"databaseFilename": "",
"limitSymbolsToIncludedHeaders": true
},
"includePath": [
"C:\\Code\\ros\\workspaces\\npe_ws\\devel\\include\\**",
"C:\\opt\\ros\\melodic\\x64\\include\\**",
@danzimmerman
danzimmerman / advance_matplotlib.py
Created February 24, 2021 17:33
Snippet I never remember to advance matplotlib property cycler
# advance matplotlib property cycler on the axis ax 5 lines
N = 5
for n in range(0, N):
ax._get_lines.prop_cycler.__next__()
@danzimmerman
danzimmerman / ur10_desc.urdf
Created May 8, 2021 16:36
universal_robot/ur_description UR10 URDF taken from parameter server for visual issue debugging
<?xml version="1.0" ?>
<!-- =================================================================================== -->
<!-- | This document was autogenerated by xacro from C:\Code\ros\workspaces\noethp_ws\src\universal_robot\ur_description\urdf\ur.xacro | -->
<!-- | EDITING THIS FILE BY HAND IS NOT RECOMMENDED | -->
<!-- =================================================================================== -->
<robot name="ur">
<!--
Base UR robot series xacro macro.
NOTE: this is NOT a URDF. It cannot directly be loaded by consumers
@danzimmerman
danzimmerman / DAEMeshFileSetObject.py
Last active June 7, 2022 02:36
DAE _meshfile_object loader toward meshcat-python colored Collada
import base64
import pathlib
import xml.etree.ElementTree as Et
import uuid
class DaeMeshFileSetObject(object):
def __init__(self, dae_file, meshcat_path_string):
"""
Assumes that all images are in the same directory as the .dae file
"""
@danzimmerman
danzimmerman / DaeMeshFileSetObject.py
Created February 20, 2022 05:21
meshcat-python Collada loader texture/color hack
class DaeMeshFileSetObject(object):
def __init__(self, dae_file, meshcat_path_string):
"""
Assumes that all images are in the same directory as the .dae file
"""
self.file = pathlib.Path(dae_file).absolute().resolve()
self.path = meshcat_path_string
# -- we don't really need to hold on to these but for debugging it'll be nice to keep them
self.dae_tree = None
self.file_contents = None