Skip to content

Commit

Permalink
finish offline jrs generation backport
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildingAtom committed Feb 16, 2024
1 parent 6ed0d59 commit cb7f660
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 30 deletions.
4 changes: 4 additions & 0 deletions zonopyrobots/joint_reachable_set/jrs_trig/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.mat
jrs_trig_mat_saved*/
jrs_trig_tensor_saved*/
gen_jrs_trig/jrs_trig_dynamics/
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
t_plan = 0.5;
t_total = 1;
dt = 0.01;
d_kai = pi/24; % parameter range for acceleration

% generates dynamics parameterized by K
[dyn_zero_to_t_plan, dyn_t_plan_to_t_total] = ...
Expand Down Expand Up @@ -43,6 +44,9 @@
% save vector of initial velocity subinterval centers
save(fullfile(save_path,'c_kvi.mat'), 'c_kvi');

% save the parameter range
save(fullfile(save_path,'d_kai.mat'), 'd_kai');

% set options for reachability analysis:
options.timeStep = dt;
options.taylorTerms=5; % number of taylor terms for reachable sets
Expand All @@ -63,9 +67,6 @@
for j = 1:n_JRS
% break JRS computation into two steps...
tic;
%delta_kai = max(pi/24, (abs(c_kvi(j))+delta_kvi)/3);
%delta_kai = pi/24; % EXCLUDE heuristic
delta_kai = pi/24;
% first, use dyn_zero_to_t_plan dynamics
params.tStart = 0; % start time
params.tFinal = t_plan; % end time for these dynamics
Expand All @@ -74,7 +75,7 @@
% this is described by eqs. (3) and (8)
params.x0 = [1; 0; c_kvi(j); c_kai; c_kvi(j); 0]; % start at q_i = 0, so cos(q_i) = 1 and sin(q_i) = 0
% use two generators, one for K^a_i and one for K^v_i (eq. 8)
params.R0 = zonotope([params.x0, [0; 0; 0; delta_kai; 0; 0], [0; 0; delta_kvi; 0; delta_kvi+epsilon; 0]]);
params.R0 = zonotope([params.x0, [0; 0; 0; d_kai; 0; 0], [0; 0; delta_kvi; 0; delta_kvi+epsilon; 0]]);

% create system for reachability analysis (1 dummy input)
% CORA 2018:
Expand Down

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
17 changes: 16 additions & 1 deletion zonopyrobots/joint_reachable_set/offline_jrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,27 @@
Array = Union[Tensor, ndarray]

class OfflineJRS:
""" Wrapper for preloading and processing ARMTD style JRS tensors generated offline
These tensors are generated offline using the MATLAB scripts in the jrs_trig/gen_jrs_trig folder.
This provides a wrapper for some of the jrs_trig.load_jrs_trig and jrs_trig.process_jrs_trig functions
to make it easier to use the JRS tensors. The JRS tensors are preloaded and processed in the __init__ function
and then the __call__ function can be used to get the JRS and the corresponding rotatotopes for a given configuration
and velocity.
This specifically loads the tensors from the jrs_trig/jrs_trig_tensor_saved folder
"""
def __init__(
self,
device: torch.device = 'cpu',
dtype: torch.dtype = torch.float,
):
""" Wrapper for preloading and processing JRS tensors """
""" Wrapper for preloading and processing JRS tensors
Args:
device (torch.device, optional): The device to use for the JRS tensors. Defaults to 'cpu'.
dtype (torch.dtype, optional): The dtype to use for the JRS tensors. Defaults to torch.float.
"""
from .jrs_trig.load_jrs_trig import g_ka
self.jrs_tensor = _preload_batch_JRS_trig(device=device, dtype=dtype)
self.g_ka = g_ka
Expand Down

0 comments on commit cb7f660

Please sign in to comment.