This repository has been archived by the owner on May 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
real_world_tasks.py
257 lines (176 loc) · 6.93 KB
/
real_world_tasks.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# -*- coding: utf-8 -*-
"""
Copyright (c) 2018 Robert Bosch GmbH
All rights reserved.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
@author: Andreas Doerr
"""
import os
import numpy as np
import scipy.io
from prssm.tasks.tasks import AutoregTask
class RealWorldTask(AutoregTask):
def __init__(self):
datapath = os.path.join(os.path.dirname(__file__),
'../../datasets/real_world_tasks')
super(RealWorldTask, self).__init__(datapath)
#
# Datasets from: http://www.gaussianprocess.org/gpml/data/
#
class SarcosArm(RealWorldTask):
"""
The data relates to an inverse dynamics problem for a seven
degrees-of-freedom SARCOS anthropomorphic robot arm. The task is
to map from a 21-dimensional input space (7 joint positions,
7 joint velocities, 7 joint accelerations) to the corresponding
7 joint torques.
Training data: sarcos_inv, 44484x28, double array
Test data: sarcos_inv_test, 4449x28, double array
Data order:
7 joint pos, 7 joint vel, 7 joint acc, 7 joint torques
Previously used to learn the mapping from (pos, vel, acc) --> torques
These data had previously been used in the papers
- LWPR: An O(n) Algorithm for Incremental Real Time Learning
in High Dimensional Space, S. Vijayakumar and S. Schaal,
Proc ICML 2000, 1079-1086 (2000).
- Statistical Learning for Humanoid Robots, S. Vijayakumar,
A. D'Souza, T. Shibata, J. Conradt, S. Schaal, Autonomous
Robot, 12(1) 55-69 (2002)
- Incremental Online Learning in High Dimensions S. Vijayakumar,
A. D'Souza, S. Schaal, Neural Computation 17(12) 2602-2634 (2005)
"""
name = 'sarcosarm'
def __init__(self):
super(SarcosArm, self).__init__()
# All inputs and all outputs
# self.input_ind = list(range(21, 28))
# self.output_ind = list(range(0, 21))
# Predict pos and vel for single joint from all inputs
# joint = 0
# self.input_ind = list(range(21, 28))
# self.output_ind = [0 + joint, 7 + joint]
# Predict pos and vel for all joints from all inputs
# self.input_ind = list(range(21, 28))
# self.output_ind = list(range(0, 14))
# Predict pos and vel for single joint from single joint input
# joint = 0
# self.input_ind = [21]
# self.output_ind = [0 + joint, 7 + joint]
# INVERSE DYNAMICS
# Predict torque from pos, vel, acc
# self.input_ind = list(range(0, 21))
# self.output_ind = list(range(21, 28))
# FORWARD DYNAMICS
# Predict positions from torques
self.input_ind = list(range(21, 28))
self.output_ind = list(range(0, 7))
self.train_ind = list(range(0, 60))
self.test_ind = list(range(60, 66))
# self.test_sub = 50
self.downsample = 1
def _load_data(self):
# Load train data
data = scipy.io.loadmat(os.path.join(self.datapath, 'sarcos_inv.mat'))
data = data['sarcos_inv']
data = data.astype(np.float64)
H = data.shape[0]
H_exp = 674
data_exps = [data[ind:ind+H_exp, :] for ind in range(0, H, H_exp)]
# Downsample original data
self.dt = 0.01 * self.downsample
data_exps_sub = [data[::self.downsample, :] for data in data_exps]
self.data_in_train = []
self.data_out_train = []
self.data_in_test = []
self.data_out_test = []
for i, data in enumerate(data_exps_sub):
# Training data
if i in self.train_ind:
self.data_in_train.append(data[:, self.input_ind])
self.data_out_train.append(data[:, self.output_ind])
# Test data
if i in self.test_ind:
self.data_in_test.append(data[:, self.input_ind])
self.data_out_test.append(data[:, self.output_ind])
# Load test data
# data = scipy.io.loadmat(os.path.join(self.datapath, 'sarcos_inv_test.mat'))
# data = data['sarcos_inv_test']
# data = data.astype(np.float64)
return True
#
# Datasets from: http://www.iau.dtu.dk/nnbook/systems.html
#
class Actuator(RealWorldTask):
name = 'actuator'
filename = 'actuator.mat'
def __init__(self):
super(Actuator, self).__init__()
self.split_point = 512
def _load_data(self):
data = scipy.io.loadmat(os.path.join(self.datapath, self.filename))
split_point = self.split_point
data_in = data['u'].astype(np.float64)
data_out = data['p'].astype(np.float64)
self.data_in_train = data_in[:split_point]
self.data_out_train = data_out[:split_point]
self.data_in_test = data_in[split_point:]
self.data_out_test = data_out[split_point:]
return True
#
# Datasets from http://homes.esat.kuleuven.be/~smc/daisy/daisydata.html
#
class Ballbeam(RealWorldTask):
name = 'ballbeam'
filename = 'ballbeam.dat'
def _load_data(self):
data = np.loadtxt(os.path.join(self.datapath, self.filename))
split_point = 500
data_in = data[:, 0]
data_out = data[:, 1]
self.data_in_train = data_in[:split_point]
self.data_out_train = data_out[:split_point]
self.data_in_test = data_in[split_point:]
self.data_out_test = data_out[split_point:]
self.dt = 0.1
return True
class Drive(RealWorldTask):
name = 'drive'
filename = 'drive.mat'
def _load_data(self):
data = scipy.io.loadmat(os.path.join(self.datapath, self.filename))
split_point = 250
data_in = data['u1']
data_out = data['z1']
self.data_in_train = data_in[:split_point]
self.data_out_train = data_out[:split_point]
self.data_in_test = data_in[split_point:]
self.data_out_test = data_out[split_point:]
return True
class Gas_furnace(RealWorldTask):
name = 'gas_furnace'
filename = 'gas_furnace.csv'
def _load_data(self):
data = np.loadtxt(os.path.join(self.datapath, self.filename),
skiprows=1, delimiter=',')
split_point = 148
data_in = data[:, 0]
data_out = data[:, 1]
self.data_in_train = data_in[:split_point]
self.data_out_train = data_out[:split_point]
self.data_in_test = data_in[split_point:]
self.data_out_test = data_out[split_point:]
return True
class Dryer(RealWorldTask):
name = 'dryer'
filename = 'dryer.dat'
def _load_data(self):
data = np.loadtxt(os.path.join(self.datapath, self.filename))
split_point = 500
data_in = data[:, 0]
data_out = data[:, 1]
self.data_in_train = data_in[:split_point]
self.data_out_train = data_out[:split_point]
self.data_in_test = data_in[split_point:]
self.data_out_test = data_out[split_point:]
return True