forked from petercorke/RVC3-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfig7_7.py
More file actions
executable file
·75 lines (55 loc) · 1.77 KB
/
fig7_7.py
File metadata and controls
executable file
·75 lines (55 loc) · 1.77 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python3
import pyvista as pv
import numpy as np
from spatialmath import SE3
from math import cos, sin, pi
import pvplus
def zoom(plotter, value):
if not plotter.camera_set:
plotter.camera_position = plotter.get_default_cam_pos()
plotter.reset_camera()
plotter.camera_set = True
plotter.camera.Zoom(value)
plotter.render()
# Monkey patch it
pv.Plotter.zoom = zoom
plotter = pv.Plotter(polygon_smoothing=True, window_size=(2000,2000))
overlap = 0.2
r = 100
eer = 0.06
opacity = 0.3
wf = True
zl = -0.4
q1 = 0.7
q2 = 0.5
T1 = SE3.Rz(q1)
T2 = SE3.Rz(q1) * SE3.Tx(1) * SE3.Rz(q2)
TE = SE3.Rz(q1) * SE3.Tx(1) * SE3.Rz(q2) * SE3.Tx(1) * SE3.Tz(-eer)
pvplus.add_frame2(plotter, SE3(0, 0, zl), scale=0.5, label='O')
## link 1
L1 = pv.Box(bounds=(-overlap, 1+overlap, -0.2, 0.2, -0.1, 0))
L1.transform(T1.A)
plotter.add_mesh(L1, color='red', show_edges=wf, opacity=opacity)
# joint
pvplus.axis(plotter, text='q_0')
# frame
pvplus.add_frame2(plotter, T1, label='1', scale=0.5)
## link 2
L2 = pv.Box(bounds=(-overlap, 1, -0.2, 0.2, -0.1, 0))
T = SE3(1, 0, 0.2)
L2.transform(T2.A)
plotter.add_mesh(L2, color='blue', show_edges=wf, opacity=opacity)
pvplus.add_frame2(plotter, T2, scale=0.5, label='2')
pvplus.axis(plotter, T2, text='q_1')
## end-effector
EE = pv.Sphere(radius=eer, center=(0,0, 0))
EE.transform(TE.A)
plotter.add_mesh(EE, color='black')
pvplus.add_frame2(plotter, TE, scale=0.5, label='E')
# centre the scene in camera view, look along -X axis
plotter.camera_position = [(3,-4, 2), (1, 0, 0), (0, 0, 1)]
plotter.set_background('white')
plotter.disable_parallel_projection()
# plotter.show_axes() # put a small frame for orientation in bottom left
# plotter.show_bounds(grid='front') # overlay a grid
plotter.export_gltf('fig7_7.gltf')