Skip to content

Instantly share code, notes, and snippets.

View HosikChae's full-sized avatar
๐Ÿ’ญ

Hosik Chae HosikChae

๐Ÿ’ญ
View GitHub Profile
@HosikChae
HosikChae / KF.m
Created April 7, 2022 12:19
Template for Kalman Filter implemented in Simulink Interpreted Function block
function y = KF(x)
% reference: https://www.mathworks.com/help/matlab/ref/persistent.html
persistent A B C D dt m1 l1 R Q P0 P;
% only executed at the first time -> initialization
if isempty(P)
% A = ...; B = ...; C = ...; D = ...;
% R = ...; Q = ...; P0 = ...;
% m1 = ...; l1 = ...; dt = ...;
end
@HosikChae
HosikChae / damped_least_square.py
Last active April 25, 2023 07:36
Inverse Kinametics
import numpy as np
import collections
def IK(joint, JOINT_IDs, Dmax=0.3, lam=0.1, a=0.1):
[u, D, vT] = np.linalg.svd(jacobian(JOINT_IDs))
op = vT.T @ np.diag(D / (D ** 2 + lam ** 2)) @ l.T
th = clipped_vector(joint[JOINT_ID_EE]['p_des'] - joint[JOINT_ID_EE]['p'], Dmax) # p/p_des: desired/current Position in World Coord
a = skew2axis(joint[JOINT_ID_EE]['R_des'] @ joint[JOINT_ID_EE]['R'].T) # R/R_des : desired/current attitude in World Coord
q = a * op @ np.vstack((th, a))
@HosikChae
HosikChae / cmake-tutorial.md
Created January 17, 2022 07:56 — forked from dongbum/cmake-tutorial.md
CMake ํ• ๋•Œ ์ชผ์˜ค์˜ค๊ธˆ ๋„์›€์ด ๋˜๋Š” ๋ฌธ์„œ

CMake๋ฅผ ์™œ ์“ฐ๋Š”๊ฑฐ์ฃ ?
์ข‹์€ ํˆด์€ Visual Studio ๋ฟ์ž…๋‹ˆ๋‹ค. ๊ทธ ์ด์™ธ์—๋Š” ์ „๋ถ€ ์‚ฌ๋„(้‚ช้“)์ž…๋‹ˆ๋‹ค ์‚ฌ๋„! - ์ž‘์„ฑ์ž

์ฃผ์˜

  • ์ด ๋ฌธ์„œ๋Š” CMake๋ฅผ ์ฃผ๊ด€์ ์œผ๋กœ ์„œ์ˆ ํ•ฉ๋‹ˆ๋‹ค
  • ์ด ๋ฌธ์„œ๋ฅผ ํ†ตํ•ด CMake๋ฅผ ์‹œ์ž‘ํ•˜๊ธฐ์—” ์ ํ•ฉํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค
    https://cgold.readthedocs.io/en/latest/ 3.1 ์ฑ•ํ„ฐ๊นŒ์ง€ ๋”ฐ๋ผํ•ด๋ณธ ์ดํ›„ ๊ธฐ๋ณธ์‚ฌํ•ญ๋“ค์„ ์†์„ฑ์œผ๋กœ ์ตํžˆ๋Š” ๊ฒƒ์„ ๋•๊ธฐ์œ„ํ•œ ๋ณด์กฐ์ž๋ฃŒ๋กœ์จ ์ž‘์„ฑ๋˜์—ˆ์Šต๋‹ˆ๋‹ค
@HosikChae
HosikChae / eigen_matlab.cpp
Created January 14, 2022 08:14 — forked from phg1024/eigen_matlab.cpp
Eigen-MATLAB reference
// A simple quickref for Eigen. Add anything that's missing.
// Main author: Keir Mierle
#include <Eigen/Dense>
Matrix<double, 3, 3> A; // Fixed rows and cols. Same as Matrix3d.
Matrix<double, 3, Dynamic> B; // Fixed rows, dynamic cols.
Matrix<double, Dynamic, Dynamic> C; // Full dynamic. Same as MatrixXd.
Matrix<double, 3, 3, RowMajor> E; // Row major; default is column-major.
Matrix3f P, Q, R; // 3x3 float matrix.
@HosikChae
HosikChae / controller.py
Created July 1, 2020 07:49 — forked from claymcleod/controller.py
Playstation 4 Controller Python
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
# This file presents an interface for interacting with the Playstation 4 Controller
# in Python. Simply plug your PS4 controller into your computer using USB and run this
# script!
#
# NOTE: I assume in this script that the only joystick plugged in is the PS4 controller.
# if this is not the case, you will need to change the class accordingly.
#
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
@HosikChae
HosikChae / COVID19_Korea_Fitting.m
Created February 27, 2020 02:09
Fitting the number of Corona patients in Korea
clear; clc; close all;
% from 'cdc.go.kr'
data_Feb = [12, 15, 15, 16, 18, 23, 24, 22, 23, 27, 28, 28, 28, 28, 28, 29, 30, 31, 46, 82, 156, 346, 556, 763, 893, 1146, 1595];
max_capacity = 7500;
t = 1:length(data_Feb);
x0 = [1 1];
F = @(x,xdata)x(1)*exp(-x(2)*xdata);% + x(3)*exp(-x(4)*xdata);
[x,resnorm,~,exitflag,output] = lsqcurvefit(F,x0,t,data2);