Kangmou shares | Autonomous driving joint simulation - Functional Model Interface FMI (Part 2)

Publisher:心有归属Latest update time:2024-07-03 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The continuity and discreteness of the concept of time in FMU are actually attributes of variables. And FMU can contain variables of continuous time or discrete time. This can be seen in the FMU communication of model exchange type and joint simulation type.

In FMI2.0, the communication structure for data exchange through communication points is discrete.


1. Model exchange: import tool provides solver

wKgaomZ7ty-AdCzsAAB45AN-C80271.png


  • The model integration between simulation tools is very tight.

  • The interface between the import tool and the model is very complex.

  • The import tool must provide a suitable solver.


2. Joint simulation: export tool provides solver

wKgZomZ7t0-AB1zAAAB184voApc737.png


  • There is a tight coupling between the model and the solver.

  • The interface between the import tool and the model is relatively simple.

  • Different joint simulation algorithms and communication steps can be selected to achieve a more stable and accurate simulation solution.


3. Interface of Joint Simulation

The communication time step can be different from the internal step. The communication time step is mainly used to exchange information between different FMUs, while different variable time steps can be used within each FMU.

In the co-simulation interface, the parameters have a typical calling order according to the FMI standard:

  • Get the output: fmiGetXXX(...)

  • Trigger calculation until the next communication node: fmidoStep(...)

  • Set input value: fmi2SetXXX(...)

Take C code as an example:

  • Instantiate the FMU using the FMI2Instantiate function

CALL (FMI2Instantiate(S, resourceURI, fmi2CoSimulation, modelDescription->instantiationToken, fmi2Flase, fmi2Flase))

The parameters involved are the FMI instance, the URI of the FMU resource, the declaration of the FMU type as co-simulation, the unique identifier, whether to display the FMU GUI, and whether to start logging.


  • Apply initial values ​​and output

CALL(applyStartValues(S,settings)); CALL(FMIApplyInput(S,input,settings->startTime,true,true,false));


  • Set parameters and enter initialization mode. If there is an FMU initial state file, you can execute it after instantiating the FMU.

CALL(FMI2SetupExperiment(S,settings->tolerance>0,settings->tolerance,settings->startTime,fmiFalse,0)); CALL(FMI2EnterInitializationMode(S)); CALL(FMI2ExitInitializationMode(S));


  • Enter the simulation loop, sampling and applying input according to the time step

or(ubsignedlongstep=0;;step++){constfmi2Realtime=settings->startTime+step*settings->outputInterval;... CALL(FMISample(S,time,result)); CALL(FMIApplyInput(S,input,time,true ,true,false)); ...... constFMIStatusdoStepStatus=FMI2DoStep(S,time,settings->outputInterval,fmiTrue); ...... CALL(FMIGetBooleanStatues(S,fmi2Terminated,&terminated)) .... .. CALL(FMI2GetRealStatus(S,fmi2LastSuccessfulTime,&lastSuccessfulTime)); CALL(FMISample(S,lastSuccessfulTime,result)); ......


Role of Joint Simulation Algorithm

  • The co-simulation algorithm is not part of the FMI standard and is mainly used for:

  • Advance the time of the entire simulation system so that the FMU components of each subsystem perform simulation calculations synchronously at each time step, that is, the simulation loop part of the code.

  • Exchange input and output data.

  • Trigger clock signal, used to synchronize different simulation components or trigger certain actions, i.e. in the code.

settings->startTime+step*settings->outputInterval;FMI2DoStep(S,time,settings->outputInterval,fmiTrue);

  • Handle events, such as state changes, external input, internal condition triggering, etc., that is, in code.

CALL(FMI2GetRealStatus(S,fmi2LastSuccessfulTime,&lastSuccessfulTime));CALL(FMISample(S,lastSuccessfulTime,result));


4. Model description files are parallel

The model description file modelDescription.xml contains all the static information about the FMU. It defines the interface types supported by the FMU, whether it is model exchange or co-simulation, and explains the model variables, including inputs, outputs and related parameters, so that the import tool can access them.


In addition, it will also contain some information about the model interface, such as whether the data conforms to the input and output when the model is connected.

wKgZomZ7tsGAQw-KAArz-1zXPIo374.png


In addition, some attribute flags are declared in the model description file, such as "needsExcutionTool". This attribute indicates that a specific program or a specific library file is required to execute the FMU. Therefore, when importing the FMU, an additional wrapper is required in the import tool. It does not actually participate in the calculation, but is used to realize communication between the model, the solving tool and the execution.


wKgaomZ7ts6Aar64AACWt1kuPeM628.png wKgaomZ7tteAR3YwAAC4FuR50iQ741.png


Reference address:Kangmou shares | Autonomous driving joint simulation - Functional Model Interface FMI (Part 2)

Previous article:Differences between the working principles of gasoline engines and diesel engines
Next article:Kangmou shares | In-depth discussion of ADTF technology in CAN

Latest Embedded Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号