定时更新
定时检测两个平台的距离,若距离小于某个值时触发函数
# File generated by Wizard 2.9.0 on Nov 21, 2024.
platform_type TANK WSF_PLATFORM
icon tank
mover WSF_GROUND_MOVER
end_mover
end_platform_type
platform tank_red TANK
position 24:42:36.68n 121:01:27.23e
side red
route
position 24:42:36.680n 121:01:27.230e altitude 0.00 ft agl
speed 22.352 m/s
label Waypoint-1
position 24:42:27.710n 121:00:48.453e
altitude 0.00 ft agl
label Waypoint-2
position 24:42:15.430n 120:59:47.653e
altitude 0.00 ft agl
label Waypoint-3
position 24:42:04.213n 120:58:36.929e
altitude 0.00 ft agl
label Waypoint-4
position 24:41:51.923n 120:57:44.916e
altitude 0.00 ft agl
label Waypoint-5
position 24:41:12.493n 120:57:22.169e
altitude 0.00 ft agl
label Waypoint-6
position 24:40:53.822n 120:57:52.570e
altitude 0.00 ft agl
label Waypoint-7
position 24:41:10.909n 120:58:41.639e
altitude 0.00 ft agl
end_route
end_platform
platform tank_blue TANK
position 24:41:26.923n 120:57:42.288e
side blue
update_interval 0.5 s
on_initialize
end_on_initialize
script_variables
bool flag = true;
end_script_variables
on_update
WsfPlatform tank_red = WsfSimulation.FindPlatform("tank_red");
WsfPlatform tank_blue = WsfSimulation.FindPlatform("tank_blue");
double lat_red = tank_red.Latitude();
double lon_red = tank_red.Longitude();
double lat_blue = tank_blue.Latitude();
double lon_blue = tank_blue.Longitude();
WsfGeoPoint loc = tank_blue.Location();
double distance = Math.Sqrt((lat_red - lat_blue)*(lat_red - lat_blue) + (lon_red - lon_blue)*(lon_red - lon_blue));
if (distance < 0.003 && flag) {
writeln("In area, distance is: ", distance);
flag = false;
}
end_on_update
end_platform
event_output
file jacksonabad.evt
end_event_output
event_pipe
file jacksonabad.aer
end_event_pipe
end_time 1 hr