Code Monkey home page Code Monkey logo

Comments (10)

traversaro avatar traversaro commented on August 15, 2024 1

Comparison of S-Functions and FMUs:

from blockfactory.

traversaro avatar traversaro commented on August 15, 2024 1
  • Code-based configuration vs file based configuration
    • In Simulink S-Functions and consequently in blockfactory, several configuration info such as the number of the ports, etc etc are specified by calling specific methods (in particular setIOPortsData in the configureSizeAndPorts method). In FMI, this information are specified in the XML file. To handle this, possible solutions are (the last one is my favorite):

      • Duplicate this info in handwritten XML files for FMUs (yuk)
      • Change how this info is specified (invasive)
      • Generate the XML files after the build by running a program that invokes the configureSizeAndPorts method of the block to wrap as FMU (this will be problematic when cross-compiling, but it seems that easy solution for now)
    • TL;DR: Handle how to generate XML files for FMU block

from blockfactory.

traversaro avatar traversaro commented on August 15, 2024 1

PR adding some part of the array support to the FMI standard: modelica/fmi-standard#543 .

from blockfactory.

traversaro avatar traversaro commented on August 15, 2024

Generate the XML files after the build by running a program that invokes the configureSizeAndPorts method of the block to wrap as FMU

Interestingly, part of this solution could be eventually re-used to automatize the existing manual process of writing the .slx file of the block library (i.e. the one described in https://robotology.github.io/blockfactory/mkdocs/create_new_library/#create-an-new-simulink-library).

As you can check by manually inspecting an .slx file, and by reading in https://stackoverflow.com/questions/23408186/information-about-simulink-mdl-and-slx-formats, the .slx is just a .zip file that contains a bunch of .xml (and some other format) files. A complete parser for reading/writing .slx does not seem to be available or feasible, but perhaps it could make sense to have a "template" .slx that can be be configured based on the library blocks' and ports.

from blockfactory.

diegoferigo avatar diegoferigo commented on August 15, 2024

Having a templated slx imho does not simplify that much the creation / maintenance of a Simulink Library, it is usually a trivial step from the GUI. I am pretty sure that Matlab (even the cli version) has some functions to automatize it without dealing with the file formats.

The main problem are the masks, the have to be developed from the GUI. I'm afraid that operating only on the slx or mdl would never be enough :/

from blockfactory.

traversaro avatar traversaro commented on August 15, 2024
OT reply moved to #10 (comment)

Having a templated slx imho does not simplify that much the creation / maintenance of a Simulink Library, it is usually a trivial step from the GUI.

It is trivial, if you have MATLAB/Simulink. It would be nice to be able to setup a blockfactory library without having MATLAB/Simulink on your PC (my current situation, for example : ) ).

The main problem are the masks, the have to be developed from the GUI. I'm afraid that operating only on the slx or mdl would never be enough :/

Why this should be the case? Everything that you input through the GUI should be contained in the .slx, right? As far as I can see, in particular the Mask information is contained in the <Mask> tag of simulink/blockdiagram.xml , for example for the SignalMath block in the ExampleToolbox:

      <Block BlockType="S-Function" Name="Signal Math" SID="1">
        <P Name="Ports">[2, 1]</P>
        <P Name="Position">[335, 69, 470, 116]</P>
        <P Name="ZOrder">1</P>
        <P Name="FunctionName">BlockFactory</P>
        <P Name="Parameters">&apos;SignalMath&apos;,&apos;ExampleToolbox&apos;,operation</P>
        <P Name="SFunctionDeploymentMode">off</P>
        <P Name="EnableBusSupport">off</P>
        <P Name="SFcnIsStateOwnerBlock">off</P>
        <Mask>
          <Display RunInitForIconRedraw="off">disp(&apos;Signal Math&apos;)

port_label(&apos;input&apos;,1,&apos;Input 1&apos;)
port_label(&apos;input&apos;,2,&apos;Input 2&apos;)

port_label(&apos;output&apos;,1,&apos;Output&apos;)</Display>
          <MaskParameter Name="operation" Type="popup" Evaluate="off">
            <Prompt>Operation</Prompt>
            <Value>Addition</Value>
            <TypeOptions>
              <Option>Addition</Option>
              <Option>Subtraction</Option>
              <Option>Multiplication</Option>
            </TypeOptions>
          </MaskParameter>
        </Mask>
      </Block>

Indeed automatically generating this may not be trivial, but I do not think it is impossible.

from blockfactory.

traversaro avatar traversaro commented on August 15, 2024

We can probably move this discussion in a separate issue, btw.

from blockfactory.

diegoferigo avatar diegoferigo commented on August 15, 2024

We can probably move this discussion in a separate issue, btw.

👍

OT reply

Indeed automatically generating this may not be trivial, but I do not think it is impossible.

Just to be clear, I never intended that this is impossible ^^ It is just complicating your own life. And, btw, if you don't plan to use Simulink (since you don't have it), why do you want to create a Simulink Library? If the aim is using / testing blockfactory, for simple models you could:

  • Create a plugin library containing classes that inherit from blockfactory::core::Block
  • Implement a simple blockfactory::core::BlockInformation for your use case
  • Develop a system that connects the blocks by assigning a simulation order and sharing data between their input / outputs with buffers

Without having Simulink I don't see any benefit of passing through the slx, but probably I didn't get entirely what you're trying to do.

from blockfactory.

traversaro avatar traversaro commented on August 15, 2024

Simulink related discussion moved to #10 .

from blockfactory.

traversaro avatar traversaro commented on August 15, 2024

Interesting paper on FMI interface with a real time communication protocol (in this case RabbitMQ): https://github.com/INTO-CPS-Association/rabbitmq-fmu-documentation/blob/e6e57da07394858bc1519ef7b746df8459123ed6/rabbitmq-fmu.pdf , similar to how BlockFactory is used with YARP.

from blockfactory.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.