0

Error while converting Simulink model into IQAN file

Friso Meeusen 5 months ago in IQAN toolbox for Simulink updated by Gustav Widén (System support) 4 months ago 14

For a project I am trying to convert a Simulink model, DOF3_RRR, which consits out of DOF3_Robot and DOF3_ForwardKinematics into an IQAN file. However, I keep on getting this error in the build sumarry: "Code generation file does not exist.". You can find the full output in the attachments:

commandwindow.asv
commandwindow.txt

I noticed three points in the output that could be the source:

Warning: File 'codedescriptor.dmr' not found.

Warning: File 'codedescriptor.dmr' not found.

Warning: File 'codedescriptor.dmr' not found.

Warning: File 'codedescriptor.dmr' not found.

Error: Simulink Coder Error: Simulink Coder Fatal: Failed to compute step size for TID=[0...1] in 'ModelReference' Block: '<Root>/Robot'

Model Action Rebuild Reason

==========================================================================

DOF3_RRR_IQAN2 Failed Code generation information file does not exist.

Please let me know if you have an idea to fix this.

Thank you in advance!

.

Check that you have selected fixed step discrete solver for the top model as well as any referred models (Model settings > Solver > Solver selection). Note that you need to make the same settings also in referred models. Also make sure that no individual blocks are using a variable sample time. Block that has a sample time parameter should be set to -1 to inherit the model's sample time.

Also try clearing out and cache folders to make sure you get a full recompile.

I already selected the fixed step discrete solver or all the models (see figure below)

I would not know which block could be using a variable sample time. In my model I am using the following blocks

-Input and output blocks

-Data type conversions

- PS- Simulink and Simulink-PS converters

- World Frame

-Mechanism configuration

- Solver Configuration

-Rigid transforms

-Revolute joints

-Mux and Demux

-Get transform and Coordinate transformation 

Any of these blocks that could be the source of the problem?

The solver you selected is fixed step, but not discrete. Try changing the solver to "discrete (no continuous states)":

Btw, I tried running it again when I removed both the cache and out folders and now I got this output:

commandwindow19-07-2022.txt

