-
Notifications
You must be signed in to change notification settings - Fork 2
/
vis_markers_to_mano_trajectory.py
74 lines (59 loc) · 2.29 KB
/
vis_markers_to_mano_trajectory.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
"""Transfer MoCap markers to MANO: record mapping."""
import argparse
import numpy as np
import pytransform3d.visualizer as pv
from hand_embodiment.mocap_dataset import HandMotionCaptureDataset
from hand_embodiment.pipelines import MoCapToRobot
from hand_embodiment.vis_utils import AnimationCallback
from hand_embodiment.command_line import (
add_animation_arguments, add_configuration_arguments,
add_playback_control_arguments)
MARKER_COLORS = [
(0.5, 0.5, 0.5), (0.5, 0.5, 0.5), (0.5, 0.5, 0.5),
(1, 0, 0), (0.5, 0, 0),
(0, 1, 0), (0, 0.5, 0),
(0, 0, 1), (0, 0, 0.5),
(1, 1, 0), (0.5, 0.5, 0),
(0, 1, 1), (0, 0.5, 0.5),
(1, 0, 1), (0.5, 0, 0.5),
(0.5, 0.5, 0.5), (0.5, 0.5, 0.5), (0.5, 0.5, 0.5),
(0.5, 0.5, 0.5), (0.5, 0.5, 0.5), (0.5, 0.5, 0.5),
(0.5, 0.5, 0.5), (0.5, 0.5, 0.5), (0.5, 0.5, 0.5),
]
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
"--demo-file", type=str,
default="data/QualisysAprilTest/april_test_010.tsv",
help="Demonstration that should be used.")
add_configuration_arguments(parser)
add_playback_control_arguments(parser)
parser.add_argument(
"--interpolate-missing-markers", action="store_true",
help="Interpolate NaNs.")
parser.add_argument(
"--hide-mano", action="store_true", help="Hide MANO mesh")
add_animation_arguments(parser)
return parser.parse_args()
def main():
args = parse_args()
dataset = HandMotionCaptureDataset(
args.demo_file, mocap_config=args.mocap_config,
skip_frames=args.skip_frames, start_idx=args.start_idx,
end_idx=args.end_idx,
interpolate_missing_markers=args.interpolate_missing_markers)
pipeline = MoCapToRobot(
"mia", args.mano_config, dataset.finger_names,
record_mapping_config=args.record_mapping_config, verbose=1)
fig = pv.figure()
fig.plot_transform(np.eye(4), s=0.5)
markers = dataset.get_markers(0)
markers = fig.scatter(markers, s=0.006, c=MARKER_COLORS[:len(markers)])
animation_callback = AnimationCallback(fig, pipeline, args)
fig.view_init(azim=45)
fig.animate(
animation_callback, dataset.n_steps, loop=True,
fargs=(markers, dataset, pipeline))
fig.show()
if __name__ == "__main__":
main()