Skip to content

Instantly share code, notes, and snippets.

View whateverforever's full-sized avatar

max whateverforever

View GitHub Profile
@whateverforever
whateverforever / xvfb-run-docker.md
Created September 4, 2023 09:34
xvfb-run and docker or kubernetes

If your docker container hangs, or complains that no display is available, even though you have an xvfb-run entrypoint, you probably need a custom init handler:

# use custom init handler so that xvfb-run is executed properly
# alternatively use docker --init, but that doesnt work in k8s
ENV TINI_VERSION v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini
@whateverforever
whateverforever / config.lua
Created August 10, 2023 09:13
lunarvim lazy.vim lvim minimap
-- lunarvim uses lazy.vim for plugin management
-- lazy.vim works with vimscript plugins, but
-- need to use init, instead of config
lvim.plugins = {
...snip...
{
'wfxr/minimap.vim',
init = function()
vim.g.minimap_auto_start = 1
end
@whateverforever
whateverforever / oriented_bounding_box.py
Last active August 12, 2023 16:43
Little script to compute the minimal oriented bounding box of a given mesh. Takes inspiration from "Fast oriented bounding box optimization on the rotation group SO(3, R)" from Chang et al. 2011, and adapts it to the python ecosystem.
#!/usr/bin/env python3
"""
Little script to compute the minimal oriented bounding box (OBB)
of a given mesh.
Takes inspiration from
"Fast oriented bounding box optimization on the rotation group SO(3, R)"
from Chang et al. 2011, and adapts it to the python ecosystem.
"""
@whateverforever
whateverforever / fix_trimesh_stl_vertex_order.py
Last active April 3, 2023 08:18
Trimesh STL loading can lead to vertex indices varying from other programs such as blender or meshlab. Use this function instead to preserve the vertex order. Note: This has been integrated into trimesh since https://github.com/mikedh/trimesh/pull/1546
import trimesh as tm
import numpy as np
def sorted_uniques(arr):
"""
np.unique mangles the order of the original array, so that the resulting
unique values are sorted. To keep them in the order of the original data,
use this function.
"""
uniques, uidxs, inverse = np.unique(arr, return_index=True, return_inverse=True)
@whateverforever
whateverforever / recover_6D_transform.py
Last active March 13, 2022 23:07
numpy-only point set registration (Arun et. al 1987)
import numpy as np
def recover_6D_transform(pts_a, pts_b):
"""
Returns least squares transform between the two point
sets pts_a and pts_b: T_b2a (Arun et. al 1987)
"""
assert np.shape(pts_a) == np.shape(pts_b), "Input data must have same shape"
assert np.shape(pts_a)[1] == 3, "Expecting points as (N,3) matrix"
@whateverforever
whateverforever / vscode-cmake.md
Created September 15, 2021 08:27
CMake vscode extension doesn't configure ROS project - ImportError: No module named catkin

ImportError: No module named catkin

generate_cached_setup.py:

try:
    from catkin.environment_cache import generate_environment_script
except ImportError:
    # search for catkin package in all workspaces and prepend to path
    for workspace in ''.split(';'):

python_path = os.path.join(workspace, 'lib/python3/dist-packages')

@whateverforever
whateverforever / slow_intellisense.md
Created September 10, 2021 12:40
Intellisense Slow vscode C++
@whateverforever
whateverforever / roslaunch-cant-locate.md
Last active August 20, 2021 13:06
rosversion roslaunch can't locate [roslaunch]

rosversion roslaunch can't locate [roslaunch]

RLException: Invalid tag: Cannot load command parameter [rosversion]

You can't start a roscore anymore, because rosversion can't find roslaunch?

  1. Try roscd <some_package> with a package you know you have installed.
  2. If that doesn't work and if your ROS_ env variables are all set correctly, check rospack profile.
  3. If that doesn't yield a list of directories like below, check if your ROS_PACKAGE_PATH contains a lone package.xml amidst the packages. For some reason, such a lone package.xml will prevent rospack from looking into the other folders, and thus it won't discover your installed modules.

Following situation: You have your own CMake Library, that depends on nanogui (probably same for other libs)

$ tree
.
├── CMakeLists.txt
├── src
│   └── main.cpp
└── ext
 └── CustomLibrary

VTK Struggle

fatal error: 'vtkExternalOpenGLRenderWindow.h' file not found

  1. Edit CMakeCache.txt
  2. Find Module_vtkRenderingExternal:BOOL=OFF
  3. Change to Module_vtkRenderingExternal:BOOL=ON
  4. run cmake. and all that jazz

Alternative