我需要在我的应用程序中运行来自xcos (Scilab)的控制模型。
因此,控制算法工程师可以开发自己的控制模型,并在xcos的可视化环境中进行测试。所开发的模型可以直接合并到应用程序中。
如何在我的python应用程序中加载和运行xcos模型?文档非常差。
发布于 2014-07-02 20:01:54
运行scicos模型
我没有太多使用XCOS的经验。但您可以尝试scicos_simulate documentation中提到的方法。
importXcosDiagram("SCI/modules/xcos/demos/batch_simulation.zcos")
typeof(scs_m) //The diagram data structure
//This diagram uses 3 context variables :
// Amplitude : the sin function amplitude
// Pulsation : the sin function pulsation
// Tf : the final simulation time
scs_m.props.context; //the embedded definition
//first batch simulation with the parameters embedded in the diagram
scicos_simulate(scs_m);
// Change the final time value
Context.Tf=10;
scicos_simulate(scs_m,Context);
// without display
Context.Tf=10;
Context.Pulsation=9;
scicos_simulate(scs_m,list(),Context,'nw');
//get the variable created by the "from workspace block"
counter使用脚本启动scilab
您可以创建一个Scilab脚本来运行模型,并使用该脚本执行call Scilab。另请参阅calling-an-external-command-in-python
from subprocess import call
call(["scilab", "-f run_my_xcos.sci"]) 来自Python的调用
还有一个a kind of python api for scilab calls,所以你可以使用它。
https://stackoverflow.com/questions/24506618
复制相似问题