Skip to content

Instantly share code, notes, and snippets.

@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 / model_load_util.py
Last active December 11, 2022 22:43
Load Python 3 PyTorch Networks in Python 2 for ROS deployment
import sys
import argparse
import torch
def load_model_txt(model, path):
print('Loading...')
data_dict = {}
fin = open(path, 'r')
i = 0
odd = 1
@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
@thomasweng15
thomasweng15 / example.py
Last active March 16, 2019 16:54
5-minute guide to Python debugging with Visual Studio Code
a = 1
b = 2
c = a + b