FlightGear飞行模拟器

标题: MatLab和FlightGear环境的配置及样例 [打印本页]

作者: ldy    时间: 2015-1-31 16:10
标题: MatLab和FlightGear环境的配置及样例
matlab 与 flightgear 联合仿真
主要参考网址:
步骤:
1、        设置工作路径:
最好是自己设定的路径,而不是软件默认的..bin..的路径。

2、        将matlab安装目录下:toolbox/aeroblks/aerodemos的aerodemos文件夹拷贝至FlightGear的data/Aircraft目录下。
3、        将aerodemos\HL20中的HL20-set.xml文件添加一下语句:
<flight-model>network</flight-model>
4、        确保安装了vs2010或者vc 6,这里测试的是vs2010.
5、        配置vs 2010的编译器:
在控制台输入:mbuild –setup
会提示:
Please choose your compiler for building standalone MATLAB applications:  
Would you like mbuild to locate installed compilers [y]/n? n
输入:n

提示:
[1] Microsoft Visual C++ 2005 SP1
[2] Microsoft Visual C++ 2008 Express
[3] Microsoft Visual C++ 2008 SP1
[4] Microsoft Visual C++ 2010
[5] Microsoft Visual C++ 2010 Express
[0] None

Compiler:       
输入:4

提示:
Your machine has a Microsoft Visual C++ 2010 compiler located at
d:\Program Files (x86)\Microsoft Visual Studio 10.0. Do you want to use this compiler [y]/n?

Please verify your choices:

Compiler: Microsoft Visual C++ 2010  
Location: d:\Program Files (x86)\Microsoft Visual Studio 10.0

Are these correct [y]/n?

输入:y

提示:

****************************************************************************
  Warning: Applications/components generated using Microsoft Visual C++      
           2010 require that the Microsoft Visual Studio 2010 run-time      
           libraries be available on the computer used for deployment.      
           To redistribute your applications/components, be sure that the   
           deployment machine has these run-time libraries.                  
****************************************************************************

Trying to update options file: C:\Users\YQY\AppData\Roaming\MathWorks\MATLAB\R2010b\compopts.bat
From template:              D:\PROGRA~1\Matlab\bin\win64\mbuildopts\msvc100compp.bat

Done . . .

则配置成功

6、        编译:点击 ,第一次会等待大概一分钟左右
7、        然后双击: ,会出现:

FlightGear base directory 中将安装flightgear的路径填上,
之后会生成runfg.bat文件,内容如下:
D:
cd D:\Program Files\FlightGear
SET FG_ROOT=D:\Program Files\FlightGear\\data
.\\bin\\EDIT_THIS_NAME\\fgfs --aircraft=HL20 --fdm=network,localhost,5501,5502,5503 --fog-fastest --disable-clouds --start-date-lat=2004:06:01:09:00:00 --disable-sound --in-air --enable-freeze --airport=KSFO --runway=10L --altitude=7224 --heading=113 --offset-distance=4.72 --offset-azimuth=0
这里需要将第三行的.\\bin\\EDIT_THIS_NAME\\去掉,然后将D:\Program Files\FlightGear\bin;加入系统环境变量中。(即将flightgear安装目录下的bin的路径加至环境目录,修改的地方原来的意思是进入这个安装flightgear的文件夹下的bin中调用fgfs.exe文件,这里修改的原因是安装flightgear之后发现data文件夹下没有bin文件)
修改之后的文件内容为:D:
cd D:\Program Files\FlightGear

SET FG_ROOT=D:\Program Files\FlightGear\\data
fgfs --fg-aircraft="D:/Program Files/FlightGear/data/Aircraft/aerodemos" --aircraft=HL20 --fdm=network,localhost,5501,5502,5503 --fog-fastest --disable-clouds --start-date-lat=2004:06:01:09:00:00 --disable-sound --in-air --enable-freeze --airport=KSFO --runway=10L --altitude=7224 --heading=113 --offset-distance=4.72 --offset-azimuth=0
其中"D:/Program Files/FlightGear/data/Aircraft/aerodemos"是存放模型的位置。

5、在matlab控制台输入dos('runfg.bat&'),然后会出现对应的界面。

6、一些参数的说明:
--fg-aircraft:模型的位置(没有它会提示找不到模型)
--aircraft:飞机名字
--airport:机场
FG_ROOT:资源路径
FG_SCENRY:场景(地形)路径


注意几点:
1、        出现这样的错误:

主要是因为没有添加--fg-aircraft="D:/Program Files/FlightGear/data/Aircraft/aerodemos",即没有将模型的路径添加上。
2、       


则多半是因为没有更改matlab的工作空间。
3、电脑不是独立显卡的可能不能跑flightgear
作者: tanxiaojun    时间: 2015-7-8 13:36
正在学习matlab与fightgear联合仿真。挺好啊。
作者: 18298347945    时间: 2015-7-8 13:54
楼主写的很详细啊,幸苦了
作者: lvguohu    时间: 2015-7-27 14:11
顶弹道弹道弹道弹道弹道弹道弹道弹道弹道弹道弹道弹道弹道弹道弹道弹道导弹
作者: shark1986    时间: 2019-1-8 15:51
参考学习!!!!!!!!!!!!11
作者: shark1986    时间: 2019-1-9 14:10
顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶
作者: 思想的小鱼    时间: 2019-3-13 11:07
先看看后面可能就需要了
作者: 帆小生丶    时间: 2019-6-15 09:53
辛苦楼主,可惜图片看不到




欢迎光临 FlightGear飞行模拟器 (https://www.flightgear.org.cn/) Powered by Discuz! X3.2