Algebraic state in algebraic loop containing ... computed at time 0.0 is Inf or NaN.

Hello,
I am making a collision avoidance application such that an ego vehicle must avoid collision with another vehicle using responsibilty sensative safety by mobileye, controlling the ego vehicle with an mpc to get to point A to point B, and changing the optimal control with a Barrier Certificate Enforcement to avoid other vehicles.
I've attached a compressed file of the matlab codes and simulink model. I believe its necessary that I attach it all because this error is coming from a matrix multiplier. Please run "initialize_constants" matlab script before running simulink model.
The error I recieve is...
An error occurred while running the simulation and the simulation was terminated
Caused by:
In my barrier function I divide by a parameter called LODSDSD(Longitudinal opposite direction/same direction safe distance). This value is calculated by using the longitudinal velocity data of the non-ego vehicle from the scenario reader.
When I log the signal of the non-ego vehicle's longitudinal velocity it comes out as 0 which would cause that barrier function to be a non-real number which is why I believe im getting this error from. I've verified that the scenario is inputted properly by making a feedfoward system with the same scenario to just log the data. and the initial condition of the non-ego vehicle is correct but when I turn it back to a feedback loop the intial longitudinal velocity of the non-ego vehicle is 0.
I've tried to change to a stiffer solver (ode15s(stiff/NDF)) and tighten my error tolerance.
I believe my model is correct as im use a model from Rajesh Rajamani - Vehicle Dynamics and Control Second Edition book.
Thank you in advance for anyone that can assist me with this error,
Marshall Botta

4 Comments

I get some errors trying to run the attached model. It looks like you defined some variables in the MATLAB workspace that don't get populated automatically by the model. Could you provide some values to use for those variables?
Error evaluating 'InitFcn' callback of NonlinearMPC block (mask) 'feedbackmpcCBFv3/MPC controller/Nonlinear MPC Controller'. Callback string is 'nmpcblock_InitFcn;'
Caused by:
  • Cannot resolve: nlobj.
Error:Error due to multiple causes.
Caused by:
Error evaluating parameter 'EgoVehicleActorID' in 'feedbackmpcCBFv3/Simulation/Scenario Reader'
Unrecognized function or variable 'egoID'.
Variable 'egoID' does not exist.
Suggested Actions:
Load a file into base workspace.
Create a new variable.
Error evaluating parameter 'SampleTime' in 'feedbackmpcCBFv3/Simulation/Scenario Reader'
Unrecognized function or variable 'Ts'.
Variable 'Ts' does not exist.
Suggested Actions:
Load a file into base workspace.
Create a new variable.
Error:Error due to multiple causes.
Caused by:
Error evaluating parameter 'a' in 'feedbackmpcCBFv3/Vehicle dynamics/Vehicle Body 3DOF Single Track'
Unrecognized function or variable 'lf'.
Variable 'lf' does not exist.
Suggested Actions:
Load a file into base workspace.
Create a new variable.
Error evaluating parameter 'b' in 'feedbackmpcCBFv3/Vehicle dynamics/Vehicle Body 3DOF Single Track'
Unrecognized function or variable 'lr'.
Variable 'lr' does not exist.
Suggested Actions:
Load a file into base workspace.
Create a new variable.
Error evaluating parameter 'Cy_f' in 'feedbackmpcCBFv3/Vehicle dynamics/Vehicle Body 3DOF Single Track'
Unrecognized function or variable 'Cf'.
Variable 'Cf' does not exist.
Suggested Actions:
Load a file into base workspace.
Create a new variable.
Error evaluating parameter 'Cy_r' in 'feedbackmpcCBFv3/Vehicle dynamics/Vehicle Body 3DOF Single Track'
Unrecognized function or variable 'Cr'.
Variable 'Cr' does not exist.
Suggested Actions:
Load a file into base workspace.
Create a new variable.
Error evaluating parameter 'Izz' in 'feedbackmpcCBFv3/Vehicle dynamics/Vehicle Body 3DOF Single Track'
Unrecognized function or variable 'Iz'.
Variable 'Iz' does not exist.
Suggested Actions:
Load a file into base workspace.
Create a new variable.
Hi Daniel,
I apologize, I should have mentioned in the compressed folder there is a matlab script called "initialize_constants". You have to run this script before you can run the simulink model or else you will get these errors you recieved.
Hi Marshall,
In retrospect that file probably should have been more obvious to me. :)
Anyway, I get another error now. It looks like I'm missing "deaccelerationtestscript".
Sorry, its hard to keep track of these files sometimes.
Here is the new zip file with an edited "initialize_constants" script that reads "deaccelerationtest" scenario instead of "deaccelerationtestscript".

Sign in to comment.

 Accepted Answer

I'm having some difficulty seeing exactly where the error is coming from---simulations that fail at the first time step can be a bit tricky to figure out---but here are some general recommendations:
  1. To break an algebraic loop artificially, you might consider introducing an artificial delay, with a sample time smaller than the dynamics of the system are changing. I attached Unit Delay blocks to the inputs to Vehicle dynamics at the top level, with a sample time of 0.01, and the simulation at least runs... though I don't know anything about your system, so I can't say if it's running correctly or not. :)
  2. Sometimes you can handle 0 values specially in this sort of situation. For instance, you could check if LODSDSD is 0, and then perform some different calculation that produces a finite result in that case.

1 Comment

Hi Daniel,
Sorry for the late reply, thank you very much for these recommendations. Your first recommendation worked and now the model runs with no errors. This has helped me out a ton.
Sincerly,
Marshall Botta

Sign in to comment.

More Answers (0)

Products

Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!