Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 其它 > 资料存档 > MATLAB技术文章
MATLAB技术文章 MATLAB Technical Articles From Mathworks
回复
 
主题工具 显示模式
旧 2008-01-06, 16:32   #1
TechnicalArticles
游客
 
帖子: n/a
默认 Building a Distributed Aircraft Tracking Simulation Using TCP/IP

Building a Distributed Aircraft Tracking Simulation Using TCP/IP


by Edward J. Mayhew, Jr., George Mason University
Pilots face many challenges while navigating their aircraft in potentially adverse situations. They rely on a large array of visual, sensor, and computed data to maintain crew, passenger, and mission safety.
Under the sponsorship of a major aerospace company, the Electrical and Computer Engineering Department at George Mason University (GMU) is currently using MATLAB to develop a platform sensor management system (PSM) that enhances the quality and availability of aircraft tactical information. The system utilizes newly developed methods for controlling the use of sensors to collect specific, directed information about the aircraft's environment based on a unique goal structure. Pilots can use the PSM to answer several vital questions:
  • Is there anyone else out there?
  • If so, who is it?
  • Is my aircraft at risk?
  • Where should I look next?
  • Which is the best sensor to use?
The PSM incorporates multiple tracking and detection tasks programmed in MATLAB, including Guidance/Navigation/Control, data fusion, information calculation, threat detection and assessment, Kalman filter state estimation, GMU platform sensor manager, and several other critical parts of the multisensor heterogeneous simulation. A stand-alone, MATLAB based GUI known as the pilot visualization interface (PVI) uses the PSM task calculations as input. This article describes how the GMU team used MATLAB to develop the PVI application and some of the PSM project challenges that were overcome, including incorporating and communicating with a C application executing on a remote machine.
The PVI enables a user to visualize the results of the mathematical calculations of the PSM system by displaying actual geographic locations on Earth from the pilot's (or any other) viewpoint using real and simulated sensor data. A pilot can also view and display detected events. From an "ownship" (center of the universe) position, the pilot can adjust any camera (representing a sensor) to any viewpoint to visualize the displayed area at any angle. In addition, the PVI can perform aircraft six-degree-of-freedom (DoF) flight dynamics and instrumentation.
The GMU team used the PVI to test and verify possible solutions to several PSM project challenges, including:Interfacing with Remote Software

A primary goal for this project was to demonstrate to our sponsor that a software application written in C could be integrated with a new software system, even when those components are on separate machines. Specifically, we demonstrated that C code used to compute the bearing and distance from the tracking platform to the target can be remotely linked to the PSM. We needed C code to call a portion of our simulation based upon specific criteria. As the algorithms in the sponsor's C code were proprietary, “MEXing” the MATLAB code with the C code would have created testing, development, and security difficulties that we wanted to avoid. Editing the sponsor's C code every time we made changes to the MATLAB application would also have created configuration management problems. The sponsor's C code worked and was best left unedited.
A possible option was to program the PVI in C, but that would have been significantly more difficult and time-consuming than using MATLAB, especially as we added more advanced functionality to the interface. MATLAB provides mathematical libraries and tools for analyzing results and building applications that offer significant time savings over lower-level languages. We simply didn't have the resources or the luxury of time to develop this research application in C.
We had to determine if the MATLAB application could:
  • Call a C program running on a different computer, located in a different part of the country, and immediately provide its output to our application
  • Provide bidirectional communication, that is, the remote C program had to read data from the MATLAB application, process it, and return it to be displayed in the MATLAB based PVI
  • Run multiple PVIs simultaneously off of one C program
So the question was, “How does one, from within a MATLAB application, call a C program that is not directly accessible or available?” As it turned out, the solution in MATLAB was relatively simple, inexpensive, and provided impressive results.
Setting up the TCP/IP Connection

Using the Instrument Control Toolbox, we established a TCP/IP connection between our MATLAB application and the remote application written in C. The Instrument Control Toolbox provides networking functionality that lets you develop a client application in MATLAB to communicate with one or more server applications built in programming languages other than MATLAB. This toolbox enabled us to develop our new software in MATLAB while utilizing the C-based application.
The MATLAB code for TCP/IP communication is straightforward. This generic example shows how a MATLAB client can send data to and receive data from a remote application not developed in MATLAB:
% Create TCP/IP object 't'. Specify server machine and port number.
t = tcpip('www.mathworks.com', 80);

% Set size of receiving buffer, if needed.
set(t, 'InputBufferSize', 30000);

% Open connection to the server.
fopen(t);

% Transmit data to the server (or a request for data from the server).
fprintf(t, 'GET /');

% Pause for the communication delay, if needed.
pause(1)

% Receive lines of data from server
while (get(t, 'BytesAvailable') > 0)
t.BytesAvailable
DataReceived = fscanf(t)
end

