Afsim沿高程运动
目录
前言
一、数据格式转换
二、Afsim加载
1.拷贝数据
2.编写脚本
3.运行效果
前言
将tif数据转为dted格式数据,通过terrain加载到afsim中,使得平台沿着高程运动。
一、数据格式转换
使用Arcgis Pro在工具箱搜索栅格转数字地形高程(DTED),如图:
设置好参数,等待运行结束,如图:
成果,如图:
二、Afsim加载
1.拷贝数据
2.编写脚本
代码如下(示例):
# File generated by Wizard 2.9.0 on Sep 14, 2025.route Route-1label Waypoint-0position 23:27:59.080n 121:08:24.867e altitude 0.00 ftspeed 50 m/slinear_acceleration 10 gradial_acceleration 10 glabel Waypoint-1position 23:25:13.442n 120:57:46.577e altitude 0.00 ftlabel Waypoint-2position 23:26:56.039n 120:51:34.674e altitude 0.00 ftlabel Waypoint-3position 23:31:01.476n 120:46:42.788e altitude 0.00 ftlabel Waypoint-4position 23:44:48.837n 120:36:49.525e altitude 0.00 ftlabel Waypoint-5position 23:55:02.124n 120:33:57.843e altitude 0.00 ftlabel Waypoint-6position 23:56:00.586n 120:25:57.363e altitude 0.00 ft
end_routeprocessor TERRAIN_FOLLOWING WSF_SCRIPT_PROCESSORscript_variablesdouble COMMANDED_HEIGHT_ABOVE_TERRAIN = 10; # This is the default - must be changed# by either the platform_type or platformdouble HEIGHT_TOLERANCE = 0; # +/- tolerance for hysteresisend_script_variablesupdate_interval 0.1 secon_updateWsfGeoPoint FutureLocation = PLATFORM.Location();double CurrentAltAGL = PLATFORM.HeightAboveTerrain();double CurrentSpeed = PLATFORM.Speed();double CurrentAltMSL = PLATFORM.Altitude();double MaxRate = 100;double Rate = 50;FutureLocation.Extrapolate(0, CurrentSpeed*2); #heading, speed*script_update_ratedouble FutureAltAGL = FutureLocation.HeightAboveTerrain();// Valley coming...if (FutureAltAGL > (COMMANDED_HEIGHT_ABOVE_TERRAIN + HEIGHT_TOLERANCE)){#double NewAlt = CurrentAltMSL - COMMANDED_HEIGHT_ABOVE_TERRAIN;double NewAlt = CurrentAltMSL - FutureAltAGL;if (CurrentAltMSL - NewAlt > 100) Rate = MaxRate;PLATFORM.GoToAltitude(NewAlt, Rate, 1); # Alt, Rate, stay on routewriteln(TIME_NOW, " Commanding to go down to the new alt of ", NewAlt);}// Hill coming up..if (FutureAltAGL < (COMMANDED_HEIGHT_ABOVE_TERRAIN - HEIGHT_TOLERANCE)){#double NewAlt = CurrentAltMSL + COMMANDED_HEIGHT_ABOVE_TERRAIN;double NewAlt = CurrentAltMSL + FutureAltAGL ;if (NewAlt - CurrentAltMSL > 100) Rate = MaxRate;PLATFORM.GoToAltitude(NewAlt, Rate, 1); # Alt, Rate, stay on routewriteln(TIME_NOW, " Commanding to go up to the new alt of ", NewAlt);}end_on_update
end_processorplatform_type A WSF_PLATFORM mover WSF_GROUND_MOVER body_g_limit 4 gmaximum_climb_rate 200 ft/send_moverprocessor TERRAIN_DOLLOWING TERRAIN_FOLLOWINGend_processorend_platform_typeplatform B Aicon 2s6side redposition 23:27:59.080n 121:08:24.867e altitude 3000 mon_initialize2 FollowRoute(WsfRoute.CopyGlobal("Route-1"));end_on_initialize2end_platformterrainraw_dted 2 dted 21 119 26 125
end_terrainon_initializeWsfTerrain terrain = WsfTerrain();if (terrain.TerrainElevApprox(22.4, 121.38) == 0){writeln("***** WARNING: You must provide your own terrain data in 'terrain_demo.txt', line 71, near column 1");}
end_on_initializeend_time 1 h