Skip to content

Instantly share code, notes, and snippets.

View mukheshpugal's full-sized avatar

Mukhesh P S mukheshpugal

  • Indian Institute of Technology, Madras
  • Chennai
View GitHub Profile
@mukheshpugal
mukheshpugal / rv32i.py
Created October 3, 2020 15:04
A partially implemented rv32i decoder.
import argparse
alu = {
'0000':'add', '1000':'sub',
'0001':'sll',
'0010':'slt',
'0011':'sltu',
'0100':'xor',
'0101':'srl', '1101':'sra',
'0110':'or',

Keybase proof

I hereby claim:

  • I am mukheshpugal on github.
  • I am mukheshpugal (https://keybase.io/mukheshpugal) on keybase.
  • I have a public key ASAnzPkYW8hqdYC1cCo_wcSkxtGqXSd900rQo6Zl0NCMJQo

To claim this, I am signing this object:

class Exp_SE3(Function):
"""
Implements exp SO3 as a torch fuction
"""
@staticmethod
def forward(ctx, vec: "Tensor[6]") -> "Tensor[4,4]":
"""
:param ctx: context, to store some tensors
for backward
import numpy as np
import pptk
from mayavi import mlab
import cv2
depthmap = np.array(cv2.imread('depth.png',0));
depthmap = depthmap[300:340, 220:260]
intrinsics = np.array([[525.0, 0, 319.5],
[0, 525.0, 239.5],
[0, 0, 1]])
def hat(w):
return torch.tensor([[0, -w[2], w[1]],
[w[2], 0, -w[0]],
[-w[1], w[0], 0]])
def hat_inv(R):
return torch.tensor([R[2][1], R[0][2], R[1][0]])
def matrix_from_euler(euler):
rotation_x = torch.tensor([[1, 0, 0], [0, torch.cos(euler[0]), -torch.sin(euler[0])], [0, torch.sin(euler[0]), torch.cos(euler[0])]])
rotation_y = torch.tensor([[torch.cos(euler[1]), 0, torch.sin(euler[1])], [0, 1, 0], [-torch.sin(euler[1]), 0, torch.cos(euler[1])]])
rotation_z = torch.tensor([[torch.cos(euler[2]), -torch.sin(euler[2]), 0], [torch.sin(euler[2]), torch.cos(euler[2]), 0], [0, 0, 1]])
rotation_3d = torch.matmul(torch.matmul(rotation_x, rotation_y), rotation_z)
return rotation_3d
@mukheshpugal
mukheshpugal / optimizer.py
Last active August 15, 2019 13:06
Pose estimation using scipy.least_squares()
from scipy.optimize import least_squares as ls
import math
import numpy as np
from PIL import Image
import cv2
from matplotlib import pyplot as plt
def huber(r, delta):
if math.sqrt(r) < delta:
return r / (2 * delta)