Switch to unified view

a b/tool_funcs/getOpenSimVersion.m
1
%-------------------------------------------------------------------------%
2
%    Copyright (c) 2021 Modenese L.                                       %
3
%    Author:   Luca Modenese,  2021                                       %
4
%    email:    l.modenese@imperial.ac.uk                                  %
5
% ----------------------------------------------------------------------- %
6
% This script returns the OpenSim version
7
% ----------------------------------------------------------------------- %
8
function [osim_version_float, osim_version_string] = getOpenSimVersion()
9
10
import org.opensim.modeling.*
11
12
% read env variable
13
try
14
    % method available only from 4.x
15
    os_version = char(opensimCommonJNI.GetVersion());
16
    
17
    % get the field separators, e.g. '-
18
    % sep_set = strfind(os_version, '-');
19
    
20
    % use the last file separator to get the OpenSim installation folder name
21
    version = os_version(1:3);
22
    
23
    % get the string for the opensim version
24
    osim_version_string = strtrim(strrep(lower(version),'opensim', ''));
25
    
26
    % transform in float
27
    osim_version_float = str2double(osim_version_string);
28
    
29
catch
30
    
31
    % GetVersion is not available in earlier OpenSim versions
32
    osim_version_float = 3.3;
33
    osim_version_string = '3.3';
34
    return
35
end
36
end