-
Notifications
You must be signed in to change notification settings - Fork 2
/
demo_drawData.py
50 lines (40 loc) · 1.65 KB
/
demo_drawData.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
from __future__ import print_function
import time
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rc
from matplotlib.widgets import Button
from ds_tools.mousetrajectory_gui import MouseTrajectory
rc('font',**{'family':'serif','serif':['Times']})
rc('text', usetex=True)
'''
Brings up an empty world environment to draw "human-demonstrated" trajectories
'''
if __name__ == '__main__':
# Create figure/environment to draw trajectories on
fig, ax = plt.subplots()
plt.subplots_adjust(bottom=0.2)
points, = ax.plot([], [], 'ro', markersize=2, lw=2)
ax.set_xlim(-0.25, 1.25)
ax.set_ylim(0, 1)
plt.gca().set_aspect('equal', adjustable='box')
plt.xlabel('$x_1$',fontsize=15)
plt.ylabel('$x_2$',fontsize=15)
plt.title('Draw trajectories to learn a motion policy:',fontsize=15)
# Add UI buttons for data/figure manipulation
store_btn = plt.axes([0.67, 0.05, 0.075, 0.05])
clear_btn = plt.axes([0.78, 0.05, 0.075, 0.05])
snap_btn = plt.axes([0.15, 0.05, 0.075, 0.05])
bstore = Button(store_btn, 'store')
bclear = Button(clear_btn, 'clear')
bsnap = Button(snap_btn, 'snap')
# Calling class to draw data on top of environment
indexing = 1 # Set to 1 if you the snaps/data to be indexed with current time-stamp
store_mat = 0 # Set to 1 if you want to store data in .mat structure for MATLAB
draw_data = MouseTrajectory(points, indexing, store_mat)
draw_data.connect()
bstore.on_clicked(draw_data.store_callback)
bclear.on_clicked(draw_data.clear_callback)
bsnap.on_clicked(draw_data.snap_callback)
# Show
plt.show()