I’m currently trying to integrate a linear state-space model inside a ModelingToolkit model.
For this purpose I used the ODESystem specialization provided by ControlSystemsMTK, which itself uses the StateSpace block provided by MTK-SL.
However, once the ODESystem is formed, its “interfaces” are RealInputs / RealOutputs, which feel a bit abstract to me.
Are there any examples around showing how to combine such systems with e.g. Flange, MechanicalPort, Pin or else, to give them proper “physical” interfaces and make connections with other blocks easier ?
The StateSpace block has inputs and outputs in the “signal domain”, that is, a generic domain not tied to any physical domain. To use these signals in a physical doman, one uses interface components like sensors (physical → signal), and special input components (signal → physical), such as Voltage, Torque, Force etc. These input components take a signal input and outputs the corresponding physical quantity.
Here’s an example, where the interface components are SpeedSensor, Voltage, and Torque
1 Like
Thanks ! I figured theses sensor blocks would be of use, I’ll try ASAP !
Hi. I’m coming back at this (long delayed, due to more pressing matters) issue. Looking again at your answer, I’m wondering if it is the right approach given the following additional context :
I’m trying to combine a state-space model of a mechanical dynamical system with mechanical components of the standard library.
To achieve that
- I assembled the state space model using the capabilities of
ControlSystemsMTK, which provides me with an ODESystem. This system has its inputs (RealInput vector matching forces) and outputs (RealOutput vector matching displacements).
- As some of the forces are actually redundant relationships and should be imposed at 0, I added some equations to reflect that using basically
f_n ~ 0 for each redundant force.
- Assuming I have the same input and output nodes of my finite element model, I figured I should have
Flanges to which I would connect the other mechanical blocks. However, as you pointed, I should make the proper conversions since I only have “signals”.
That is where I am actually blocked.
I tried the following with no luck so far :
- manually create
Flanges and connect their s port to the outputs and f port to the inputs
- connect these
Flanges to the the external mechanical block flange, say a spring.
or
- add
ForceSensors and DisplacementSensors to this model
- connect their flanges together (since they are on the same node),
- connect the
ForceSensor output to the force input of the state-space model
- connect the
PositionSensor output to the position output of the state-space model
- connect their flanges together (since they are on the same node), along with the external mechanical block flange.
Do you have any suggestions about this ? I am short on ideas… Thanks.
An alternative approach could be to directly incorporate the linear equations in some custom component, bypassing the StateSpace component.
I was once working on something similar to what I think you are doing
https://github.com/JuliaComputing/Multibody.jl/compare/main...sb#diff-7b57a9d4675844bf244fd005347a0ccad38a154cb12ebbe7c8d9c2bc5846ac58
I haven’t yet pursued it to completion though so it’s not usable, but perhaps you can pick up some idea from there.