-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrajectory_feature.m
68 lines (61 loc) · 2.21 KB
/
trajectory_feature.m
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
classdef trajectory_feature < handle
%TAG Groups together some commmon attributes of trajectories
properties(GetAccess = 'public', SetAccess = 'protected')
% short and long descriptions
abbreviation = '';
end
properties(GetAccess = 'private', SetAccess = 'private')
hash_ = [];
f_ = [];
start_time_offset_ = -1;
dt_ = -1;
end
methods
%% constructor
function inst = trajectory_feature(abbrev, desc, func, rarg, prop, varargin)
inst.abbreviation = abbrev;
if nargin < 4
rarg = 1;
end
if nargin < 5
prop = {};
end
[inst.start_time_offset_, inst.dt_] = process_options(varargin, ...
'StartTimeOffset', -1, ...
'TLength', -1 ...
);
inst.f_ = function_wrapper(desc, func, rarg, prop, varargin{:});
end
function val = hash_value(inst)
val = inst.f_.hash_value;
val = hash_combine(val, inst.start_time_offset_);
val = hash_combine(val, inst.dt_);
end
function set_parameters(inst, config)
inst.f_.set_parameters(config);
end
function ret = value(inst, traj)
% compute over the whole trajectory or just a sub-segment?
if inst.start_time_offset_ > 0 || inst.dt_ > 0
if inst.start_time_offset_ > 0
toff = inst.start_time_offset_;
else
toff = 0;
end
if inst.dt_ > 0
dt = inst.dt_;
else
% to infinity - will take the rest of the trajectory
dt = 1e10;
end
seg = traj.sub_segment_time(toff, dt);
ret = inst.f_.apply1(seg);
else
ret = inst.f_.apply1(traj);
end
end
function desc = description(inst)
desc = inst.f_.description;
end
end
end