Skip to content

Instantly share code, notes, and snippets.

View yanfengliu's full-sized avatar
⌨️
Learning

Yanfeng Liu yanfengliu

⌨️
Learning
View GitHub Profile
@yanfengliu
yanfengliu / transform_matrix_tensor.py
Last active January 1, 2019 22:01
Create transform matrix in tensor form for forward kinematics
def transform_matrix_tensor(theta, d, a, alpha):
# tensor version of transform matrix
matrix = [[tf.cos(theta), tf.multiply(-tf.sin(theta), tf.cos(alpha)), tf.multiply(tf.sin(theta), tf.sin(alpha)), tf.multiply(a, tf.cos(theta))],
[tf.sin(theta), tf.multiply(tf.cos(theta), tf.cos(alpha)), tf.multiply(-tf.cos(theta), tf.sin(alpha)), tf.multiply(a, tf.sin(theta))],
[tf.zeros_like(theta), tf.sin(alpha), tf.cos(alpha), d],
[tf.zeros_like(theta), tf.zeros_like(theta), tf.zeros_like(theta), tf.ones_like(theta)]]
return matrix
def forward_kinematics_loss_2(y_true, y_pred):
# y_true is the xy position