Skip to content

Instantly share code, notes, and snippets.

@thomasweng15
thomasweng15 / hsv_segmenter.py
Created March 21, 2022 15:52
Segment HSV from an image rostopic using OpenCV sliders
import cv2
import rospy
import argparse
import numpy as np
import matplotlib.pyplot as plt
from cv_bridge import CvBridge
from sensor_msgs.msg import Image
class Segmenter():
def __init__(self, args):
@thomasweng15
thomasweng15 / reskin_3d_plot.py
Created February 5, 2022 06:37
3D reskin plot
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import TimedAnimation
class SubplotAnimation(TimedAnimation):
def __init__(self, num_steps=50):
fig = plt.figure()
self.ax1 = fig.add_subplot(2, 1, 1)
self.ax2 = fig.add_subplot(2, 1, 2, projection='3d')
self.ax2.set(xlim3d=(-1, 1), xlabel='X')
@thomasweng15
thomasweng15 / publish_eye_on_hand.py
Created June 4, 2021 05:45
publish calibration transform
#!/usr/bin/env python
import rospy
import numpy as np
import copy
import tf
import tf.transformations as tfs
import geometry_msgs.msg
from easy_handeye.handeye_calibration import HandeyeCalibration
@thomasweng15
thomasweng15 / resnet.py
Created October 28, 2020 13:48
modified resnet
import torch.nn as nn
import math
import torch.utils.model_zoo as model_zoo
import numpy as np
__all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101',
'resnet152']
@thomasweng15
thomasweng15 / resnet.py
Created August 24, 2020 15:55
resnet with multigrid
class ResNet(nn.Module):
def __init__(self,
block,
layers,
num_classes=1000,
fully_conv=False,
remove_avg_pool_layer=False,
output_stride=32,
additional_blocks=0,
multi_grid=(1,1,1) ):
# -*- coding: utf-8 -*-
from __future__ import print_function
from matplotlib import pyplot as plt
from PIL import Image
import numpy as np
import random
import os
import cv2
@thomasweng15
thomasweng15 / plots.py
Created January 23, 2020 20:21
Plots for peg insertion project
import seaborn as sns; sns.set()
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
def plot(run_IDs, run_labels, factors, titles,
colors=['steelblue', 'orange', 'mediumseagreen', 'red', 'purple'],
ecolors=['lightblue', 'navajowhite', 'lightgreen', 'pink', 'plum'],
dpi=150):
csv_names = ['run_%d/progress.csv' % i for i in run_IDs]
@thomasweng15
thomasweng15 / test_cartesian.py
Created January 17, 2020 03:31
Sawyer cartesian control
#!/usr/bin/env python
import rospy
import numpy as np
import moveit_commander
import intera_interface
from copy import deepcopy
from geometry_msgs.msg import Pose
import sys
from visual_mpc.envs.robot_envs.sawyer.sawyer_impedance import SawyerImpedanceController
from visualization_msgs.msg import Marker
@thomasweng15
thomasweng15 / train.sh
Last active March 29, 2019 23:23
Bash script for running sbatch
#!/usr/bin/env bash
#SBATCH --nodes=1
#SBATCH --partition=GPU
#SBATCH --ntasks-per-node=1
#SBATCH --time=96:00:00
#SBATCH --gres=gpu:1
#SBATCH --mem=8G
#SBATCH --exclude=compute-0-[9,11,13]
#SBATCH -o /home/USER/out.txt
#SBATCH -e /home/USER/out.txt
@thomasweng15
thomasweng15 / save_rgbd.py
Created March 28, 2019 01:21
Save RGBD script
import rospy
import sys
from sensor_msgs.msg import Image
import pprint
import cv2
from cv_bridge import CvBridge
import tf
import time
global saved_RGB