Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error reported when running simulation #2

Open
CPU-beng opened this issue Mar 6, 2024 · 0 comments
Open

Error reported when running simulation #2

CPU-beng opened this issue Mar 6, 2024 · 0 comments

Comments

@CPU-beng
Copy link

CPU-beng commented Mar 6, 2024

In 'rov_simulation' Simulink, when I click the run button, it reports an error.
“Error evaluating 'InitFcn' callback for block_diagram 'ROV_Simulation'. Callback string is:

load('Simulation_busses.mat');
%Load simulator preferences
load("simparam.mat");

%Load Thruster settings
load("TAM.mat");
load("thrusterLimit.mat");

%Load External forces
load("External_forces.mat");

%Load Reference Case study
load("Reference_trajectory_case_study.mat");

if(not(isMATLABReleaseOlderThan("R2021b")))
set_param('ROV_Simulation/External Forces/Tether', 'commented', double(not(Sim_param.extTetUse)))
set_param('ROV_Simulation/External Forces/Manual disturbance', 'commented', double(not(Sim_param.extManUse)))
end

%Load sensors
load("Dependencies\Workspaces\Sensors.mat");
noise = NoiseSelection();

%Load Initial Conditions
load("InitCond.mat");
nu_Init = [nu_IC.u nu_IC.v nu_IC.w nu_IC.p nu_IC.q nu_IC.r];
eta_Init = [eta_IC.N eta_IC.E eta_IC.D eta_IC.phi eta_IC.theta eta_IC.psi];

% Load Physical parameters:
if(get_param('ROV_Simulation/Equation of Motion', 'use_app_parameters') == "on")
Env = LoadEnvironment(Sim_param.Env);
end

% Load robot chosen in "Equation of Motion" block:
if(get_param('ROV_Simulation/Equation of Motion', 'use_app_parameters') == "on")
Robot = LoadRobotParameters(Sim_param.Robot);
else
ROV_Constants;
Robot = ROV_Struct2Bus(ROV);
end

% Pos Rov
xi = eta_Init(1);
yi = eta_Init(2);
zi = eta_Init(3);

knots = 11;
len_tet = 35;
ln_tet = len_tet / (knots - 1);
z_tet_i = 0;
z1 = zi / 2 - ln_tet;

len_1 = len_tet / 2 - ln_tet;
x_tet = zeros(knots, 1);
z_tet = zeros(knots, 1);
if zi == len_tet
z_tet = linspace(0, zi, knots)';
else
x1 = sqrt(len_1^2 - z1^2);
a1 = (z1 - z_tet_i) / (x1 - 0);
x_inc = x1 / ((knots - 1) / 2 - 1);

for i=2:1:(knots - 1) / 2
    x_tet(i, 1) = x_inc * (i - 1);
end
z_tet(1:(knots - 1) / 2, 1) = a1 * x_tet(1:(knots - 1) / 2, 1);
z2 = zi / 2 + ln_tet;
x2 = sqrt(len_1^2 - z1^2);
a2 = (zi - z2) / (0 - x2);
x_tet((knots + 1) / 2:(knots - 1) / 2 + 2, 1) = x2;
z_tet((knots + 1) / 2) = z2 - ln_tet;
for i=(knots - 1) / 2 + 2:1:knots - 1
    x_tet(i + 1, 1) = x2 - x_inc * (i - ((knots + 1) / 2));
end
x_tet((knots - 1) / 2 + 1:(knots - 1) / 2 + 2, 1) = x2;
z_tet((knots + 1) / 2 + 1:end, 1) = a2 * x_tet((knots + 1) / 2 + 1:end, 1) + zi;

end
x_tet = x_tet + xi;
P10 = [xi yi zi]';
P9 = [x_tet(10) yi z_tet(10)]';
P8 = [x_tet(9) yi z_tet(9)]';
P7 = [x_tet(8) yi z_tet(8)]';
P6 = [x_tet(7) yi z_tet(7)]';
P5 = [(x_tet(6)) yi z_tet(6)]';
P4 = [x_tet(5) yi z_tet(5)]';
P3 = [x_tet(4) yi z_tet(4)]';
P2 = [x_tet(3) yi z_tet(3)]';
P1 = [x_tet(2) yi z_tet(2)]';
P0 = [xi yi 0]';
Reason: Cannot modify the contents of the Subsystem Reference block 'ROV_Simulation/External Forces' from within callbacks of the model 'ROV_Simulation'. To modify the contents, please use a self-modifying system encapsulation on the Subsystem Reference module.”

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant