-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathrrr_robot_planning.py
55 lines (43 loc) · 1.46 KB
/
rrr_robot_planning.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""
RRR Robot trajectory planning examples
"""
import numpy as np
from utils.trajectory_generator import TrajectoryGenerator
from robots.rrr_robot import RRRRobot
from rrr_robot_jacobians import get_symbolic_jacobian_inverse
def main():
dq_max = 1
ddq_max = 20
dx_max = 1
ddx_max = 10
n = 50
cf = 10
tg = TrajectoryGenerator(dq_max, ddq_max, dx_max, ddx_max, control_freq=cf)
# Polynomial joint trajectory
q_0 = [[0.5, 0, 0], [-0.6, 0, 0], [0, 0, 0]]
q_f = [[1.57, 0, 0], [0.5, 0, 0], [-2.0, 0, 0]]
t_0, t_f = 0, 2
qs = tg.generate_joint_poly_trajectory(q_0,
q_f,
t_f,
t_0=t_0,
n=n,
plot=True)
robot = RRRRobot()
robot.move_joints(qs)
# Trapezoidal joint trajectory
q_0 = [0.0, 0.0, 0.0]
q_f = [-0.9, -2.3, 1.2]
qs = tg.generate_p2p_trajectory(q_0, q_f, n=n, plot=True)
robot = RRRRobot()
robot.move_joints(qs)
# Trapezoidal cartesian linear trajectory
p_1 = [1.0, 0.0, 2.0]
p_2 = [np.sqrt(2) / 2, np.sqrt(2) / 2, 1.2]
xs, dxs, ts = tg.generate_lin_trajectory(p_1, p_2, n=n, plot=True)
robot = RRRRobot()
qs = robot.move_via_points(xs)
J_inv = get_symbolic_jacobian_inverse()
tg.get_dq_from_dx(qs, dxs, J_inv, ts)
if __name__ == '__main__':
main()