The warining Codedescriptor.dmr is now removed, but it shows up again after I run IQAN.export('IQAN") again.

I also noticed the following message on line 51,114 216 and 217 

### Model reference code generation target (ForwardKinematics.c) for model ForwardKinematics is out of date because ForwardKinematics.c does not exist.
### Starting build procedure for: ForwardKinematics


### Model reference code generation target (Robot.c) for model Robot is out of date because Robot.c does not exist.
### Starting build procedure for: Robot


 

It looks like the files IQAN.c, ForwardKinematics.c and Robot.c cannot be found altough I can find them in the directories C;\IQANsim\out\IntelWin32_IQAN\IQAN

C;\IQANsim\out\IntelWin32_IQAN\Robot

C;\IQANsim\out\IntelWin32_IQAN\ForwardKinematics

Please let me know if you have an idea to solve this,

Thank you in advance!

It still has the following error:

Error: Simulink Coder Error: Simulink Coder Fatal: Failed to compute step size for TID=[0...1] in 'ModelReference' Block: '/Model'

Which I think is the root cause for it not to compile. Changing the solver from "ode4" to "discrete" should fix this.

Thank you for the quick response! I changed the setting to "discrete (no continous state)" and again removed the cache and out foler. However, it gave the exact same output as before. I even got the same error:

Error: Simulink Coder Error: Simulink Coder Fatal: Failed to compute step size for TID=[0...1] in 'ModelReference' Block: '/Model'


 Do you have another idea of how to fix this?

Thank you in advance!

Assuming you also changed the solver to discrete also in the sub models I have no immediate idea on what the issue could be.

If you want you could send the model (or a sample model with the same issue) and I could take a look. In that case use the link below: 


IQAN share file

That would be great! I have sent you the files. Note that I have changed the names a bit. 

The file I want to convert into an IQAN file is called IQAN.slx and this model refers to both ForwardKinematics.slx and Robot.slx.


Also note that you first have to run the script in getRBT.m to obtain the RigidBodyTree (RBT) which is a needed parameter in ForwardKinematics.slx


Thank you for your help! 

The reference models in the top models must not be connected to each other. IQAN uses these models as separate building blocks which is why they have to be independent. The inports and outports of each reference models is connected to the IQAN application. 


The toolbox installs a documentation available in the MATLAB documentation which explains this "top model pattern". In the example below components A-C will be available for instantiation in IQANdesign.


During the model check the toolbox tries to determine if the "top model pattern" is violated, but it seems this check could be improved.

In your case you could move the two reference models to a new sub model and reference that from the top model. Then you would get only one reference model in the top model with the inports and outports accessible from IQANdesign. I could not verify if an export works after this since I don't have access to the robotics toolbox.

Thank you for the suggestion. I tried to put the Robot.slx and ForwardKinematics.slx into one file (RobotandFW.slx) and I refered to that in the top model (see the file IQANthree.slx). However, when I select the FixedStepDiscrete solver - Discrete (no continous states) I get the error message:

The "FixedStepDiscrete" solver cannot be used to simulate block diagram 'RobotandFK' because it contains continuous states

(see also commandwindowDiscreteNoConntinousStates.txt). 

I switched back again to the ode4 solver and then the error message went away. However, I ended up with some other errors along the way. I have solved them by changing some of the model settings:


-Support continuous time (Code Generation >Interface >  (check) Continous time)


-Enable Dynamic Memory Allocation (Simulation Target > Advanced Parameters > (check) Dynamic memory allocation in -MATLAB functions) 


-Unsupport Single output/update function (Interface > Advanced parameters > (uncheck) Single output/update function)

After I did all of these steps, and thus resolved the intermediate errors, I got the same error as before: 


Error: Simulink Coder Error: Simulink Coder Fatal: Failed to compute step size for TID=[0...1] in 'ModelReference' Block: '/RobotandFK'
Main program:
==> [00] C:\Program Files\MATLAB\R2021b\rtw\c\tlc\public_api\block_api.tlc:LibBlockSampleTime(346)
[01] C:\Users\Friso Meeusen\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\IQAN Toolbox for Simulink\MainFileGenerator\utilityFunctions.tlc:myLibWriteSubsystemStruct(215)
[02] C:\Users\Friso Meeusen\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\IQAN Toolbox for Simulink\MainFileGenerator\generateMain.tlc:FcnGenerateMain(91)
[03] C:\IQANsim\out\IntelWin32_IQAN\IQANthree\tlc\iqan_file_process.tlc:(15)
[04] C:\Program Files\MATLAB\R2021b\rtw\c\tlc\mw\formatwide.tlc:(566)


(see also ode4.txt)


I have sent you the IQANthree.slx and RobotandFW.slx file. Hopefully you can find what goes wrong here.


Again, thank you so much for your efforts! 


 

If you cannot use the discrete solver it is not possible to use the model in IQAN. Models that contains continuous states does not support discrete solvers. See Solver - MATLAB & Simulink - MathWorks Nordic.


Unfortunately I don't have any experience with the robotics toolbox so I can't say if it is possible for it to support a discrete solver. I suggest you check with the MATLAB support if this is possible.

I see. I will try to contact MATLAB Technical Support. 


Still hank you for all your inputs!

Hello again,



I have contacted MATLAB support but no reply yet. 


However, I have been trying to find the root of the problem (located in the Robot.slx file according to the error) and I think I have found out that "Physical Systems" modeled in Simulink cannot be converted into IQAN. Allow me to demonstrate:

I put each subsystem of Robot.slx in a separate filec( such as Link.slx, EE.slx, Base.slx and RevoluteJoint.slx). and then I made another file where I referred to these new files (such as LinkRefer.slx, BaseRefer.slx, EERefer.slx and RevoluteJointRefer.slx). After this, I tried to convert each of these files into an IQAN file. All of them gave the same error:

 Each physical network must be connected to exactly one Solver Configuration block. There is no Solver Configuration block connected to Physical Network with the following blocks: 

(this was for a model that consisted out of a Revolute Joint with a rigid transform). So the error suggests that you need to connect the "Physical Network" with one Solver Configuration block. However, when I add  this block I get the same error as before:
  

The "FixedStepDiscrete" solver cannot be used to simulate block diagram 'RevoluteJoint' because it contains continuous states

I tried to check if it is perhaps the SolverConfiguration or RigidTransformation block itself that is causing this error by making another two files that only contains a SolverConfiguration block and a RigidTransformation block (see SolverConfigurationRefer.slx, SolverConfiguration.slx, RigidTransformRefer.slx, and RigidTransform.slx). However, these files seem to be converting without an error to an .ism file.


So I guess it goes wrong whenever you try to convert a model that has a connection between two blocks such as a rigid transform, links, revolute joints, PS-simulink convertes and Solver Configurations (because this is appereantly a "Physical network").


Lastly, I removed all of these kind of blocks from my robot model and this new model could be converted into a .ism file aswell (see Robotref.slx).   
 

Do you perhaps know if my assumptions are correct? Are there alternative blocks I can use so I can still model my robot? 

I have sent you my files again using the same IQAN share link.

Please let me know you inputs

Thank you in advance ! 

:)

When it comes to the use of MATLAB and available blocks I'm afraid I can't help much. What I do know is that the key to get the integration to work is to stay away from blocks requiring continuous states since we require the fixed step discrete solver.