This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
x = np.arange(0.001, 5, 0.001) | |
def Huber(a, d): | |
x = np.zeros_like(a) | |
x[a<d] = 0.5 * a[a<d]**2 | |
x[a>=d] = d * (np.abs(a[a>=d]) - 0.5 * d) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Add the path to this file to Tools -> Options -> Debugger -> Locals & Expressions -> Extra Debugging Helpers | |
## Based on the `misctypes.py` which ships with QtCreator, and extended to add support for Maps and my geometry library | |
from dumper import * | |
# Similar to Matrix, but you have to dive into the pointer | |
def qdump__Eigen__Map(d, value): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import numpy as np | |
import math | |
import time | |
import cvxpy | |
l = 1.5 # length of bar | |
M = 1.0 # [kg] | |
m = 0.1 # [kg] | |
g = 9.8 # [m/s^2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def skew(v): | |
return np.array([[0, -v[2,0], v[1,0]], | |
[v[2,0], 0, -v[0,0]], | |
[-v[1,0], v[0,0], 0]]) | |
for i in range(1000): | |
w0 = np.random.rand(3, 1) | |
v = np.ones((3, 1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sets import Set | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from tqdm import tqdm | |
p_z_gx = np.array([[0.7, 0.3], | |
[0.3, 0.7]]) | |
p_x_g_u_z = np.zeros((2,3,2)) | |
p_x_g_u_z[:,2,:] = np.array([[0.2, 0.8], | |
[0.8, 0.2]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tensorflow.python.ops.rnn_cell import RNNCell | |
from tensorflow.python.ops import math_ops | |
import tensorflow as tf | |
class myGRU(RNNCell): | |
def __init__(self, num_units, forget_bias=1.0, | |
state_is_tuple=True, activation=None, reuse=None): | |
super(RNNCell, self).__init__(_reuse=reuse) | |
self._num_units = num_units | |
self._forget_bias = forget_bias |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import scipy.linalg | |
import scipy.stats | |
import matplotlib.pyplot as plt | |
import scipy.io | |
import scipy.sparse | |
from plot_helper import plot_cov_ellipse | |
from tqdm import tqdm | |
def R(theta): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
from matplotlib.patches import Ellipse | |
import numpy as np | |
def plot_point_cov(points, nstd=2, ax=None, **kwargs): | |
""" | |
Plots an `nstd` sigma ellipse based on the mean and covariance of a point | |
"cloud" (points, an Nx2 array). | |
Parameters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is an implementation of Occupancy Grid Mapping as Presented | |
# in Chapter 9 of "Probabilistic Robotics" By Sebastian Thrun et al. | |
# In particular, this is an implementation of Table 9.1 and 9.2 | |
import scipy.io | |
import scipy.stats | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from tqdm import tqdm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def lqr(A,B,Q,R): | |
#first, try to solve the ricatti equation | |
X = np.matrix(solve_continuous_are(A, B, Q, R)) | |
#compute the LQR gain | |
K = np.matrix(inv(R)*(B.T*X)) | |
eigVals, eigVecs = eig(A-B*K) | |
return K, X, eigVals |
NewerOlder