Skip to content

Instantly share code, notes, and snippets.

View robodhruv's full-sized avatar
🥑

Dhruv Shah robodhruv

🥑
View GitHub Profile
@robodhruv
robodhruv / process_rosbag_sync.py
Last active September 4, 2022 00:24
A simple script to extract synced topics at a fixed rate from a rosbag
"""
File: process_rosbag_sync.py
Author: Dhruv Shah (shah@cs.berkeley.edu)
Python Version: 3.8.13
A simple script to extract rostopics at a fixed (reduced) rate from a rosbag.
"""
import pickle as pkl
import pandas
"""
Convert Robinhood Account Summary (CSV) to a Transaction Summary (CSV) you can use with a tax software like Glacier (or TaxAct, SprinTax etc.
Coupled with (https://github.com/JiahaoShan/Glacier-tax-1099-B-Stock-Transactions-Helper), use this script to autofill Robinhood transaction summary for your 1099-B tax docs on Glacier Tax Prep (http://glaciertax.com).
NOTE: This can manually handle stock splits, but does not account for referral stocks. You might have to handle them externally.
"""
from collections import deque
import pandas as pd
import numpy as np
import csv
@robodhruv
robodhruv / habitat_wrapper.py
Created January 19, 2020 18:04
Gym Wrapper for Habitat environment compatible with tf-agents
class HabitatWrapper(gym_wrapper.GymWrapper):
# GymWrapper cannot handle all types of gym Spaces, and the action
# space in Habitat (at least for the PointNav task) is a gym.Dict
# (supported) with str keys and habitat.EmptySpace values
# (unsupported). Since the action space is really a discrete space,
# we'll update gym_env.action_space temporarily to be Discrete
# so that GymWrapper can create an action spec.
def __init__(self,
gym_env,
@robodhruv
robodhruv / MDP_planner.py
Last active September 27, 2018 17:53
MDP Planning using Howard's Policy Iteration and as a Linear Program
"""
File: planner.py
Author: Dhruv Ilesh Shah. CS 747, Autumn 2018.
Indian Institute of Technology, Bombay.
Date created: 8/30/2018
Date last modified: 9/07/2018
Python Version: 2.7.12
This file contains two ways of solving an MDP planning problem: (i) using Howard's PI (Howard, 1960)
or (ii) by posing it as a linear program. The PuLP package has been used to solve the linear system
@robodhruv
robodhruv / compute_RIC.m
Created May 28, 2018 21:50
Compute the restricted isometry constant (RIC) of a matrix at a specified sparsity level. Note that this is a certified NP-hard problem and only computationally tractable for small values of s (upto 4 or 5).
function out = compute_RIC(A, s)
% This function computes the Restricted Isometry Constant of given matrix A
% at sparsity level s.
% Written by Alankar Kotwal (alankarkotwal13@gmail.com), Dhruv Shah (dhruv.ilesh@gmail.com)
A = normc(A);
nT = size(A, 2);
combs = combnk(1:nT, s);
out = 0;
disp(size(combs, 1))
@robodhruv
robodhruv / dtft_fir_filter.m
Created March 26, 2018 15:55
Generate the DTFT of Window Functions in FIR Filter Design
%% Discrete time Fourier Transform of FIR filters
% Generate the DTFT of Window Functions in FIR Filter Design. For a custom
% window, define the window function and use the following snippets as is.
% Written by Dhruv Ilesh Shah (dhruv.shah@iitb.ac.in)
clear all; close all;
N = 100;
k = -N:N;
hamming_window = 0.54 + (0.46 * cos(2*pi*k / (2 * N)));
bartlett_window = 1 - (abs(k) / N);
@robodhruv
robodhruv / odom_to_path.py
Last active May 29, 2023 09:10
ROS Node for converting nav_msgs/odometry messages to nav_msgs/Path
#!/usr/bin/env python
from __future__ import print_function
import rospy
from tf.transformations import quaternion_from_euler
from std_msgs.msg import String
from nav_msgs.msg import Odometry, Path
from geometry_msgs.msg import PoseWithCovarianceStamped, PoseStamped
from sensor_msgs.msg import Joy
import sys
import json
@robodhruv
robodhruv / frequency_confusion.m
Created February 24, 2018 19:30
Visualise frequency confusing/aliasing due to sampling of a pure sinusoid as a video.
clear all; close all;
n = [0:0.1:50];
w = pi/2;
Ts = 0.2;
ks = [-200:200];
y = zeros(size(n))
frame_count = 1;
@robodhruv
robodhruv / lloyd-max.py
Created November 24, 2017 16:10
Lloyd Max Quantizer for optimal quantization of a random variable demonstrating a Gaussian PDF
"""
Lloyd Max Quantizer
This program implements a midrise lloyd-max quantizer, for optimal
quantization of a random variable demonstrating a Gaussian PDF.
The clustering mechanism used here equivalent to k-Means clustering.
Author: Dhruv Ilesh Shah
EE308 - Communication Systems, Autumn 2017
Indian Institute of Technology, Bombay
"""
# include <cstdlib>
# include <iostream>
# include <iomanip>
# include <cmath>
# include <ctime>
# include <omp.h>
using namespace std;
int main ( void );