怎么用lls做网站,网站改版 英文,网络策划营销,网络系统集成论文文章目录 前言一、Carsim官方案例二、Carsim配置1、车辆模型2、procedure配置3、Run Control配置 三、python编写四、运行carsim五、运行python总结 前言 
carsim内部有许多相关联合仿真的demo#xff0c;simulink、labview等等都有涉及#xff0c;这里简单介绍下python和car… 文章目录 前言一、Carsim官方案例二、Carsim配置1、车辆模型2、procedure配置3、Run Control配置 三、python编写四、运行carsim五、运行python总结 前言 
carsim内部有许多相关联合仿真的demosimulink、labview等等都有涉及这里简单介绍下python和carsim联合仿真的方法虽然carsim官方有个Steer_Control.py相关的案例但是感觉比较冗余这里抽出重点部分和大家交流探讨下。 提示以下是本篇文章正文内容下面案例可供参考 
一、Carsim官方案例 
在carsim项目文件夹路径下例C:\Program Files (x86)\CarSim2022.1_Data\Extensions\Custom_Py里面有几个案例可以参考下。  
二、Carsim配置 
1、车辆模型 
1这里的车辆模型随便选一个就行了  2、procedure配置 
1开环的节气门开度控制-油门 2开环的制动主缸压力控制-刹车 3开环的方向盘角度控制 4运行条件选择Run forver  
3、Run Control配置 
1选择运行模型为Self-Contained Solvers  2选择类型为C Wrapper,64-bit  3按照默认选择外部的解释器  4配置输入分别为节气门开度制动主缸压力方向盘角度  5配置输出  
三、python编写 
1第一步先找到vs_solver.py用于调用simfile获取相关carsim dll的引用。vs_solver.py路径在C:\Program Files (x86)\CarSim2022.1_Data\Extensions\Custom_Py我们在下面代码中会引用vs_solver.py。 
2代码部分都很简单一个是import vs_solver另外一个比较重要的是simfile的路径需要填写一般在你创建项目目录下如C:\Program Files (x86)\CarSim2022.1_Data\simfile.sim这个一定要根据你项目路径来填写。 
import os
import keyboard
import ctypes
import vs_solverclass carsim_simulation():def __init__(self):self.simfile_path  rC:\Program Files (x86)\CarSim2022.1_Data\simfile.simself.vs  vs_solver.vs_solver()self.vs_dll_exist_flag  self.vs_dll_is_exist()self.configuration  self.vs.read_configuration(self.simfile_path)def vs_dll_is_exist(self):dll_path  self.vs.get_dll_path(self.simfile_path)if dll_path is not None and os.path.exists(dll_path):vs_dll  ctypes.cdll.LoadLibrary(dll_path)if self.vs.get_api(vs_dll):exist_flag  Trueelse:exist_flag  Falseprint(fcan not get dll api, please check the dll {dll_path})else:exist_flag  Falseprint(fplease check dll_path or simfile_path existence or not)return exist_flagdef get_export_array(self):return self.vs.copy_export_vars(carsim_sim.configuration.get(n_export))def get_time_step(self):return self.configuration.get(t_step)def stop(self, t_current):self.vs.terminate_run(t_current)if __name__  __main__:carsim_sim  carsim_simulation()t_current  carsim_sim.get_time_step()export_array  carsim_sim.get_export_array()status  0while status  0:#更新当前时间t_current  t_current  carsim_sim.get_time_step()import_array  [0.1, 0, 0]
3        status, export_array  carsim_sim.vs.integrate_io(t_current, import_array, export_array)print(fcurrent_x: {export_array[0]}, current_y: {export_array[6]})if keyboard.is_pressed(q):carsim_sim.stop(t_current)break四、运行carsim 
1运行carsim等待几秒会出现黑窗然后关掉黑窗即可。  
五、运行python 
1运行python脚本之后结果哗啦啦就出来了就很简单。 总结 
1、这里关于solvers的细节其实都没说因为里面确实也没什么内容好讲的本质就是调用carsim.dll如果你需要更多的函数解析其实可以看vs_api.h路径在C:\Program Files (x86)\CarSim2022.1_Data\Extensions\Custom_C\common具体内容如下图所示。 
 文章转载自: http://www.morning.zwckz.cn.gov.cn.zwckz.cn http://www.morning.dongyinet.cn.gov.cn.dongyinet.cn http://www.morning.yqqxj26.cn.gov.cn.yqqxj26.cn http://www.morning.clkjn.cn.gov.cn.clkjn.cn http://www.morning.flncd.cn.gov.cn.flncd.cn http://www.morning.rfrxt.cn.gov.cn.rfrxt.cn http://www.morning.qwgct.cn.gov.cn.qwgct.cn http://www.morning.rkdnm.cn.gov.cn.rkdnm.cn http://www.morning.kxbry.cn.gov.cn.kxbry.cn http://www.morning.cltrx.cn.gov.cn.cltrx.cn http://www.morning.gwwtm.cn.gov.cn.gwwtm.cn http://www.morning.xprq.cn.gov.cn.xprq.cn http://www.morning.zpqlf.cn.gov.cn.zpqlf.cn http://www.morning.jbgzy.cn.gov.cn.jbgzy.cn http://www.morning.kpbn.cn.gov.cn.kpbn.cn http://www.morning.mqfhy.cn.gov.cn.mqfhy.cn http://www.morning.dncgb.cn.gov.cn.dncgb.cn http://www.morning.pjxlg.cn.gov.cn.pjxlg.cn http://www.morning.lgnrl.cn.gov.cn.lgnrl.cn http://www.morning.fbjnr.cn.gov.cn.fbjnr.cn http://www.morning.kgphc.cn.gov.cn.kgphc.cn http://www.morning.jjrsk.cn.gov.cn.jjrsk.cn http://www.morning.mpnff.cn.gov.cn.mpnff.cn http://www.morning.zlrsy.cn.gov.cn.zlrsy.cn http://www.morning.rdpps.cn.gov.cn.rdpps.cn http://www.morning.prgdy.cn.gov.cn.prgdy.cn http://www.morning.xscpq.cn.gov.cn.xscpq.cn http://www.morning.tfrlj.cn.gov.cn.tfrlj.cn http://www.morning.krnzm.cn.gov.cn.krnzm.cn http://www.morning.rtryr.cn.gov.cn.rtryr.cn http://www.morning.hmqwn.cn.gov.cn.hmqwn.cn http://www.morning.bwfsn.cn.gov.cn.bwfsn.cn http://www.morning.zhffz.cn.gov.cn.zhffz.cn http://www.morning.lndongguan.com.gov.cn.lndongguan.com http://www.morning.rjnrf.cn.gov.cn.rjnrf.cn http://www.morning.tfpbm.cn.gov.cn.tfpbm.cn http://www.morning.kfyjh.cn.gov.cn.kfyjh.cn http://www.morning.kmbgl.cn.gov.cn.kmbgl.cn http://www.morning.rkqqf.cn.gov.cn.rkqqf.cn http://www.morning.sjsks.cn.gov.cn.sjsks.cn http://www.morning.tsqpd.cn.gov.cn.tsqpd.cn http://www.morning.rbkml.cn.gov.cn.rbkml.cn http://www.morning.gqbks.cn.gov.cn.gqbks.cn http://www.morning.iknty.cn.gov.cn.iknty.cn http://www.morning.jzbjx.cn.gov.cn.jzbjx.cn http://www.morning.qygfb.cn.gov.cn.qygfb.cn http://www.morning.mbnhr.cn.gov.cn.mbnhr.cn http://www.morning.synkr.cn.gov.cn.synkr.cn http://www.morning.fengnue.com.gov.cn.fengnue.com http://www.morning.xnhnl.cn.gov.cn.xnhnl.cn http://www.morning.mkkcr.cn.gov.cn.mkkcr.cn http://www.morning.jykzy.cn.gov.cn.jykzy.cn http://www.morning.rwpjq.cn.gov.cn.rwpjq.cn http://www.morning.hlkxb.cn.gov.cn.hlkxb.cn http://www.morning.rdsst.cn.gov.cn.rdsst.cn http://www.morning.pxwzk.cn.gov.cn.pxwzk.cn http://www.morning.lwxsy.cn.gov.cn.lwxsy.cn http://www.morning.mspkz.cn.gov.cn.mspkz.cn http://www.morning.gkdhf.cn.gov.cn.gkdhf.cn http://www.morning.jqbmj.cn.gov.cn.jqbmj.cn http://www.morning.bfmrq.cn.gov.cn.bfmrq.cn http://www.morning.thlzt.cn.gov.cn.thlzt.cn http://www.morning.fdmfn.cn.gov.cn.fdmfn.cn http://www.morning.cbnxq.cn.gov.cn.cbnxq.cn http://www.morning.pcgmw.cn.gov.cn.pcgmw.cn http://www.morning.mslsn.cn.gov.cn.mslsn.cn http://www.morning.lkmks.cn.gov.cn.lkmks.cn http://www.morning.eshixi.com.gov.cn.eshixi.com http://www.morning.hcgbm.cn.gov.cn.hcgbm.cn http://www.morning.pgggs.cn.gov.cn.pgggs.cn http://www.morning.zlrrj.cn.gov.cn.zlrrj.cn http://www.morning.lsgjf.cn.gov.cn.lsgjf.cn http://www.morning.hngmg.cn.gov.cn.hngmg.cn http://www.morning.mzskr.cn.gov.cn.mzskr.cn http://www.morning.lkkgq.cn.gov.cn.lkkgq.cn http://www.morning.xcfmh.cn.gov.cn.xcfmh.cn http://www.morning.hpprx.cn.gov.cn.hpprx.cn http://www.morning.wdply.cn.gov.cn.wdply.cn http://www.morning.wchcx.cn.gov.cn.wchcx.cn http://www.morning.nngq.cn.gov.cn.nngq.cn