Skip to content

Instantly share code, notes, and snippets.

View LimHyungTae's full-sized avatar
🎯
Focusing on the next paper!

Hyungtae Lim LimHyungTae

🎯
Focusing on the next paper!
View GitHub Profile
@LimHyungTae
LimHyungTae / angle_type_conversion.cpp
Last active December 4, 2023 14:45
ROS quaternion to rotation matrix OR rotation matrix to roll-pitch-yaw OR roll-pitch-yaw to quaternion
#include <iostream>
#include <tf/tf.h>
int main(){
/**< Declaration of quaternion */
tf::Quaternion q;
q.setW(1);
q.setX(0);
q.setY(0);
@LimHyungTae
LimHyungTae / set_get_comparison.cpp
Created December 16, 2019 15:41
ROS difference btw setRotation() and getRotation() in tf::Matrix3x3
#include <iostream>
#include <tf/tf.h>
void coutQuaternion(tf::Quaternion q){
std::cout<<q.getX()<<", "<<q.getX()<<", "<<q.getZ()<<", "<<q.getW()<<std::endl;
}
void coutTfMat(const tf::Matrix3x3& mat){
std::cout<<mat[0][0]<<mat[0][1]<<mat[0][2]<<std::endl;
std::cout<<mat[1][0]<<mat[1][1]<<mat[1][2]<<std::endl;
#include <iostream>
vector<float> ints = {0.01, 0.02, 0.03, 0.04};
void main(){
// to avoid copying
for (auto &i: ints){
std::cout<< i <<std::endl;
}
// to prevent to change the value
for (auto const i: ints){
import torch
import torch.nn as nn
from torch.autograd import Variable
import torch.nn.functional as F
num_classes = 5
input = torch.randn(3, num_classes, requires_grad=True)
print(input)
target = torch.randint(num_classes, (3,), dtype=torch.int64)
print(target)
@LimHyungTae
LimHyungTae / auto_train.sh
Created January 17, 2020 17:01
Auto training using shell script
#!/bin/sh
gpu='1'
seq='0'
batch=6400
dir="/home/shapelim/RONet/0213fc_"
network_type='fc'
#
count="_1/"
python3.5 train.py --save_dir $dir$count --gpu $gpu --sequence_length $seq --batch_size $batch --network_type $network_type
python3.5 test.py --load_model_dir $dir$count --gpu $gpu --sequence_length $seq --network_type $network_type
@LimHyungTae
LimHyungTae / draw_histogram.py
Created February 4, 2020 12:57
Draw histogram on Python
import h5py
import os
import numpy as np
import cv2
import matplotlib.pyplot as plt
from scipy import ndimage, misc
from scipy.stats import norm
def draw_histogram(x, n_bins, name):
n, bins, patches = plt.hist(x, bins=n_bins, color=(0.0, 0.0, 0.5), density=True)
@LimHyungTae
LimHyungTae / Terminator config setting
Last active August 27, 2021 06:50
Terminator setting in Ubuntu 18.04. Paste the contents on the ~/.config/terminator/config
[global_config]
focus = system
handle_size = 1
tab_position = bottom
[keybindings]
# Normalize for Esential Matrix calaculation
pts_l_norm = cv2.undistortPoints(np.expand_dims(pts_l, axis=1), cameraMatrix=K_l, distCoeffs=None)
pts_r_norm = cv2.undistortPoints(np.expand_dims(pts_r, axis=1), cameraMatrix=K_r, distCoeffs=None)
E, mask = cv2.findEssentialMat(pts_l_norm, pts_r_norm, focal=1.0, pp=(0., 0.), method=cv2.RANSAC, prob=0.999, threshold=3.0)
points, R, t, mask = cv2.recoverPose(E, pts_l_norm, pts_r_norm)
M_r = np.hstack((R, t))
M_l = np.hstack((np.eye(3, 3), np.zeros((3, 1))))
@LimHyungTae
LimHyungTae / ros_subscriber_multithread.py
Created July 15, 2020 08:53
Multithread to preserve the data on ROS
#!/usr/bin/env python
import rospy
from std_msgs.msg import String
from sensor_msgs.msg import CompressedImage, Image
from cv_bridge import CvBridge
import cv2
import threading
import time
@LimHyungTae
LimHyungTae / pcl_snippet_transformation.cpp
Last active April 8, 2021 04:28
ROS Point Cloud Library (PCL) Transformation example code
#include <iostream>
#include <pcl/common/transforms.h>
#include <pcl/point_types.h>
#include <pcl/point_cloud.h>
// Input: pcl::PointCloud source, namely cloud_src
//Output: Transformed pcl::PointCloud, namely pc_transformed, via 4x4 transformation matrix
int main(int argc, char **argv){