-
Notifications
You must be signed in to change notification settings - Fork 0
/
Function.py
35 lines (24 loc) · 1.11 KB
/
Function.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import numpy as np
from math import cos, sin
# Given time and coeffs of quintic fuction to calcute position
def calculate_pos(c, t):
pos = c[0] * t ** 5 + c[1] * t ** 4 + c[2] * t ** 3 + c[3] * t ** 2 + c[4] * t + c[5]
return pos
# Given time and coeffs of quintic fuction to calcute velocity
def calculate_vel(c, t):
vel= 5 * c[0] * t ** 4 + 4 * c[1] * t ** 3 + 3 * c[2] * t ** 2 + 2 * c[3] * t + c[4]
return vel
# Given time and coeffs of quintic fuction to calcute acceleration
def calculate_acc(c, t):
acc = 20 * c[0] * t ** 3 + 12 * c[1] * t ** 2 + 6 * c[2] * t + 2 * c[3]
return acc
# Calculate rotation matrix
def rotation_matrix(roll, pitch, yaw):
rot_m=np.array(
[[cos(yaw) * cos(pitch), -sin(yaw) * cos(roll) + cos(yaw) * sin(pitch) * sin(roll),
sin(yaw) * sin(roll) + cos(yaw) * sin(pitch) * cos(roll)],
[sin(yaw) * cos(pitch), cos(yaw) * cos(roll) + sin(yaw) * sin(pitch) *
sin(roll), -cos(yaw) * sin(roll) + sin(yaw) * sin(pitch) * cos(roll)],
[-sin(pitch), cos(pitch) * sin(roll), cos(pitch) * cos(yaw)]
])
return rot_m