This file contains hidden or 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 __future__ import print_function | |
import numpy as np | |
import gym | |
from gym.spaces import Discrete, Box | |
# DQN for Reinforcement Learning | |
# by Qin Yongliang | |
# 2017 01 11 | |
def continuous_actions(env): |
This file contains hidden or 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 __future__ import print_function | |
# Deep Deterministic Policy Gradient Method | |
# David Silver et al. | |
# implemented in plain Keras, by Qin Yongliang | |
# 2017 01 13 | |
''' | |
summary |
This file contains hidden or 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 __future__ import print_function | |
# Deep Deterministic Policy Gradient Method | |
# David Silver et al. | |
# implemented in plain Keras, by Qin Yongliang | |
# 2017 01 13 | |
# heavily optimized for speed, lots of numpy flowed into tensorflow | |
# 2017 01 14 |
This file contains hidden or 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
REM make sure you have miniconda installed | |
cd c:\ | |
conda create -n osrl -c kidzik opensim git python=2.7 | |
activate osrl | |
git clone https://github.com/stanfordnmbl/osim-rl | |
git clone https://github.com/ctmakro/stanford-osrl | |
pip install pyro4 pymsgbox |
This file contains hidden or 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 trilaterate(points, distances): | |
# ported from https://github.com/gheja/trilateration.js | |
# points -> list of np arrays in the form of [[x, y, z], [x, y, z] | |
# distances -> np array [r1, r2, r3] | |
p1,p2,p3 = points | |
r1,r2,r3 = distances | |
def norm(v): | |
return np.sqrt(np.sum(v**2)) |
This file contains hidden or 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 normalized(v): | |
norm = np.sqrt(np.sum(v**2)) | |
return v / norm | |
# Trilateration to find the target point, given positions of 3 points, and distances(radiuses) | |
def trilaterate(points, distances): | |
precision = 1e-3 | |
iteration = 1000 |
This file contains hidden or 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
# tacos=[[2.7647068559860712, -0.008816344965933138, 0.08419820920066164], [4.1482390698137275, 0.004365272677300839, 0.059974440683546126], [4.799411832657377, 0.012794506986796655, 0.07305748780077449], [2.395640662714245, 0.005136789959712116, 0.055235542912785984], [3.3942322982802495, 0.0034807961045444052, 0.058021672551073204], [4.556883550968967, 0.006043932006157158, 0.050294840880930024], [2.1072139294765933, 0.019171523718931313, 0.15339955024246338], [3.3087723737032717, 0.02240615211003253, 0.1343706158894652], [4.568062436714624, 0.01720806864461718, 0.07717739475940219]] | |
# psoas=[[1.0832688044403371, 1.0456262964311989], [1.0823437836374254, 0.8830063845929389], [0.9780701248134204, 1.016855183151065]] | |
test=None | |
test999=None |
This file contains hidden or 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
# if input image is in range 0..1, please first multiply img by 255 | |
# assume image is ndarray of shape [height, width, channels] where channels can be 1, 3 or 4 | |
def imshow(img): | |
import cv2 | |
import IPython | |
_,ret = cv2.imencode('.jpg', img) | |
i = IPython.display.Image(data=ret) | |
IPython.display.display(i) |
This file contains hidden or 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
// return true if there is character in uart recv buffer, false otherwise. | |
int peek(){ | |
#include <xuartps_hw.h> | |
#include <xparameters.h> | |
return XUartPs_IsReceiveData(XPAR_PS7_UART_0_BASEADDR); | |
} | |
// it is recommended to use inbyte() to read a byte after peek() returned true. |
This file contains hidden or 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
/* | |
With an Arduino, | |
If you want to: | |
1) execute a function precisely every N microseconds (or precisely 1,000,000/N times every second), | |
REGARDLESS of the running time of that function | |
2) obtain a precision of +-4 microseconds with NO ACCUMULATION OF ERROR | |
3) use no 3rd party libraries | |
Then this is for you. | |
*/ |
OlderNewer