Skip to content

Instantly share code, notes, and snippets.

View justagist's full-sized avatar
⚠️
raise CoffeeNotFoundError

Saif Sidhik justagist

⚠️
raise CoffeeNotFoundError
View GitHub Profile
@justagist
justagist / grid_search_2d.py
Created August 31, 2024 10:01
Implementing depth-first and breadth-first search for a 2D grid in python.
from typing import List, Tuple, Dict
def find_start(grid: List[List[str]], start_val="S") -> Tuple[int, int]:
for i in range(len(grid)):
for j in range(len(grid[i])):
if grid[i][j] == start_val:
return (i, j)
raise ValueError(f"No start val {start_val} found in grid.")
@justagist
justagist / pca.py
Created August 14, 2024 09:12
principal component analysis in code
import numpy as np
def PCA(X , num_components):
#Step-1
X_meaned = X - np.mean(X , axis = 0)
#Step-2
cov_mat = np.cov(X_meaned , rowvar = False)
@justagist
justagist / remove_submodule.sh
Created March 8, 2024 10:40
Cleanly remove submodule
# From https://stackoverflow.com/a/36593218/2066118
# Remove the submodule entry from .git/config
git submodule deinit -f path/to/submodule
# Remove the submodule directory from the superproject's .git/modules directory
rm -rf .git/modules/path/to/submodule
# Remove the entry in .gitmodules and remove the submodule directory located at path/to/submodule
git rm -f path/to/submodule
@justagist
justagist / pybullet_robot.py
Created March 5, 2024 10:41
Pybullet interface for any robot urdfs. Primary purpose is for testing controllers and planners. Not implemented for handling vision/camera/sensor information.
"""This is a standalone file for interfacing with any robot in pybullet.
FEATURES:
- Main use-case is for controlling the robot. Not implemented for testing vision/camera stuff.
- Handles prismatic, revolute and continuous joints.
- Control in torque (Position, velocity, torque targets) or in direct position mode.
- Retrieve kinematic and dynamics data for links and robot.
- Get contact states for specified end-effectors (or links)
TODO:
@justagist
justagist / pink_interface.py
Created January 30, 2024 19:31
Utility interface class for inverse kinematics and dynamics computations using PINK library, for all type of robot embodiments.
"""Provides utility interface class for inverse kinematics and dynamics computations using PINK library.
If the functionalities of this class are required only intermittently and is not super performance-demanding,
the utility functions in ik_utils.py might be enough.
This is a standalone file.
pypi dependencies: [numpy, pin, pin-pink]
"""
from pink import Configuration, solve_ik, custom_configuration_vector
from pink.tasks import FrameTask, PostureTask, Task
@justagist
justagist / pinocchio_interface.py
Last active March 5, 2024 10:45
An interface class for using Kinematics and Dynamics computations offered by Pinocchio library, supporting all types of robots.
"""Provides utilities for kinematics and dynamics parameters retrievals.
This is a standalone file.
pypi dependencies: [numpy, pin]
FEATURES:
- Retrieve all dynamics and kinematics info for any robot (urdf).
- All methods become available after a single call to the `update()` method of the class, which will compute
all required kinematics and dynamics data, which can be retreived using the other methods in the class.
- Handles continuous joints in addition to revolute and prismatic joints.
@justagist
justagist / clear_rosparams.py
Last active December 24, 2021 11:25
Delete ros parameters from server containing strings provided as arguments
#!/usr/bin/env python
import rospy
from argparse import ArgumentParser
COMMON_PARAMS = ["franka", "panda", "controller", "control", "camera", "gazebo", "state", "arm", "robot", "dynamic_reconfigure", "interactive_marker", "sim_time"]
def delete_params_containing(string_list, verbose=False):
"""
Delete ros parameters from server containing strings listed in 'string_list'.
@justagist
justagist / hybrid_force_motion_control.py
Last active July 27, 2021 08:58
sample simplified hybrid force-motion code
# feedback control loop for hybrid force motion control (simplified)
def compute_cmd(self, time_elapsed=None):
robot_state = robot.state() # from FRI
# calculate the jacobian of the end effector
jac_ee = robot_state['jacobian']
# get position of the end-effector
curr_pos = robot_state['ee_point']

Keybase proof

I hereby claim:

  • I am justagist on github.
  • I am justagist (https://keybase.io/justagist) on keybase.
  • I have a public key whose fingerprint is 1663 461F FB34 C742 63E7 9880 7464 276E CBA4 DF8E

To claim this, I am signing this object:

@justagist
justagist / railpro_download.py
Last active February 11, 2021 12:24
Download and create a csv or xlsx file containing all the listed companies from railpro.co.uk
"""
Download all listed companies from raipro.co.uk.
Saves to a single csv/xlsx file with columns
"Company Name", "Address", "Phone", "Website"
"""
import re
import urllib.request
import pandas as pd
import html