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

Implement support for stateful systems #8

Open
8 tasks
traversaro opened this issue Dec 23, 2018 · 5 comments
Open
8 tasks

Implement support for stateful systems #8

traversaro opened this issue Dec 23, 2018 · 5 comments

Comments

@traversaro
Copy link
Member

traversaro commented Dec 23, 2018

This is probably a long term goal, but for now let's collect some possible basic steps:

  • Add support for reading continuous state in BlockInformation
  • Add support for reading and writing discrete state in BlockInformation
  • Implement support for reading continuous state in SimulinkBlockInformation (probably using ssGetContStates)
  • Implement support for reading discrete state in SimulinkBlockInformation (probably using ssGetDiscStates)
  • Implement support for reading continuous state in CoderBlockInformation
  • Implement support for reading and writing discrete state in CoderBlockInformation
  • Correctly implement mdlDerivatives in the BlockFactory S-Function:
    static void mdlDerivatives(SimStruct* /*S*/)
  • Permit to specify that a (input) port of the block is not direct feed-through (see ssSetInputPortDirectFeedThrough and https://drake.mit.edu/doxygen_cxx/classdrake_1_1systems_1_1_system.html the drake::systems::System<T>::xxxDirectFeedthrough methods for an inspiration related to the corresponding Drake API . At the moment this is hardcoded at Simulink level in
    ssSetInputPortDirectFeedThrough(simstruct, idx, 1);
    .
@traversaro traversaro changed the title Implement support for stateful system Implement support for stateful systems Dec 23, 2018
@traversaro
Copy link
Member Author

For the discrete state, it is also important to specify the sample time of the period update connected to the discrete state update. See https://it.mathworks.com/help/simulink/sfg/sample-times-cpp.html#f4-33929 for a description of this concept in the Simulink docs, and https://drake.mit.edu/doxygen_cxx/classdrake_1_1systems_1_1_leaf_system.html#a262f71637a37127840acefca3bda8897 for the related API in Drake's System API.

@traversaro
Copy link
Member Author

For the discrete state, it is also important to specify the sample time of the period update connected to the discrete state update.

Related to that, for properly describing this in FMUs it is necessary to wait for FMI 3. See modelica/fmi-standard#353 and http://www.ep.liu.se/ecp/132/057/ecp17132507.pdf .

@traversaro
Copy link
Member Author

Still related to stateful systems, it is relevant to mention that simStateCompliance should be properly set in Simulink:

ssSetSimStateCompliance(S, USE_CUSTOM_SIM_STATE); //??
.
At the moment, it is set to USE_CUSTOM_SIM_STATE. This means (see https://it.mathworks.com/help/simulink/sfg/s-function-compliance-with-the-simstate.html) that the S-Function "has mdlGetSimState and mdlSetSimState methods", that are not implemented in the existing BlockFactory S-Function.

@diegoferigo
Copy link
Member

That part of S-Function code is a very old heritage (from first versions of WBI-Toolbox I think). All of them would need a refreshing, not only this one.

@diegoferigo
Copy link
Member

cc @fjandrad

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

No branches or pull requests

2 participants