% Disconnect and clean up the server connection.
fclose(t);
delete(t);
clear t
This example shows how relatively simple it is to set up MATLAB to act as a client and communicate with other applications on a local or remote computer. While HTTP was used as the higher-level protocol in this example, you can use other protocols, as was the case in our project. (See the Instrument Control Toolbox user documentation for more information on setting up a TCP/IP connection.)
With the help of TCP/IP SOCKETS IN C: A Practical Guide for Programmers (Donahoo and Calvert) we created a C message server program for TCP/IP communication on a Windows machine. This message server application comprised a mere 100 lines of executable C code. (We later developed a Linux version.)
Once the client-server bidirectional communication was successfully established on the same computer, we established a TCP/IP connection between different computers. Figure 1 shows the functionality provided by each application as well as the information exchanged between the applications.
Figure 1. The high-level functionality of the MATLAB based PVI and the remote C application as well as the TCP/IP information exchange. Click on image to see enlarged view.
With the single client-server TCP/IP link established, we expanded our application by simultaneously running multiple independent PVIs on several different computers connected to the same TCP/IP message server. Figure 2 shows the set-up used to run multiple PVIs linked to a single server using TCP/IP communications provided by the Instrument Control Toolbox.
Figure 2. Running multiple independent PVIs on several different computers simultaneously connected to the TCP/IP message server. Click on image to see enlarged view.
We also developed and implemented a method to log and display the results of each communication as it occurred. Figure 3 shows a portion of the log file.
Figure 3. Sample data log output. The TCP/IP interface is processing requests from two different MATLAB applications. Click on image to see enlarged view.


Creating 3-D Geographical Backgrounds in MATLAB

We needed to determine if we could use MATLAB to display an accurate 3-D background scene of an actual geographical location without having to purchase and integrate a third-party flight simulator into our sensor management system. Using such a third-party simulator would have caused additional cost, license, integration, and distribution issues. Furthermore, we hoped to improve output times by executing both the application processing and scene display in a MATLAB environment.
We used the Mapping Toolbox to display actual 3-D geographical background scenes of Utah and Idaho directly in our MATLAB application, using purchased aerial images "draped" over digital elevation model (DEM) data of the same area. The results are, to say the least, amazing, extremely realistic, and useful. Figure 4 shows a screenshot of the PVI and its 3-D display.

Figure 4. Stand-alone PVI application developed in MATLAB. We used the Mapping Toolbox to develop a realistic 3-D geographical data display of the results. Click on image to see enlarged view.

Distributing the Application

We used the MATLAB Compiler mcc function to convert the PVI into a stand-alone executable (EXE) that we could distribute to many users. As a result, we could distribute the PVI any number of times without additional costs or conditions. There is no difference in appearance or functionality between the application running on full MATLAB and the stand-alone versions.
Using the PVI

To use the PVI for visualization of potential dangers in a specific area, you first set up a client-server TCP/IP connection by entering the IP address and port number of the server computer (the remote host) that is currently running the message server and is waiting for data transmission. The PVI provides editable fields for these inputs (see Figure 5).
Figure 5. The team used GUIDE, the MATLAB GUI development tool, to create fields and sliders for entering data and displaying results in the PVI. Users enter the IP address and port number in the two input fields and adjust the sensor and target positions using the sliders. Each GUI window is labeled to identify the input fields and results. Click on image to see enlarged view.

You can then use a series of sliders to adjust the latitude, longitude, and altitude (lat/long/alt) positioning of the sensing platform and the sensor's target. When you move a slider, the client application transmits the sensor position and target information to the server via TCP/IP. The server application (the C program) receives six scalars from the client: the lat/long/alt position of the “ownship” and the lat/long/alt of the camera's target. Once the server receives the two sets of coordinates, the application processes the data by computing the new bearing and the distance from the tracking platform to the target. The server returns the bearing and distance to the client, which displays the updated information in the PVI GUI window specific to each output.
For the test case illustrated in this article, we used the Mapping Toolbox to create a realistic 3-D display of Bear Lake in Idaho and Utah, an area of approximately 350 square miles. Our results were quite impressive, both visually and in terms of processing and communication time. While experimenting with the TCP/IP communication among different computers on a LAN, we found that the communication and processing were so fast that when we clicked a slider's arrowhead, the data was delivered, processed, returned, displayed, and the new viewpoint image rendered in less time than it took to click the same slider's arrowhead again.
The Electrical and Computer Engineering Department at George Mason University used MATLAB to develop a platform sensor management (PSM) system to help aircraft pilots navigate in potentially adverse situations. This project included the development of a GUI known as the platform visual interface (PVI), which provides pilots with fast visual feedback about their surrounding conditions. A primary project goal was demonstrating to our sponsor that a legacy software application could be integrated with the new system. Working with limited financial and engineering resources, we also needed to be able to freely distribute our software application and not purchase additional third-party applications. We chose MATLAB to develop the PVI for its analysis, visualization, and GUI-building capabilities. The Instrument Control Toolbox provided TCP/IP network functionality, enabling us to develop new MATLAB based software while utilizing a remote application written in C. We were able to quickly and easily build, test, and freely distribute the PVI application.
For information on the Instrument Control Toolbox, contact Steve Kolak.


更多...
  回复时引用此帖
回复

主题工具
显示模式

发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛启用 表情符号
论坛启用 [IMG] 代码
论坛启用 HTML 代码



所有时间均为北京时间。现在的时间是 03:12


Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.