CN110134025A - A real-time simulation system for a small distributed hypersonic vehicle - Google Patents
A real-time simulation system for a small distributed hypersonic vehicle Download PDFInfo
- Publication number
- CN110134025A CN110134025A CN201910443127.3A CN201910443127A CN110134025A CN 110134025 A CN110134025 A CN 110134025A CN 201910443127 A CN201910443127 A CN 201910443127A CN 110134025 A CN110134025 A CN 110134025A
- Authority
- CN
- China
- Prior art keywords
- simulation
- module
- data
- aircraft
- real
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000004088 simulation Methods 0.000 title claims abstract description 160
- 230000000007 visual effect Effects 0.000 claims abstract description 33
- 230000003993 interaction Effects 0.000 claims abstract description 12
- 230000006870 function Effects 0.000 claims description 71
- 238000000034 method Methods 0.000 claims description 42
- 230000008569 process Effects 0.000 claims description 27
- 238000004891 communication Methods 0.000 claims description 14
- 238000012545 processing Methods 0.000 claims description 13
- 238000013500 data storage Methods 0.000 claims description 11
- 238000006243 chemical reaction Methods 0.000 claims description 6
- 238000004364 calculation method Methods 0.000 claims description 5
- 230000005540 biological transmission Effects 0.000 claims description 4
- 230000008859 change Effects 0.000 abstract description 16
- 238000012800 visualization Methods 0.000 abstract description 3
- 238000013461 design Methods 0.000 description 10
- 230000000694 effects Effects 0.000 description 10
- 238000010586 diagram Methods 0.000 description 9
- 238000010276 construction Methods 0.000 description 5
- 238000007405 data analysis Methods 0.000 description 5
- 238000011161 development Methods 0.000 description 5
- 238000005516 engineering process Methods 0.000 description 5
- 230000009466 transformation Effects 0.000 description 5
- 238000012360 testing method Methods 0.000 description 4
- 238000004422 calculation algorithm Methods 0.000 description 3
- 239000000463 material Substances 0.000 description 3
- 238000012795 verification Methods 0.000 description 3
- RZVHIXYEVGDQDX-UHFFFAOYSA-N 9,10-anthraquinone Chemical compound C1=CC=C2C(=O)C3=CC=CC=C3C(=O)C2=C1 RZVHIXYEVGDQDX-UHFFFAOYSA-N 0.000 description 2
- 239000011159 matrix material Substances 0.000 description 2
- 230000004044 response Effects 0.000 description 2
- 238000005316 response function Methods 0.000 description 2
- 238000013459 approach Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000008901 benefit Effects 0.000 description 1
- 230000003139 buffering effect Effects 0.000 description 1
- 239000003086 colorant Substances 0.000 description 1
- 238000005094 computer simulation Methods 0.000 description 1
- 230000007123 defense Effects 0.000 description 1
- 230000003111 delayed effect Effects 0.000 description 1
- 238000006073 displacement reaction Methods 0.000 description 1
- 230000008676 import Effects 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 230000002452 interceptive effect Effects 0.000 description 1
- 238000007726 management method Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000003825 pressing Methods 0.000 description 1
- 238000009877 rendering Methods 0.000 description 1
- 238000011160 research Methods 0.000 description 1
- 238000005070 sampling Methods 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G05—CONTROLLING; REGULATING
- G05B—CONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
- G05B17/00—Systems involving the use of models or simulators of said systems
- G05B17/02—Systems involving the use of models or simulators of said systems electric
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F30/00—Computer-aided design [CAD]
- G06F30/20—Design optimisation, verification or simulation
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02T—CLIMATE CHANGE MITIGATION TECHNOLOGIES RELATED TO TRANSPORTATION
- Y02T90/00—Enabling technologies or technologies with a potential or indirect contribution to GHG emissions mitigation
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Automation & Control Theory (AREA)
- Computer Hardware Design (AREA)
- Evolutionary Computation (AREA)
- Geometry (AREA)
- General Engineering & Computer Science (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
- Processing Or Creating Images (AREA)
Abstract
本发明提供给出一种小型分布式高超声速飞行器实时仿真系统,由主控模块、仿真模块和视景模块构成,该系统包含了人机交互界面,用户可以在该界面随时更改飞行器的相关参数而不需中断仿真,同时含有视景界面,使用者可以在该界面清楚地看到在当前参数下飞行器的飞行状态,具有简洁、高实时性和可视化的特点。
The invention provides a real-time simulation system for a small-scale distributed hypersonic aircraft, which is composed of a main control module, a simulation module and a visual module. The system includes a human-computer interaction interface, and the user can change the relevant parameters of the aircraft at any time on the interface There is no need to interrupt the simulation, and it also contains a visual interface, the user can clearly see the flight status of the aircraft under the current parameters on this interface, which has the characteristics of simplicity, high real-time and visualization.
Description
技术领域technical field
本发明涉及属于仿真领域,特别涉及一种面向高超声速飞行器的小型仿真平台设计,在MATLAB环境下结合Simulink搭建控制器和飞行器模型,结合VC++ 和OpenGL开发管理平台和人机交互界面,形成联合移动便携式仿真平台,适用于在线调节下的仿真和验证。The invention relates to the field of simulation, in particular to a design of a small-scale simulation platform for hypersonic aircraft, which combines Simulink to build a controller and aircraft model under the MATLAB environment, and combines VC++ and OpenGL development management platform and human-computer interaction interface to form a joint mobile Portable simulation platform, suitable for simulation and verification under online regulation.
背景技术Background technique
随着科学技术的不断发展,对于飞行器的关注也越来越多。飞行器,尤其是高超声速飞行器等无人飞行器在不同的领域中担任了各种各样的角色,被广泛应用于农业、商业、军事、和国防领域,具有不可替代的价值和潜力。但是飞行器性能的影响因素多,造价高,易损毁等特点往往也制约了飞行器的发展速度。对于目前取得的成果,其实际可行性往往无法直接得到验证,而仿真在控制领域得到了广泛的应用,利用仿真平台对已取得的成果进行可行性仿真有着实际飞行试验无可比拟的优势。计算机仿真平台经济,安全,不受场地及天气环境限制,可控且可重复试验,这些特点使得仿真平台在飞行器研究中占据了重要地位,世界各国对飞行器仿真平台给予了高度重视并作为重点发展项目。With the continuous development of science and technology, more and more attention has been paid to aircraft. Aircraft, especially unmanned aerial vehicles such as hypersonic vehicles, have played various roles in different fields and are widely used in agriculture, commerce, military, and national defense, and have irreplaceable value and potential. However, there are many factors affecting the performance of the aircraft, the high cost, and the characteristics of easy damage often restrict the development speed of the aircraft. The actual feasibility of the current achievements cannot be verified directly, and simulation has been widely used in the field of control. Using the simulation platform to simulate the feasibility of the achieved results has an incomparable advantage in actual flight tests. The computer simulation platform is economical, safe, not limited by the site and weather environment, controllable and repeatable. These characteristics make the simulation platform occupy an important position in the research of aircraft. Countries all over the world have attached great importance to the aircraft simulation platform and developed it as a key point. project.
为了验证不同设计方案的性能,工程师们通常会使用MATLAB等软件进行离线的仿真验证,但是这种方式具有极大局限性,我们只能通过仿真结果中的数据、图像等分析设计方案的性能,但不能看到当前参数情况下飞行器的实时飞行状态。其次,MATLAB仿真为离线仿真,仿真开始后,如果系统的一些参数发生改变,我们就只能等待当前仿真结束,或者直接停止仿真,更改参数后重新进行,无法得到在参数发生变化时系统响应的动态变化过程。再者,Simulink 环境下的仿真并非真正意义上的实时仿真,它在一定程度上改变了模型的仿真时间。In order to verify the performance of different design schemes, engineers usually use software such as MATLAB to conduct offline simulation verification, but this method has great limitations. We can only analyze the performance of design schemes through the data and images in the simulation results. But you cannot see the real-time flight status of the aircraft under the current parameters. Secondly, MATLAB simulation is an offline simulation. After the simulation starts, if some parameters of the system change, we can only wait for the current simulation to end, or stop the simulation directly, and restart after changing the parameters. We cannot get the system response when the parameters change. dynamic process. Furthermore, the simulation in the Simulink environment is not real-time simulation in the true sense, it changes the simulation time of the model to a certain extent.
一般情况下,在现有的飞行器仿真方法中,根据仿真模型形式的不同和仿真的不同方式,飞行器仿真可以分为三类,即实物仿真、半实物仿真和全数字仿真。进行飞行器仿真,尤其是高超声速飞行器的仿真需要大量不同类型的资源,模型精度越高,结构越复杂,解算时间将越长,在单机仿真中对于这类模型几乎不能完成实时仿真。同时这种仿真的方法需要操作人员能够有足够的编程仿真能力,且不能实时更改参数进行调试,要求较高,且相对繁琐。当前一些较好的在线实时仿真系统,大多造价较高,或者技术保密,或者为专用的系统,普通的工程人员无法使用。此外,大多已有仿真平台不具有移动性,或移动性较差,无法满足仿真的实用性和灵活性要求。In general, in the existing aircraft simulation methods, aircraft simulation can be divided into three categories according to different simulation model forms and different simulation methods, namely physical simulation, semi-physical simulation and full digital simulation. Simulation of aircraft, especially hypersonic aircraft, requires a large number of different types of resources. The higher the accuracy of the model, the more complex the structure, and the longer the calculation time. It is almost impossible to complete real-time simulation for this type of model in stand-alone simulation. At the same time, this simulation method requires the operator to have sufficient programming and simulation capabilities, and cannot change parameters in real time for debugging, which requires high requirements and is relatively cumbersome. At present, some good online real-time simulation systems are mostly expensive, or the technology is confidential, or it is a special system, which cannot be used by ordinary engineers. In addition, most existing simulation platforms do not have mobility, or have poor mobility, which cannot meet the practicality and flexibility requirements of simulation.
考虑到现有仿真方法所存在弊端,包括复杂的模型建立,不可连续的调参过程,无法直观地实时观测飞行器的状态。考虑到现有仿真方法和仿真平台所存在弊端,包括复杂的模型建立,不可连续的调参过程,无法直观地实时观测飞行器的状态,移动性差等问题。Considering the disadvantages of the existing simulation methods, including complex model establishment and discontinuous parameter adjustment process, it is impossible to observe the state of the aircraft intuitively in real time. Considering the disadvantages of existing simulation methods and simulation platforms, including complex model establishment, non-continuous parameter adjustment process, inability to intuitively observe the state of the aircraft in real time, and poor mobility.
发明内容Contents of the invention
为了解决现有技术存在的问题,本发明将给出一种小型移动分布式飞行器实时仿真平台的设计方案。该方案将给出实现实时仿真的设计方法,同时,针对仿真过程中不可在线调参的问题,本方案包含了人机交互界面,用户可以在该界面随时更改飞行器的相关参数而不需中断仿真;该系统同时含有视景界面,使用者可以在该界面清楚地看到在当前参数下飞行器的实时飞行状态;所以本方案具有简洁、高实时性和可视化的特点。In order to solve the problems existing in the prior art, the present invention will provide a design scheme of a real-time simulation platform for small mobile distributed aircraft. This program will give a design method to realize real-time simulation. At the same time, in view of the problem that online parameters cannot be adjusted during the simulation process, this program includes a human-computer interaction interface. Users can change the relevant parameters of the aircraft at any time on this interface without interrupting the simulation. ; The system also contains a visual interface, the user can clearly see the real-time flight status of the aircraft under the current parameters on this interface; so this program has the characteristics of simplicity, high real-time and visualization.
针对现有技术存在的问题,本方采用如下技术方案予以实现:In view of the problems existing in the existing technology, this party adopts the following technical solutions to realize it:
一种小型分布式高超声速飞行器实时仿真系统,由主控模块、仿真模块和视景模块构成,A real-time simulation system for a small distributed hypersonic vehicle, consisting of a main control module, a simulation module and a visual module,
主控模块是整个分布式仿真平台的枢纽,在Simulink环境下模拟飞行器模型,在仿真过程中与仿真模块进行数据互传,并把姿态数据传送给视景模块,同时具有控制仿真启停和存储仿真数据的功能;The main control module is the hub of the entire distributed simulation platform. It simulates the aircraft model in the Simulink environment, transmits data with the simulation module during the simulation process, and transmits the attitude data to the visual module. It also has the functions of controlling the simulation start-stop and storage Functions for simulating data;
仿真模块相当于飞行器的控制器,运行支持Simulink外部模式的飞行控制程序和服务器程序,根据主控模块传来的飞行器姿态数据和给定参数,通过计算给出控制指令并发送给主控模块;其中,所述仿真模块包括数据接收模块、数据实时显示模块、数据存储模块、数据查看模块、实时曲线绘制模块和人机交互界面;The simulation module is equivalent to the controller of the aircraft. It runs the flight control program and server program that support the Simulink external mode. According to the aircraft attitude data and given parameters transmitted from the main control module, control instructions are given through calculation and sent to the main control module; Wherein, the simulation module includes a data receiving module, a real-time data display module, a data storage module, a data viewing module, a real-time curve drawing module and a human-computer interaction interface;
视景模块运行视景软件,负责实时接收主控模块传输来的飞行器姿态数据,通过动画的形式表现飞行器实时状态,使用户更直观地观察整个仿真过程,其中:所述视景模块包括动画显示单元、视景显示单元、数据接收处理单元和飞行器模型和场景模型。The visual module runs the visual software, is responsible for receiving the attitude data of the aircraft transmitted by the main control module in real time, and displays the real-time state of the aircraft in the form of animation, so that the user can observe the whole simulation process more intuitively, wherein: the visual module includes animation display Unit, visual display unit, data receiving and processing unit, aircraft model and scene model.
本发明还包括如下步骤予以实施:The present invention also comprises following steps to implement:
S1,仿真模块设置初始参数;S1, the simulation module sets initial parameters;
S2,主控模块启动仿真过程;S2, the main control module starts the simulation process;
2.1、基于RTW的飞控程序转换;2.1. RTW-based flight control program conversion;
2.2、构建转换通信网络;2.2. Build a conversion communication network;
2.3、实时仿真处理;2.3. Real-time simulation processing;
S3,仿真模块接收相应数据分发不同数据处理模块实现人机交互对飞行器输出数据输出和曲线图像过程;S3, the simulation module receives the corresponding data and distributes different data processing modules to realize the human-computer interaction to the aircraft output data output and curve image process;
S4,视景模块接收相应数据以动画的形式显示飞行器的飞行状态;S4, the visual module receives corresponding data and displays the flight state of the aircraft in the form of animation;
S5,仿真模块通过人机互换界面实现在线参数调整,如果仿真模块中曲线图像和视景模块中飞行器状态满足要求,则结束仿真状态;否则返回步骤S2。S5, the simulation module realizes online parameter adjustment through the man-machine exchange interface, if the curve image in the simulation module and the state of the aircraft in the visual module meet the requirements, then end the simulation state; otherwise, return to step S2.
所述主控模块和仿真模块基于TCP/IP通信协议进行数据传输,主控模块与仿真模块采用客户端/服务器模式,客户端将飞行器模型的姿态数据发送给服务器,服务器接收姿态数据并且将飞行控制程序输出的控制指令发送给飞行器模型,选用C语言的SOCKET套接字编程编写客户端和服务器代码以实现数据的正常发送和接收功能。The main control module and the simulation module carry out data transmission based on the TCP/IP communication protocol, the main control module and the simulation module adopt the client/server mode, the client sends the attitude data of the aircraft model to the server, and the server receives the attitude data and sends the flight The control commands output by the control program are sent to the aircraft model, and the client and server codes are written by using C language SOCKET socket programming to realize the normal sending and receiving functions of data.
有益效果Beneficial effect
1、考虑到现有仿真方法所存在弊端,包括复杂的模型建立,不可连续的调参过程,无法直观地实时观测飞行器的状态;本发明将给出实现实时仿真的设计方法,同时,针对仿真过程中不可调参的问题,本方案包含了人机交互界面,用户可以在该界面随时更改飞行器的相关参数而不需中断仿真;方案同时含有视景界面,使用者可以在该界面清楚地看到在当前参数下飞行器的飞行状态;具有简洁、高实时性和可视化的特点。1. Considering the disadvantages of the existing simulation methods, including complex model establishment, non-continuous parameter adjustment process, and the inability to observe the state of the aircraft in real time intuitively; this invention will provide a design method for real-time simulation. At the same time, for the simulation For problems that cannot be adjusted during the process, this solution includes a human-computer interaction interface, where the user can change the relevant parameters of the aircraft at any time without interrupting the simulation; the solution also includes a visual interface, where the user can clearly see To the flight status of the aircraft under the current parameters; it has the characteristics of simplicity, high real-time and visualization.
2、在使用MATLAB等仿真软件或仿真平台进行算法验证时,仿真结果通常无法实时显示,若要修改系统参数,需等当前仿真结束或停止仿真才可实现,且更改后的结果无法立时显示,因此难以体现实时的特点。为此,发明的仿真平台目的在于,当仿真进行时如需要调整系统参数,可在仿真模块的相应窗口直接进行更改,仿真即能够在新的参数下继续进行,而无需终端,从而可实时观察到因参数改变而引起的仿真结果变化,实现在线调参。2. When using simulation software such as MATLAB or a simulation platform for algorithm verification, the simulation results usually cannot be displayed in real time. If you want to modify the system parameters, you need to wait for the current simulation to end or stop the simulation before it can be realized, and the changed results cannot be displayed immediately. Therefore, it is difficult to reflect the real-time characteristics. For this reason, the purpose of the simulation platform invented is that if the system parameters need to be adjusted during the simulation, the changes can be made directly in the corresponding window of the simulation module, and the simulation can continue under the new parameters without a terminal, so that real-time observation To realize the change of simulation results caused by parameter changes, realize online parameter adjustment.
3、现有仿真平台的仿真时间尺度大多与真实系统差距较大,而本平台在实时性方面能更好地逼近真实系统;同时,平台的视景模块可以将飞行器在仿真过程中的飞行状态实时地显示出来,让使用者能够更直观地了解飞行器当前的状态。3. Most of the simulation time scales of the existing simulation platforms are far from the real system, but this platform can better approach the real system in terms of real-time performance; at the same time, the visual module of the platform can compare the flight status of the aircraft during the simulation process. It is displayed in real time, allowing users to understand the current status of the aircraft more intuitively.
附图说明Description of drawings
图1为本发明的流程图;Fig. 1 is a flowchart of the present invention;
图2为本发明仿真模块界面布局示意图;Fig. 2 is a schematic diagram of the interface layout of the simulation module of the present invention;
图3为数据实时显示模块效果图;Figure 3 is the effect diagram of the data real-time display module;
图4数据查看模块效果图;Figure 4 Data view module effect diagram;
图5仿真模块人机交互界面;Fig. 5 The human-computer interaction interface of the simulation module;
图6视景模块结构框图;Figure 6 Structural block diagram of the visual module;
图7飞行器模型简图;Fig. 7 sketch map of aircraft model;
图8动画的过程框图Figure 8 Process block diagram of animation
图9分布是仿真系统结构框图;Fig. 9 distribution is a structural block diagram of the simulation system;
图10视景模块仿真软件实现流程图;Figure 10 is a flow chart of the simulation software implementation of the visual module;
具体实施方式Detailed ways
本发明涉及一种基于MATLAB的在线实时仿真方法,以高超声速飞行器的纵向模型为例,介绍其设计方法,实现高超声速飞行器的可视化在线实时仿真。The invention relates to an online real-time simulation method based on MATLAB. Taking a longitudinal model of a hypersonic aircraft as an example, the design method is introduced to realize the visualized online real-time simulation of the hypersonic aircraft.
如图1所示,首先给出仿真平台的整体设计方案。本分布式仿真平台共由三大模块构成,分别为主控模块,仿真模块和视景模块。As shown in Figure 1, the overall design of the simulation platform is given first. The distributed simulation platform consists of three modules, namely the main control module, the simulation module and the visual module.
主控模块是整个分布式仿真平台的枢纽,在Simulink环境下模拟飞行器模型,在仿真过程中与仿真模块进行数据互传,并把姿态数据传送给视景模块,同时具有控制仿真启停和存储仿真数据的功能。The main control module is the hub of the entire distributed simulation platform. It simulates the aircraft model in the Simulink environment, transmits data with the simulation module during the simulation process, and transmits the attitude data to the visual module. It also has the functions of controlling the simulation start-stop and storage Functions for simulating data.
仿真模块相当于飞行器的控制器,运行支持Simulink外部模式的飞行控制程序和服务器程序,根据主控模块传来的飞行器姿态数据和给定参数,通过计算给出控制指令并发送给主控模块。The simulation module is equivalent to the controller of the aircraft. It runs the flight control program and server program that support the Simulink external mode. According to the aircraft attitude data and given parameters transmitted from the main control module, control instructions are given through calculation and sent to the main control module.
视景模块运行视景软件,负责实时接收主控模块传输来的飞行器姿态数据,通过动画的形式表现飞行器实时状态,使用户更直观地观察整个仿真过程。The visual module runs the visual software, which is responsible for receiving the aircraft attitude data transmitted by the main control module in real time, and displays the real-time status of the aircraft in the form of animation, so that users can observe the whole simulation process more intuitively.
本发明还包括如下步骤予以实施:The present invention also comprises following steps to implement:
S1(101),仿真模块设置初始参数;S1 (101), the simulation module sets initial parameters;
S2(102),主控模块启动仿真过程;S2 (102), the main control module starts the simulation process;
2.1、基于RTW的飞控程序转换;2.1. RTW-based flight control program conversion;
2.2、构建转换通信网络;2.2. Build a conversion communication network;
2.3、实时仿真处理;2.3. Real-time simulation processing;
S3(103),仿真模块接收相应数据分发不同数据处理模块实现人机交互对飞行器输出数据输出和曲线图像过程;S3 (103), the simulation module receives the corresponding data and distributes different data processing modules to realize the human-computer interaction to the aircraft output data output and curve image process;
S4(104),视景模块接收相应数据以动画的形式显示飞行器的飞行状态;S4 (104), the visual module receives corresponding data and displays the flight status of the aircraft in the form of animation;
S5(105),仿真模块通过人机互换界面实现在线参数调整,如果仿真模块中曲线图像和视景模块中飞行器状态满足要求,则结束仿真状态;否则返回步骤 S2,其中:S5 (105), the simulation module realizes online parameter adjustment through the man-machine exchange interface, if the curve image in the simulation module and the state of the aircraft in the visual module meet the requirements, then end the simulation state; otherwise return to step S2, wherein:
1、主控模块1. Main control module
根据主控模块的功能,其实现主要包括三大部分:基于RTW的飞控程序转换,通讯网络的构建和实时仿真的实现。According to the function of the main control module, its realization mainly includes three parts: the flight control program conversion based on RTW, the construction of communication network and the realization of real-time simulation.
(1)基于RTW的飞控程序转换(1) RTW-based flight control program conversion
为实现飞控程序的转换,首先以高超声速飞行器的纵向模型为例,结合反步法和动态逆方法,在Simulink中搭建控制器模型。In order to realize the conversion of the flight control program, the longitudinal model of the hypersonic vehicle is taken as an example, and the controller model is built in Simulink by combining the backstepping method and the dynamic inverse method.
该控制器的主要作用是能在仿真的过程中,根据飞行器模型状态计算出控制指令,实时地改变控制器的参数并将控制器输出的控制指令发送给飞行器模型,使飞行器模型做出相应变化,而利用RTW工具箱能实现实时在线改变数据的功能。因此,将模型保存为flight_ctrl.mdl文件,利用RTW对控制器模型进行C代码和外部可执行程序的生成。The main function of the controller is to calculate the control instructions according to the state of the aircraft model during the simulation process, change the parameters of the controller in real time and send the control instructions output by the controller to the aircraft model, so that the aircraft model can make corresponding changes , and the use of RTW toolbox can realize the function of changing data online in real time. Therefore, save the model as flight_ctrl.mdl file, and use RTW to generate C code and external executable program for the controller model.
在转化之前,为了在程序仿真结束后保存输入的飞行器模型状态量,先对其进行输出配置:打开模型中的scope模块,选择设置中的History选项卡,取消Limit data选项,并选中Save data to workspace选项,将变量名改为 All Data,并以Array格式存储。Before the conversion, in order to save the input aircraft model state quantity after the program simulation ends, first configure the output: open the scope module in the model, select the History tab in the settings, cancel the Limit data option, and select Save data to workspace option, change the variable name to All Data, and store it in Array format.
接下来进行C代码和外部程序的生成选项设,打开Model ConfigurationParameters面板:Next, set the generation options of C code and external programs, and open the Model ConfigurationParameters panel:
1.选中Solver选项卡,将终止时间改为inf,即无限时间,将定步长设置为0.05,并选择精度较高ode4算法,保存设置;1. Select the Solver tab, change the termination time to inf, that is, infinite time, set the fixed step size to 0.05, and select the ode4 algorithm with higher precision, and save the settings;
2.选中Code Generation选项卡,在Target selection选项中,单击Browse 按钮,打开系统目标文件浏览器,将系统目标文件改为嵌入式实时目标,即 ert.tlc,单击Apply,返回Code Generation选项卡,取消Generate code only 选项;2. Select the Code Generation tab, in the Target selection option, click the Browse button to open the system target file browser, change the system target file to the embedded real-time target, ie ert.tlc, click Apply, and return to the Code Generation option card, cancel the Generate code only option;
3.选中MAT-file logging选项,以保存飞控程序的输出数据。当程序运行结束后会生成flight_ctrl.mat文件,该文件中的rt_yout保存的是飞控程序的两路输出数据,rt_tout保存的是仿真时间。为避免数据溢出,在Make command 窗口添加语句make_rtw OPTS=”-DDEFAULT_BUFFER_SIZE=102400”,使内存分配达到102400Byte,保证存储空间,在Template makefile窗口添加ert_default_tmf;3. Select the MAT-file logging option to save the output data of the flight control program. When the program finishes running, the flight_ctrl.mat file will be generated. The rt_yout in this file saves the two output data of the flight control program, and the rt_tout saves the simulation time. In order to avoid data overflow, add the statement make_rtw OPTS=”-DDEFAULT_BUFFER_SIZE=102400” in the Make command window to make the memory allocation reach 102400Byte to ensure storage space, and add ert_default_tmf in the Template makefile window;
4.选中Interface选项卡,在Interface选项中选择External mode,在 Transportlayer选项中选择tcpip,使生成的代码支持外部模式仿真,保存以上设置,返回CodeGeneration选项卡,单击Build按钮。成功生成代码后,将会出现flight_ctrl.exe和ert_main.c文件。flight_ctrl.exe即生成的支持外部模式的飞行控制程序,ert_main.c是飞行控制程序的入口。4. Select the Interface tab, select External mode in the Interface option, select tcpip in the Transportlayer option, so that the generated code supports external mode simulation, save the above settings, return to the CodeGeneration tab, and click the Build button. After successfully generating the code, the flight_ctrl.exe and ert_main.c files will appear. flight_ctrl.exe is the generated flight control program that supports external mode, and ert_main.c is the entry of the flight control program.
(2)通讯网络的构建(2) Construction of communication network
如图9所示,本发明中的分布式飞行器仿真平台基于TCP/IP通信协议进行数据传输,主控模块与仿真模块采用客户端/服务器模式,客户端将飞行器模型的姿态数据发送给服务器,服务器接收姿态数据并且将飞行控制程序输出的控制指令发送给飞行器模型,选用C语言的SOCKET套接字编程编写客户端和服务器代码以实现数据的正常发送和接收功能:As shown in Figure 9, the distributed aircraft simulation platform in the present invention carries out data transmission based on the TCP/IP communication protocol, the main control module and the simulation module adopt the client/server mode, and the client sends the attitude data of the aircraft model to the server, The server receives the attitude data and sends the control commands output by the flight control program to the aircraft model, and uses C language SOCKET socket programming to write the client and server codes to realize the normal sending and receiving functions of data:
首先找到并打开上一步生成的ert_main.c文件,在int_T main()函数中找到rt_OneStep()函数,在该函数之前添加创建、绑定、监听、接受连接等套接字代码和接收数据的相关代码,在它之后添加发送数据和断开连接关闭套接字的相关代码,保存并对飞行控制模型重新进行C代码生成,便得到了添加了服务器代码的飞行控制程序,实现了仿真平台通讯中的服务器。在启动该程序后,程序将处于监听客户端状态,直到客户端连接请求到来,飞行控制程序才会继续运行;First find and open the ert_main.c file generated in the previous step, find the rt_OneStep() function in the int_T main() function, and add socket codes such as creating, binding, listening, and accepting connections before this function and related to receiving data After the code, add the relevant codes for sending data and disconnecting and closing the socket, save and regenerate the C code for the flight control model, and then get the flight control program with the server code added, and realize the simulation platform communication. server. After starting the program, the program will be in the state of listening to the client, and the flight control program will continue to run until the client connection request arrives;
之后采用相同的方式建立客户端,不同之处在于,建立客户端套接字后不需要利用bind()函数进行套接字绑定,而是使用connect()函数对指定的服务器套接字发送连接请求。Then use the same method to establish the client, the difference is that after the client socket is established, it is not necessary to use the bind() function to bind the socket, but to use the connect() function to send the specified server socket Connection request.
完成通讯网络的构建之后,仍以纵向模型为例,在simulink中搭建飞行器模型。该控制器共有七个输入,分别为速度V,航迹角γ,攻角α,油门开度β,高度h,俯仰率q和油门开度的一阶导数有两个输出,为油门开度指令βc和升降舵偏转角δe。为保证飞行器模型输出的数据与飞行控制程序所接收的数据是同一时刻和同一精度的数据,需要在飞行器模型的Configuration Parameters 面板中把解法器设置为定步长、ode4算法,固定步长0.05,这与飞行控制程序的基本参数设置相同。After completing the construction of the communication network, still taking the longitudinal model as an example, build the aircraft model in simulink. The controller has seven inputs, which are velocity V, track angle γ, angle of attack α, throttle opening β, altitude h, pitch rate q and the first derivative of throttle opening There are two outputs, throttle opening command β c and elevator deflection angle δ e . In order to ensure that the data output by the aircraft model and the data received by the flight control program are at the same time and with the same accuracy, it is necessary to set the solver to a fixed step size, ode4 algorithm, and a fixed step size of 0.05 in the Configuration Parameters panel of the aircraft model. This is the same as the basic parameter setting of the flight control program.
为了增强其可读性,将模型封装为子系统,引入C-MEX Sfunction模块充当客户端,并取名为client.c,与飞行控制程序的服务器进行通信。在最终飞行器模型中,C-MEXSfunction模块的输入是飞行器模型的七个输出变量,而输出是接收到的飞行器模型的两个输入变量。In order to enhance its readability, the model is packaged as a subsystem, and the C-MEX Sfunction module is introduced to act as a client, and named client.c, to communicate with the server of the flight control program. In the final vehicle model, the input of the C-MEXSfunction module is the seven output variables of the vehicle model, and the output is the received two input variables of the vehicle model.
之后对C-MEX Sfunction模块进行修改并写入客户端代码:Then modify the C-MEX Sfunction module and write the client code:
第一步,将Sfunction模块的名字改为client,加入客户端代码需要的头文件,定义所需的变量,在Sfunction模块的mdlInitializeSizes()函数中设置1个输入端口数,且输入的维数是7;输出的端口数为1,输出的维数是2;采样时间是0.05;其他设置保持默认值;The first step is to change the name of the Sfunction module to client, add the header file required by the client code, define the required variables, set an input port number in the mdlInitializeSizes() function of the Sfunction module, and the input dimension is 7; The number of output ports is 1, the output dimension is 2; the sampling time is 0.05; other settings keep the default values;
第二步,在所有函数体外进行数据类型转化子函数的声明和定义,并在 mdlStart()函数中创建客户端套接字,并设置要连接的服务器信息,如IP地址和端口号;在mdlOutputs()函数中进行数据的发送与接收;The second step is to declare and define the data type conversion sub-function outside the body of all functions, and create a client socket in the mdlStart() function, and set the server information to be connected, such as IP address and port number; in mdlOutputs () function to send and receive data;
第三步,在mdlTerminate()函数中关闭客户端套接字,释放系统资源;The third step is to close the client socket in the mdlTerminate() function and release system resources;
最后,在MATLAB的命令窗口输入mex client.c指令对刚刚编辑的C-MEXSfunction进行编译。Finally, enter the mex client.c command in the command window of MATLAB to compile the C-MEXS function just edited.
(3)实时仿真的实现(3) Realization of real-time simulation
由于该仿真模型仿真时间要比系统时间快很多,为了使MATLAB仿真所用的时间与真实时间一致,需要在客户端和服务器程序中添加延时代码,使飞行器模型按一定时间间隔接收控制指令。使用Simulink模块库中的Clock模块可以方便地得到当前仿真所用的时间,计算出需要延时的时间差,利用C语言中的 Sleep函数进行延时,以达到实时仿真的效果。修改代码后要对飞行控制程序重新生成C代码和可执行程序,飞行器模型的Sfunction模块需要重新编译 client.c文件。Since the simulation time of the simulation model is much faster than the system time, in order to make the MATLAB simulation time consistent with the real time, it is necessary to add delay codes in the client and server programs to make the aircraft model receive control commands at a certain time interval. Using the Clock module in the Simulink module library can easily get the time used by the current simulation, calculate the time difference that needs to be delayed, and use the Sleep function in C language to delay the time to achieve the effect of real-time simulation. After modifying the code, it is necessary to regenerate the C code and executable program for the flight control program, and the Sfunction module of the aircraft model needs to recompile the client.c file.
如图2所示,仿真模块应能实现五大功能:数据实时接收、数据实时显示、数据存储、数据查看、实时曲线绘制。其系统框图如图1,数据接收模块接收客户端传来的数据,将数据分别传到数据实时显示模块,数据存储模块与实时曲线绘制模块。其中数据存储模块处理后将数据传入数据查看模块。在所有后台模块均对传来的数据进行相关处理后,统一传到人机交互界面,将数据显示出来,以便平台使用者查看。As shown in Figure 2, the simulation module should be able to realize five functions: real-time data reception, real-time data display, data storage, data viewing, and real-time curve drawing. The system block diagram is shown in Figure 1. The data receiving module receives the data from the client, and transmits the data to the real-time data display module, data storage module and real-time curve drawing module. The data storage module transfers the data to the data viewing module after processing. After all the background modules have processed the incoming data, they will be uniformly transmitted to the human-computer interaction interface, and the data will be displayed for platform users to view.
根据仿真模块的功能要求,对其界面进行了如图2的规划,其中左上角为飞行器图片,右上角为数据存储和查看部分,下方为数据分析的曲线图,用以显示各个参数的实时变化过程。According to the functional requirements of the simulation module, its interface is planned as shown in Figure 2. The upper left corner is the picture of the aircraft, the upper right corner is the data storage and viewing part, and the lower part is the data analysis curve to display the real-time changes of various parameters. process.
平台使用VC6.0作为开发工具,使用C++进行编程,下面将介绍其开发过程。The platform uses VC6.0 as a development tool and uses C++ for programming. The following will introduce its development process.
(1)整体布局设计(1) Overall layout design
首先打开VC6.0,创建一个新的MFC单文档exe程序,保存并命名为chap10,插入一个新的DIALOG,并在上方中间位置插入一个静态文本,将其标题改为“分布式飞行器仿真平台仿真管理软件”,在DIALOG1中分别添加三个组框,其中右上角及正下方组框分别命名为“数据存储与查看”和“数据分析”。在左上角组框内加入图片控件,插入飞行器图片。数据存储与分析组框加入列表控件,同时添加查看数据按钮,为后面数据查看模块实现做准备。最后,以高超声速飞行器纵向模型为例,在数据分析组框依次加入七个Teechart控件,将其大小做适当调整,整齐排列。First open VC6.0, create a new MFC single-document exe program, save it and name it chap10, insert a new DIALOG, and insert a static text in the upper middle position, change its title to "distributed aircraft simulation platform simulation Management software", add three group boxes in DIALOG1 respectively, among which the upper right corner and the right lower group boxes are respectively named "data storage and viewing" and "data analysis". Add a picture control to the group box in the upper left corner and insert the picture of the aircraft. The data storage and analysis group box is added with a list control, and at the same time, a view data button is added to prepare for the implementation of the data view module later. Finally, taking the longitudinal model of the hypersonic vehicle as an example, add seven Teechart controls in sequence in the data analysis group box, adjust their sizes appropriately, and arrange them neatly.
(2)数据实时接收(2) Real-time data reception
利用server=socket函数对自身服务器端即管理软件套接字的端口地址进行设定,同时设置socket属性,并用server_addr.sin_port=htons(6000) 对套接字进行绑定,将管理软件即服务器套接字设置成监听状态,使管理软件时刻处于等待连接的状态。Use the server=socket function to set the port address of the management software socket on the server side, and set the socket attribute at the same time, and use server_addr.sin_port=htons(6000) to bind the socket, and the management software is the server socket The interface is set to monitor state, so that the management software is always in the state of waiting for connection.
当管理软件即服务器端监听到或接收到客户端即飞行器模型的连接请求时,响应其请求,同时建立一个新的线程。将服务器端的描述发送给客户端,等待客户端确认此描述,一旦确认,连接建立,服务器向客户端提供相应服务,服务器端重新处于之前的监听状态,继续等待接收其他客户端的连接请求,以便完成通信与服务。利用Getdata()函数接收数据,即对请求提供相应服务。When the management software, that is, the server, monitors or receives the connection request from the client, that is, the aircraft model, it responds to the request and creates a new thread at the same time. Send the server-side description to the client, and wait for the client to confirm the description. Once confirmed, the connection is established, and the server provides corresponding services to the client. The server is in the previous listening state again, and continues to wait for connection requests from other clients to complete. Communications and Services. Use the Getdata() function to receive data, that is, to provide corresponding services to the request.
(3)数据实时显示(3) Data real-time display
对于数据实时显示模块,由于每隔20ms便会有新的数据到来,因此数据需要20ms更新一次。在界面适当位置即数据存储与查看组框内插入一个listbox 控件,在并将此控件与变量m_list相关联,在控件初始化过程中使用 m_list.InsertItem()函数将列表中第一行中每一列对应的变量名称进行标注,在循环体中将数据实时接收模块中每次循环接收到的七个数据通过sprintf() 函数由int型(序号数字,并非上一模块接收)与double型变量(数据接收模块接收到的数据)统一转化为char型变量,并使用m_list.InsertItem()函数将此次接收到的七个数据实时显示在人机交互界面中对应表格的相应位置(此处需要注意进行换行处理)。显示效果如图3。For the real-time data display module, since new data arrives every 20ms, the data needs to be updated every 20ms. Insert a listbox control in the appropriate position of the interface, that is, the data storage and viewing group box, and associate this control with the variable m_list. During the initialization process of the control, use the m_list.InsertItem() function to correspond to each column in the first row of the list In the loop body, the seven data received in each cycle of the real-time data receiving module are composed of int type (serial number, not received by the previous module) and double type variables (data received) through the sprintf() function The data received by the module) is uniformly transformed into a char variable, and the seven data received this time are displayed in real time in the corresponding position of the corresponding table in the human-computer interaction interface by using the m_list. deal with). The display effect is shown in Figure 3.
(4)数据存储(4) Data storage
在数据接收后,除显示之外,还需将其存储,以便查看。首先利用gcvt函数把浮点数转换成字符串,同时返回一个指向字符串存储位置即缓冲区的指针。向data[i]赋值,并将七个指针分别所指的字符串依次表示出来。然后生成并打开命名好的testdata.txt文件,利用fputs函数,向该文档写入一个字符串,成功写入一个字符串后,文件的位置指针会自动后移,由此将一组数据写入。利用条件语句进行判断,每写入七个数据进行换行,同时清除缓冲区。重复此过程,直至飞行器仿真系统停止运行。After data is received, in addition to displaying it, it needs to be stored for viewing. First, use the gcvt function to convert the floating-point number into a string, and return a pointer to the storage location of the string, that is, the buffer. Assign a value to data[i], and represent the strings pointed to by the seven pointers in sequence. Then generate and open the named testdata.txt file, and use the fputs function to write a string to the file. After a string is successfully written, the position pointer of the file will automatically move backward, thus writing a set of data . Use the conditional statement to judge, and write a line break every seven data, and clear the buffer at the same time. Repeat this process until the aircraft simulation system stops running.
(5)数据查看与另存(5) View and save data
在数据存储的基础上实现数据查看与另存的功能。先在主界面上添加一个“查看数据”按钮,并将此按钮通过ShellExecute()函数来执行运行且控制一个指定的外部程序的功能。在此外部程序的设计中,首先于适当位置添加一个编辑框,并关联变量m_FileText,在界面上分别添加两个按钮即“打开”与“另存为”,实现打开文本文档与将此文档另存为到其他路径的功能。On the basis of data storage, the functions of data viewing and saving are realized. First add a "View Data" button on the main interface, and use this button to execute the function of running and controlling a specified external program through the ShellExecute() function. In the design of this external program, first add an edit box at an appropriate position, and associate the variable m_FileText, and add two buttons on the interface, namely "Open" and "Save As", to realize opening the text document and saving the document as to other path functions.
“打开”按钮单击事件打开所需显示的文本文档,依次读取文档里的内容,关闭选择的文档,并将文档中内容在编辑框内显示出来;“另存为”按钮单击事件处理函数将另存为文档路径显示出来,并进行文本文档的创建,获取之前在编辑框中所显示的内容,在另存为的文本文档当中写入编辑框中数据,通过 file.Close()关闭另存为文本文档。效果图如图4。The "Open" button click event opens the text document to be displayed, reads the content in the document in turn, closes the selected document, and displays the content in the document in the edit box; the "Save As" button clicks the event processing function Display the save as document path, and create a text document, obtain the content displayed in the edit box before, write the data in the edit box in the saved text document, and close the save as text through file.Close() document. The effect diagram is shown in Figure 4.
(6)实时曲线绘制(6) Real-time curve drawing
每接收完一组数据之后,将接收到的七个数据分别与时间节点一一对应,以坐标点的形式分别将其添加到对应的七个实时曲线图上,进而构成七条曲线。After each set of data is received, the seven received data are corresponding to the time nodes one by one, and are added to the corresponding seven real-time graphs in the form of coordinate points, thereby forming seven curves.
下载并注册控件Teechart,在交互界面适当不同位置即数据分析组框内依次添加7个Teechart控件,分别进行初始化,如命名、选择图表类型、横纵坐标的设置等,将七个控件分别关联m_chart,m_chart1,m_chart2,m_chart3, m_chart4,m_chart5,m_chart6七个变量。在每一次接收到七个实时数据之后,利用m_chart.Series(0).Add()函数把每个数据描绘在曲线图当中,循环绘制过程直到仿真结束。其最终界面如图5所示。Download and register the control Teechart, add 7 Teechart controls in sequence in the appropriate different positions of the interactive interface, that is, the data analysis group box, and initialize them respectively, such as naming, selecting the chart type, setting the horizontal and vertical coordinates, etc., and linking the seven controls to m_chart respectively , m_chart1, m_chart2, m_chart3, m_chart4, m_chart5, m_chart6 seven variables. After receiving seven real-time data each time, use the m_chart.Series(0).Add() function to draw each data in the graph, and loop the drawing process until the end of the simulation. Its final interface is shown in Figure 5.
3、视景模块3. Vision module
视景模块在仿真平台中最主要的功能就是以动画的形式实时显示飞行器的飞行状态,为此,视景模块需要具有数据接收的功能,同时要保证动画变换的实时性。其结构框图如图6。本专利使用OpenGL完成基本场景绘制,基于VC++,通过MFC的exe程序来搭建软件框架,通过坐标变换达到飞行器运动的效果,通过双缓存功能实现动画效果,通过数据传输模块实现实时仿真功能。The main function of the visual module in the simulation platform is to display the flight status of the aircraft in the form of animation in real time. For this reason, the visual module needs to have the function of data reception, and at the same time, it must ensure the real-time performance of animation transformation. Its structural block diagram is shown in Figure 6. This patent uses OpenGL to complete the basic scene drawing, based on VC++, builds the software framework through the exe program of MFC, achieves the effect of aircraft movement through coordinate transformation, realizes the animation effect through the double buffer function, and realizes the real-time simulation function through the data transmission module.
(1)基本场景绘制(1) Basic scene drawing
首先完成飞行器模型及场景模型的建立。通过链接OpenGL图形库绘制飞行器模型并进行渲染,其简易模型如图7。为了让仿真具有更加真实的视觉效果,使用glFrustum()和gluLookAt()等函数搭建仿真空间,综合随机刷新点和固定点规律运动的方式制作星空背景,并添加地球模型。First complete the establishment of aircraft model and scene model. The aircraft model is drawn and rendered by linking the OpenGL graphics library, and its simple model is shown in Figure 7. In order to make the simulation have a more realistic visual effect, functions such as glFrustum() and gluLookAt() are used to build the simulation space, and the background of the starry sky is made by combining random refresh points and regular movement of fixed points, and an earth model is added.
(2)软件框架搭建(2) Software framework construction
接下来在MFC单文档环境下实现OpenGL功能,搭建整个仿真软件的环境。启动VC++6.0创建一个新的MFC单文档exe程序,更改头文件,在程序前加入 #include gl\gl.h与#include gl\glu.h,打开链接按钮,在链接的各种库前面加入OpenGL32.Lib与glu32.Lib,并添加mydraw()、mypixelformat()、myfirst() 函数,在函数mypixelformat()中设置像素格式,在myfirst()函数中创建渲染描述表,在Onsize()函数中设置视场和视点,在OnDraw()中加入背景处理,在 mydraw()中加入绘图语句,在Dialog中编辑各种图标和按钮操作,完成视场创建。Next, the OpenGL function is implemented in the MFC single-document environment, and the environment of the entire simulation software is built. Start VC++6.0 to create a new MFC single-document exe program, change the header file, add #include gl\gl.h and #include gl\glu.h before the program, open the link button, in front of various linked libraries Add OpenGL32.Lib and glu32.Lib, and add mydraw(), mypixelformat(), myfirst() functions, set the pixel format in the function mypixelformat(), create a rendering description table in the myfirst() function, and use the Onsize() function Set the field of view and viewpoint in OnDraw(), add background processing in OnDraw(), add drawing statements in mydraw(), edit various icons and button operations in Dialog, and complete the creation of the field of view.
视场创建完成之后,导入绘制好的飞行器模型和仿真空间模型,包括星空和地球。通过按钮操作开启timer函数,在timer函数中创建询问网络连接代码,利用套接字实现网络通道的建立,进行数据的接收与使用。After the field of view is created, import the drawn aircraft model and simulated space model, including the starry sky and the earth. Start the timer function by button operation, create a query network connection code in the timer function, use the socket to realize the establishment of the network channel, and receive and use the data.
如图10所示,为了便于观察,在工具栏中创建一个新按钮,建立按钮相应命令,添加响应函数的类,在得到的相应函数中写入全屏显示代码。在一开始建立两个鼠标响应函数,写入响应代码,分别对应鼠标键按下与鼠标键抬起,用以打开OpenGL程序,由于还未通过定点定义图形的色彩,所以此时显示的是一个处于黑屏状态的基础软件框架。As shown in Figure 10, for the convenience of observation, create a new button in the toolbar, create the corresponding command of the button, add the class of the response function, and write the full-screen display code in the corresponding function obtained. Create two mouse response functions at the beginning, and write in the response codes, which correspond to mouse button press and mouse button lift, respectively, to open the OpenGL program. Since the color of the graphic has not been defined by fixed points, a display is displayed at this time. Basic software framework on a black screen.
OpenGL采用glColor()函数定义色彩,通过调用glColor3f(x,y,z)来定义接下来绘图使用的颜色值,函数三个值为三原色的显示矩阵。但有时显示的颜色并不能自然地表示物体的真实颜色,因此OpenGL在定义物体顶点颜色的同时引入了光照与物体材质的概念。OpenGL uses the glColor() function to define the color, and calls glColor3f(x, y, z) to define the color value used in the next drawing. The three values of the function are the display matrix of the three primary colors. But sometimes the displayed color does not naturally represent the real color of the object, so OpenGL introduces the concept of lighting and object material while defining the vertex color of the object.
OpenGL通过函数glEnable(GL_LIGHTING)来启动光照应用,通过函数 glDisable(GL_LIGHTING)来关闭光照,通过函数glLightfv(GLenum light, GLenum pname,constGLfloat*p)定义光照属性,这里使用一般的全局漫反射光照;OpenGL通过函数glMaterialfv(GLenum face,GLenum pname,const GLfloat*p)来设置材质变量,这里使用最基本的类金属材质设置。OpenGL starts the lighting application through the function glEnable(GL_LIGHTING), turns off the lighting through the function glDisable(GL_LIGHTING), and defines the lighting properties through the function glLightfv(GLenum light, GLenum pname, constGLfloat*p). Here, the general global diffuse lighting is used; OpenGL The material variable is set through the function glMaterialfv(GLenum face,GLenum pname,const GLfloat*p), and the most basic metal-like material setting is used here.
进一步,为了使图像看起来更柔和,进行反走样处理。OpenGL通过glEnable (GL_POINT_SMOOTH)来开启点的反走样,用glDisable(GL_POINT_SMOOTH)来屏蔽反走样,线和多边形对应LINE与POLYGON。Furthermore, in order to make the image look softer, anti-aliasing processing is performed. OpenGL uses glEnable (GL_POINT_SMOOTH) to enable point anti-aliasing, and glDisable (GL_POINT_SMOOTH) to block anti-aliasing. Lines and polygons correspond to LINE and POLYGON.
最后进行星球贴图设置。OpenGL通过对像素点的直接操作,并完成图像的位图操作,从而完成绘制。具体如下:OpenGL采用glReadPixels()函数读取颜色缓存中的一块图像并保存,通过glDrawPixels()函数将数组的图像绘制到屏幕光栅所在的位置,函数glCopyPixels()完成从屏幕拷贝图像到光栅所在的屏幕位置。Finally, set the planet map. OpenGL completes the drawing by directly operating on the pixels and completing the bitmap operation of the image. The details are as follows: OpenGL uses the glReadPixels() function to read and save an image in the color buffer, draws the image of the array to the position of the screen raster through the glDrawPixels() function, and the function glCopyPixels() completes copying the image from the screen to the position of the raster screen position.
(3)实时动画与仿真(3) Real-time animation and simulation
完成了仿真环境的搭建,下面进行动画与实时仿真的实现。OpenGL利用双缓存计算机绘图技术实现动画,模型变化则是通过坐标变换来实现,其过程如图8所示。After completing the construction of the simulation environment, the animation and real-time simulation will be implemented below. OpenGL uses double-buffer computer graphics technology to realize animation, and the model change is realized through coordinate transformation. The process is shown in Figure 8.
在利用坐标变换绘制图像时,可以调用glTranslate(x,y,z)函数,对模型在屏幕中显示的位置进行位移定义;调用glRotate(angle,x,y,z)函数分别表示绕x,y,z轴旋转angle角度,实现飞行器角度的控制;通过调用glScalef (a,b,c)函数表示远小近大的变化情况;通过调用 glMatrixMode(GL_PROJECTION)函数启动投影矩阵,进行投影变换,把三维坐标变换为二维屏幕坐标,将三维虚拟物体显示在电脑屏幕上,令使用者有了视距和视场的概念,观看感受更加真实;通过调用函数glViewport(0,0,cx,cy)来定义视区的范围,可以产生分屏的效果,即在同一个窗口下显示多个视区。When using coordinate transformation to draw an image, you can call the glTranslate(x,y,z) function to define the displacement of the position of the model displayed on the screen; call the glRotate(angle,x,y,z) function to represent the rotation around x and y respectively , the z-axis rotates the angle to realize the control of the aircraft angle; by calling the glScalef (a,b,c) function to indicate the change of the far and near large; by calling the glMatrixMode(GL_PROJECTION) function to start the projection matrix, perform projection transformation, and convert the The coordinates are converted into two-dimensional screen coordinates, and the three-dimensional virtual objects are displayed on the computer screen, so that users have the concept of viewing distance and field of view, and the viewing experience is more realistic; by calling the function glViewport(0,0,cx,cy) to Define the scope of the viewport, which can produce the effect of split screen, that is, display multiple viewports under the same window.
为了实现动画效果,在公共变量中加入开关变量flykey,在公共函数中加入按钮函数响应myflykey(),在myflykey()函数中添加开启系统定时器的代码 SetTimer(1,50,NULL),在按下开启键进入飞行状态后,不断地刷新定时器,再绘制出每一次刷新的图像,并利用双缓存技术,在完成屏幕更新绘制的计算后才调用SwapBuffers()函数,完成屏幕与后台缓存图像的交替显示,从而产生动画效果。In order to realize the animation effect, add the switch variable flykey to the public variable, add the button function to respond to myflykey() in the public function, add the code SetTimer(1, 50, NULL) to start the system timer in the myflykey() function, press After pressing the open button to enter the flight state, the timer is continuously refreshed, and then the image refreshed each time is drawn, and the double buffering technology is used to call the SwapBuffers() function after the calculation of the screen update drawing is completed, and the screen and the background cache image are completed. is displayed alternately, resulting in an animation effect.
对于数据的实时接收处理,首先参考前文与仿真模块建立通讯,在主程序的timer函数中加入接收数据的代码,借用主程序的循环,实时接收飞行姿态数据并进行绘图即可。For the real-time receiving and processing of data, firstly refer to the previous article to establish communication with the simulation module, add the code for receiving data in the timer function of the main program, and borrow the loop of the main program to receive the flight attitude data in real time and draw it.
本仿真平台基于Windows操作系统搭建,使用MATLAB进行飞行器模型和控制器的搭建,并进行仿真,使用C++基于VC6.0开发仿真模块,使用VC++基于 OpenGL开发视景模块,并进行联合仿真。The simulation platform is based on the Windows operating system. MATLAB is used to build the aircraft model and controller, and the simulation is carried out. C++ is used to develop the simulation module based on VC6.0, and VC++ is used to develop the visual module based on OpenGL, and the joint simulation is carried out.
三个模块使用三根以太网线连接在同一个交换机,分别在网络邻居设置本地连接的IP地址,使三个模块的IP地址在同一网段中即可。要测试这三个模块是否能通讯,在windows命令提示符中输入“ping目标IP地址”后,模块会自动进行通讯测试。The three modules are connected to the same switch using three Ethernet cables, and the IP addresses of the local connections are respectively set in the network neighbors so that the IP addresses of the three modules are in the same network segment. To test whether the three modules can communicate, after entering "ping target IP address" in the windows command prompt, the modules will automatically perform a communication test.
测试无误后,便可以启动分布式飞行器仿真平台。在客户端/服务器模式中,服务器程序必须要优先于客户端程序启动,否则将无法顺利进行通讯。因此首先要启动仿真模块和视景模块。After the test is correct, the distributed aircraft simulation platform can be started. In the client/server mode, the server program must be started prior to the client program, otherwise the communication will not be successful. So start the simulation module and the vision module first.
然后在主控模块的MATLAB命令窗口中输入下列指令:Then enter the following commands in the MATLAB command window of the main control module:
!flight_ctrl-tf inf-w&! flight_ctrl -tf inf -w &
该命令的作用是以无限运行状态打开飞行控制外部程序,程序的启停由Simulink控制。之后点击飞行控制程序Simulink模型中的连接和运行按钮。服务器程序全部启动后,相应的程序会发生阻塞直到飞行器模型通过客户端传送来数据,各程序才会继续运行下去。The function of this command is to open the flight control external program in an infinite running state, and the start and stop of the program are controlled by Simulink. Then click the Connect and Run button in the Simulink model of the flight control program. After all the server programs are started, the corresponding programs will be blocked until the aircraft model transmits data through the client, and each program will continue to run.
服务器程序全部开启后,在飞行器模型中,以正常仿真模式点击运行按钮,分布式飞行器仿真平台开始运行。仿真平台运行过程中可以通过主控模块中的暂停按钮随时暂停和继续仿真、停止按钮终止仿真。用户可以在飞行控制程序的Simulink模型中直接修改指令参数,通过外部模式实现实时在线调节飞行器状态的功能。After all the server programs are started, in the aircraft model, click the run button in the normal simulation mode, and the distributed aircraft simulation platform starts to run. During the operation of the simulation platform, the simulation can be suspended and continued at any time through the pause button in the main control module, and the stop button can terminate the simulation. Users can directly modify the command parameters in the Simulink model of the flight control program, and realize the function of real-time online adjustment of the aircraft state through the external mode.
先进行飞行器模型与控制器的离线仿真,配置与仿真平台一致。,将其作为标准与仿真平台的结果进行对比,以验证其可行性。The off-line simulation of the aircraft model and controller is carried out first, and the configuration is consistent with the simulation platform. , and compare it with the results of the simulation platform as a standard to verify its feasibility.
应当指出的是,对于本领域的普通技术人员来说,在不脱离本发明构思的前提下,还可以做出若干变形和改进,这些都属于本发明的保护范围。因此,本发明专利的保护范围应以所附权利要求为准。It should be pointed out that those skilled in the art can make several modifications and improvements without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the patent for the present invention should be based on the appended claims.
Claims (3)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910443127.3A CN110134025B (en) | 2019-05-26 | 2019-05-26 | A real-time simulation system for a small distributed hypersonic vehicle |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910443127.3A CN110134025B (en) | 2019-05-26 | 2019-05-26 | A real-time simulation system for a small distributed hypersonic vehicle |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110134025A true CN110134025A (en) | 2019-08-16 |
CN110134025B CN110134025B (en) | 2022-05-27 |
Family
ID=67581722
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910443127.3A Active CN110134025B (en) | 2019-05-26 | 2019-05-26 | A real-time simulation system for a small distributed hypersonic vehicle |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110134025B (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2021035702A1 (en) * | 2019-08-30 | 2021-03-04 | 深圳市大疆创新科技有限公司 | Application program testing method, device and storage medium |
CN113435012A (en) * | 2021-06-02 | 2021-09-24 | 上海华穗电子科技有限公司 | Distributed aircraft simulation method and device and electronic equipment |
CN113658340A (en) * | 2021-07-07 | 2021-11-16 | 中国人民解放军火箭军工程大学 | Semi-physical simulation system of hypersonic aircraft navigation and control system |
CN115222851A (en) * | 2022-07-05 | 2022-10-21 | 上海烜翊科技有限公司 | Visual simulation method, visual simulation system, computer equipment and storage medium |
CN117555252A (en) * | 2023-11-14 | 2024-02-13 | 天津大学 | Wide speed domain hypersonic aircraft control virtual simulation verification system and evaluation method |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101950157A (en) * | 2010-07-30 | 2011-01-19 | 北京航空航天大学 | Flight simulation system with high instantaneity |
CN102426424A (en) * | 2011-09-28 | 2012-04-25 | 天津大学 | Visual emulation method of near-space flying vehicle based on distributed framework |
CN102800130A (en) * | 2012-07-04 | 2012-11-28 | 哈尔滨工程大学 | Water level-close aircraft maneuvering flight visual scene simulation method |
CN103093047A (en) * | 2013-01-12 | 2013-05-08 | 天津大学 | Typical aircraft visual simulation system |
US20140172390A1 (en) * | 2010-09-08 | 2014-06-19 | The Boeing Company | Establishing availability of a two-engine aircraft for an etops flight or an etops flight path for a two-engine aircraft |
CN105159136A (en) * | 2015-07-23 | 2015-12-16 | 中国商用飞机有限责任公司北京民用飞机技术研究中心 | Flight simulation visual display method and system |
CN109709821A (en) * | 2018-11-28 | 2019-05-03 | 北京空天技术研究所 | Communication time-delay measurement method on bullet |
-
2019
- 2019-05-26 CN CN201910443127.3A patent/CN110134025B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101950157A (en) * | 2010-07-30 | 2011-01-19 | 北京航空航天大学 | Flight simulation system with high instantaneity |
US20140172390A1 (en) * | 2010-09-08 | 2014-06-19 | The Boeing Company | Establishing availability of a two-engine aircraft for an etops flight or an etops flight path for a two-engine aircraft |
CN102426424A (en) * | 2011-09-28 | 2012-04-25 | 天津大学 | Visual emulation method of near-space flying vehicle based on distributed framework |
CN102800130A (en) * | 2012-07-04 | 2012-11-28 | 哈尔滨工程大学 | Water level-close aircraft maneuvering flight visual scene simulation method |
CN103093047A (en) * | 2013-01-12 | 2013-05-08 | 天津大学 | Typical aircraft visual simulation system |
CN105159136A (en) * | 2015-07-23 | 2015-12-16 | 中国商用飞机有限责任公司北京民用飞机技术研究中心 | Flight simulation visual display method and system |
CN109709821A (en) * | 2018-11-28 | 2019-05-03 | 北京空天技术研究所 | Communication time-delay measurement method on bullet |
Non-Patent Citations (3)
Title |
---|
YU QI等: "A Model-based Fault Injection System For Aerocraft Wing Structure", 《IEEE》 * |
孙明玮 等: "飞行器定时航迹规划及其交互仿真平台设计", 《系统仿真学报》 * |
张健 等: "基于实时飞行仿真的无人机任务规划系统设计", 《数学的实践与认识》 * |
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2021035702A1 (en) * | 2019-08-30 | 2021-03-04 | 深圳市大疆创新科技有限公司 | Application program testing method, device and storage medium |
CN113435012A (en) * | 2021-06-02 | 2021-09-24 | 上海华穗电子科技有限公司 | Distributed aircraft simulation method and device and electronic equipment |
CN113435012B (en) * | 2021-06-02 | 2024-07-02 | 上海华穗电子科技有限公司 | Distributed aircraft simulation method and device and electronic equipment |
CN113658340A (en) * | 2021-07-07 | 2021-11-16 | 中国人民解放军火箭军工程大学 | Semi-physical simulation system of hypersonic aircraft navigation and control system |
CN113658340B (en) * | 2021-07-07 | 2024-01-02 | 中国人民解放军火箭军工程大学 | Semi-physical simulation system of hypersonic aircraft navigation and control system |
CN115222851A (en) * | 2022-07-05 | 2022-10-21 | 上海烜翊科技有限公司 | Visual simulation method, visual simulation system, computer equipment and storage medium |
CN115222851B (en) * | 2022-07-05 | 2024-01-26 | 上海烜翊科技有限公司 | Visual simulation method, simulation system, computer equipment and storage medium |
CN117555252A (en) * | 2023-11-14 | 2024-02-13 | 天津大学 | Wide speed domain hypersonic aircraft control virtual simulation verification system and evaluation method |
Also Published As
Publication number | Publication date |
---|---|
CN110134025B (en) | 2022-05-27 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110134025B (en) | A real-time simulation system for a small distributed hypersonic vehicle | |
JP2024505995A (en) | Special effects exhibition methods, devices, equipment and media | |
CN102651180B (en) | OSG-based (open scene graph-based) electric-electronic virtual experiment simulation system | |
CN111191374B (en) | Real-time Simulation Verification and 3D Demonstration Method of Spacecraft Attitude Stability Control | |
EP4478285A1 (en) | Image display method and apparatus, electronic device, and storage medium | |
CN109598672B (en) | Map road rendering method and device | |
WO2023207001A1 (en) | Image rendering method and apparatus, and electronic device and storage medium | |
CN105511295A (en) | STKX component-based satellite vision real-time simulation system and method thereof | |
CN102608922A (en) | Real-time visual simulation platform of photoelectric theodolite based on Vega and RTW | |
WO2023116801A1 (en) | Particle effect rendering method and apparatus, device, and medium | |
CN108335342A (en) | Method, equipment and the computer program product of more people's drawing are carried out in web browser | |
WO2005086629A2 (en) | Ingeeni flash interface | |
US20240354904A1 (en) | Effect image processing method and apparatus, electronic device, and storage medium | |
CN113253965B (en) | Mass data multi-view-port visual interaction method, system, equipment and storage medium | |
WO2023221822A1 (en) | Data processing method, electronic device, and readable storage medium | |
CN114663560A (en) | Animation realization method and device of target model, storage medium and electronic equipment | |
Fang et al. | Design and application of VR lab based on unity | |
JPH1166351A (en) | Method and device for controlling object operation inside three-dimensional virtual space and recording medium recording object operation control program | |
CN117437346A (en) | Image processing method, image processing apparatus, electronic device, storage medium, and program product | |
DeRouchey | A remote visual interface tool for simulation control and display | |
CN114815663A (en) | Spacecraft attitude simulation control method and system | |
Zhang et al. | WebGL-based virtual reality technology construction and optimization | |
KR100583238B1 (en) | 3D modeling icon controller and its method | |
Xiao et al. | Design of Hololens-based Scene System for Spacecraft Simulation | |
CN115814423A (en) | Virtual vegetation processing method and device, storage medium and electronic equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |