Skip to content

Instantly share code, notes, and snippets.

View myjr52's full-sized avatar

Jongrae.K myjr52

View GitHub Profile
@myjr52
myjr52 / yaw_manoeuvre.ino
Last active July 6, 2016 15:46
CoDrone yaw manoeuvre
#include <CoDrone.h>
int init_yaw;
int cmd_yaw;
int err_yaw;
void setup()
{
CoDrone.begin(115200);
CoDrone.AutoConnect(NearbyDrone);
@myjr52
myjr52 / igrf12.f
Last active August 29, 2015 14:18
IGFR12 Model in Python using f2py
c the orignal coming from: http://www.ngdc.noaa.gov/IAGA/vmod/igrf.html, and modified by jongrae
c
subroutine igrf12syn (isv,date,itype,alt,colat,elong,x,y,z,f)
c
c This is a synthesis routine for the 12th generation IGRF as agreed
c in December 2014 by IAGA Working Group V-MOD. It is valid 1900.0 to
c 2020.0 inclusive. Values for dates from 1945.0 to 2010.0 inclusive are
c definitive, otherwise they are non-definitive.
c INPUT
c isv = 0 if main-field values are required
@myjr52
myjr52 / analyse_worm_moving.py
Created February 10, 2015 14:18
analyse c.elegans movement;you need the image files to run this problem; download zip compressed image files from here and extract at the same directory where the below python programme is saved. https://drive.google.com/file/d/0B5smtso7TwjrZmlRUjhKNlNQbWs/view?usp=sharing
import numpy as np
import matplotlib.pyplot as plt
from skimage.segmentation import boundaries
from scipy import ndimage
num_image = 4
fig = plt.figure(1)
@myjr52
myjr52 / rot_3d_box.py
Last active August 29, 2015 14:13
rotating 3d box in space
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
import numpy as np
from scipy.integrate import odeint
def DCM_ode(state, t):
w1 = 0.1*np.sin(2*t)
w2 = 0.01*np.cos(0.2*t)
w3 = -0.1*np.sin(0.1*t+0.5)
import scipy as sp
from scipy.integrate import odeint
import matplotlib.pyplot as plt
# 마분방정식이 적분기 부르기 전에 정의되어야 합니다.
def RLC_eqn(x, t):
R, L, C = [1, 1, 1]
u = 1
x1, x2 = x
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
# number of samples
num_sample = 2000;
# map size
map_width = 10;
map_height = 5;
@myjr52
myjr52 / get_shortest_path.py
Created January 8, 2015 22:04
Get shortest path for arbitrary generated distance matrix
import scipy as sp
num_node = 1000
num_path = max([int(num_node*num_node/4), 1])
row = sp.unique(sp.random.randint(0,num_node,num_path));
col = sp.random.randint(0,num_node,row.size);
mask = row!=col
row = row[mask]
col = col[mask]
@myjr52
myjr52 / dijkstra_example.py
Last active August 29, 2015 14:12 — forked from avrilcoghlan/dijkstra_example.py
calculate shortest path using dijkstra's algorithm
# define distance matrix
import scipy as sp
A = sp.array([[0,2,0,5,0,0],
[2,0,1,3,4,0],
[0,1,0,4,0,0],
[5,3,4,0,2,4],
[0,4,0,2,0,1],
[0,0,0,4,1,0]])
@myjr52
myjr52 / cost_function.py
Created January 1, 2015 23:11
find optimal spring and damping constants using minimize in scipy
def cost_function(x):
k_spring, c_damper = x
# import functions
from numpy import linspace, max, abs
from scipy.integrate import odeint
import msd_ode
# define constants
@myjr52
myjr52 / msd_ode.py
Last active August 29, 2015 14:12
integrate ode in Python: ode in separate file
def mass_spring_damper(state, t, k_c_set):
x, x_dot = state
k_spring, c_damper = k_c_set
f = [x_dot,
-k_spring*x - c_damper*x_dot]
return f