1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > 【飞行器】基于matlab GUI四旋翼飞行器飞行模拟【含Matlab源码 1183期】

【飞行器】基于matlab GUI四旋翼飞行器飞行模拟【含Matlab源码 1183期】

时间:2021-04-17 14:14:07

相关推荐

【飞行器】基于matlab GUI四旋翼飞行器飞行模拟【含Matlab源码 1183期】

一、获取代码方式

获取代码方式1:

通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。

获取代码方式2:

完整代码已上传我的资源:【飞行器】基于matlab GUI四旋翼飞行器飞行模拟【含Matlab源码 1183期】

备注:

订阅紫极神光博客付费专栏,可免费获得1份代码(有效期为订阅日起,三天内有效);

二、四旋翼飞行器简介

0 引 言

四旋翼飞行器由于具有可垂直起降、机动性强、操作方便等诸多优点,在军事和民用场合得到广泛应用,从而成为众多学者的研究热点。四旋翼飞行器是具有四输入、六输出的欠驱动、非线性、强耦合系统。其姿态控制精度和抗干扰问题一直是研究重点。目前国内较普遍的飞行器控制算法主要包括:反步法、自适应控制、H控制、滑模控制、自抗扰控制等,对实现四旋翼飞行器的姿态控制具有重要的理论和实践意义。文献提出应用反步算法为飞行器上下、前后、左右、偏航4个子系统配置控制律,实现了四旋翼飞行器对设定轨迹的精确跟踪。该算法在构造Lyapunov函数的过程中,是以其导数小于零为前提,因此应用受到局限。文献针对传统的离散线性滑模应用于四旋翼飞行器控制具有跟踪误差大、响应速度慢、不能有限时间收敛等问题,提出了干扰观测器补偿的自适应离散终端滑模控制,使响应时间更快、跟踪效果更理想、鲁棒性更强。文献利用线性扩张状态观测器对四旋翼飞行器内部不确定干扰和外部干扰进行实时估计,进而采取线性状态反馈控制对扰动的估计值进行在线补偿,以实现四旋翼飞行器的姿态控制。

1 四旋翼飞行器动力学模型的建立

1. 1 四旋翼飞行器受力分析

对于飞行器的每个旋翼,剖面呈非对称,一旦旋翼旋转,由于上表面空气流速比下表面快,故上表面受到的空气压力小于下表面,上下表面受到的压差形成升力,如图1所示。旋翼1、3逆时针旋转,旋翼2、4顺时针旋转。由叶素动量理论可知,每个旋翼产生的升力Fi与电机转速ωi的平方成正比,即Fi=kFω2i(i=1,2,3,4),其中kF为升力系数。

图1 四旋翼飞行器受力分析图

当旋翼旋转时,空气阻力会阻碍其旋转。这种阻力形成施加在机体上的反扭转力矩,当4个旋翼转速相等时,旋翼产生的反扭矩作用相互抵消。四旋翼飞行器通过改变2对正反螺旋桨的转速实现对其运动控制。在4个旋翼转速相等的情况下,同时增加或者减少4个旋翼转速,可以实现飞行器上升或者下降。如果4个旋翼产生的升力之和等于机体重力,可以实现飞行器空中悬停。保持旋翼2、4的转速不变,改变旋翼1或者旋翼3的转速,飞行器在力矩l(F3-F1)或l(F1-F3)的作用下(其中l为电机轴线到飞行器中心距离),可实现俯仰运动。保持旋翼1和旋翼3的转速不变,改变旋翼2或者旋翼4的转速,飞行器在力矩l(F4-F2)或l(F2-F4)的作用下,可实现横滚运动。如果同时改变旋翼1和旋翼3的转速,或者同时改变旋翼2和旋翼4的转速,并保持飞行器总升力与机体重力相等,飞行器会在反扭矩的作用下实现偏航运动。由此可见,实现飞行器垂直运动的升力,以及实现俯仰、横滚、偏航运动的旋转力矩可以表示为

式中: F——飞行器垂直运动的升力;

Mx、My、Mz——四旋翼俯仰、横滚和偏航运动的旋转力矩;

kF——升力系数;

kM——旋转力矩系数。

1. 2 动力学模型建立

为了描述飞行器的姿态和运动状态,需要引入地理坐标系n(X,Y,Z)与载体坐标系b(x,y,z)。地理坐标系又称为东北天坐标系,载体坐标系与飞行器固连,原点为飞行器中心。将地理坐标系与载体坐标系原点重合,并将地理坐标系分别绕X、Y、Z轴旋转3次之后可得到载体坐标系,地理坐标系到载体坐标系的转换矩阵可表示为

由式(5)和式(2)可求得地理坐标系n中飞行器在X、Y、Z轴方向所受旋翼升力向量:

在低速飞行过程中,角速度矢量较小,式(8)中左边第二项可近似认为为零,则式(8)可化简为

将式(10)转换可得:

由式(7)和式(11)可得四旋翼飞行器在低速飞行情况下的非线性动力学模型:

由式(12)可知,四旋翼飞行器线运动不影响角运动,但是角运动会影响线运动。以u1、u2、u3、u4为系统输入,通过改变这4个输入变量的值,可以改变飞行器的3个线位移和3个角位移,从而实现对飞行器的运动控制。

2 四旋翼飞行器的控制系统构建与仿真

经典PID算法结构简单,基于偏差设计反馈律,不依赖受控对象的具体数学模型,在很多过程控制中均有良好表现。尽管各种新的控制算法不断涌现,但是并没有改变PID控制算法在工业控制中的主导地位。本文根据四旋翼在飞行过程中经常会遇到不确定外界干扰等情况,设计了基于小扰动的PID控制器,如图2所示。

图2 PID控制器结构图

三、部分源代码

function varargout = GUI_Config(varargin)% GUI_CONFIG MATLAB code for GUI_Config.fig%GUI_CONFIG, by itself, creates a new GUI_CONFIG or raises the existing%singleton*.%%H = GUI_CONFIG returns the handle to a new GUI_CONFIG or the handle to%the existing singleton*.%%GUI_CONFIG('CALLBACK',hObject,eventData,handles,...) calls the local%function named CALLBACK in GUI_CONFIG.M_VALUE with the given input arguments.%%GUI_CONFIG('Property','Value',...) creates a new GUI_CONFIG or raises the%existing singleton*. Starting from the left, property value pairs are%applied to the GUI before GUI_Config_OpeningFcn gets called. An%unrecognized property name or invalid value makes property application%stop. All inputs are passed to GUI_Config_OpeningFcn via varargin.%%*See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one%instance to run (singleton)".%% See also: GUIDE, GUIDATA, GUIHANDLES% Edit the above text to modify the response to help GUI_Config% Last Modified by GUIDE v2.5 26-Nov- 18:35:51% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ...'gui_Singleton', gui_Singleton, ...'gui_OpeningFcn', @GUI_Config_OpeningFcn, ...'gui_OutputFcn', @GUI_Config_OutputFcn, ...'gui_LayoutFcn', [] , ...'gui_Callback', []);if nargin && ischar(varargin{1})gui_State.gui_Callback = str2func(varargin{1});endif nargout[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});elsegui_mainfcn(gui_State, varargin{:});end% End initialization code - DO NOT EDIT% --- Executes just before GUI_Config is made visible.function GUI_Config_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin command line arguments to GUI_Config (see VARARGIN)% Choose default command line output for GUI_Confighandles.output = hObject;% Update handles structureguidata(hObject, handles);set(handles.progresslabel,'String','未开始仿真');% UIWAIT makes GUI_Config wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = GUI_Config_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT);% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Get default command line output from handles structurevarargout{1} = handles.output;function m_value_Callback(hObject, eventdata, handles)% hObject handle to m_value (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of m_value as text% str2double(get(hObject,'String')) returns contents of m_value as a double% --- Executes during object creation, after setting all properties.function m_value_CreateFcn(hObject, eventdata, handles)% hObject handle to m_value (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns calledset(hObject,'String','');% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunction g_value_Callback(hObject, eventdata, handles)% hObject handle to g_value (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of g_value as text% str2double(get(hObject,'String')) returns contents of g_value as a double% --- Executes during object creation, after setting all properties.function g_value_CreateFcn(hObject, eventdata, handles)% hObject handle to g_value (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns calledset(hObject,'String','');% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunction L_value_Callback(hObject, eventdata, handles)% hObject handle to L_value (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of L_value as text% str2double(get(hObject,'String')) returns contents of L_value as a double% --- Executes during object creation, after setting all properties.function L_value_CreateFcn(hObject, eventdata, handles)% hObject handle to L_value (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns calledset(hObject,'String','');% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunction Ixx_value_Callback(hObject, eventdata, handles)% hObject handle to Ixx_value (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of Ixx_value as text% str2double(get(hObject,'String')) returns contents of Ixx_value as a double% --- Executes during object creation, after setting all properties.function Ixx_value_CreateFcn(hObject, eventdata, handles)% hObject handle to Ixx_value (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns calledset(hObject,'String','');% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunction Iyy_value_Callback(hObject, eventdata, handles)% hObject handle to Iyy_value (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of Iyy_value as text% str2double(get(hObject,'String')) returns contents of Iyy_value as a double% --- Executes during object creation, after setting all properties.function Iyy_value_CreateFcn(hObject, eventdata, handles)% hObject handle to Iyy_value (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns calledset(hObject,'String','');% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunction Izz_value_Callback(hObject, eventdata, handles)% hObject handle to Izz_value (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of Izz_value as text% str2double(get(hObject,'String')) returns contents of Izz_value as a double% --- Executes during object creation, after setting all properties.function Izz_value_CreateFcn(hObject, eventdata, handles)% hObject handle to Izz_value (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns calledset(hObject,'String','');% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');end% --- Executes on button press in structParamClear.function structParamClear_Callback(hObject, eventdata, handles)% hObject handle to structParamClear (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)set(handles.m_value,'String','');set(handles.g_value,'String','');set(handles.L_value,'String','');set(handles.Ixx_value,'String','');set(handles.Iyy_value,'String','');set(handles.Izz_value,'String','');% --- Executes on button press in structParam_Default.function structParam_Default_Callback(hObject, eventdata, handles)% hObject handle to structParam_Default (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)set(handles.m_value,'String','0.5');set(handles.g_value,'String','9.8');set(handles.L_value,'String','0.2');set(handles.Ixx_value,'String','0.114');set(handles.Iyy_value,'String','0.114');set(handles.Izz_value,'String','0.158');set(handles.progresslabel,'String','结构参数使用默认参数');function xt_value_Callback(hObject, eventdata, handles)% hObject handle to xt_value (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of xt_value as text% str2double(get(hObject,'String')) returns contents of xt_value as a double% --- Executes during object creation, after setting all properties.function xt_value_CreateFcn(hObject, eventdata, handles)% hObject handle to xt_value (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns calledset(hObject,'String','');% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunction yt_value_Callback(hObject, eventdata, handles)% hObject handle to yt_value (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of yt_value as text% str2double(get(hObject,'String')) returns contents of yt_value as a double% --- Executes during object creation, after setting all properties.function yt_value_CreateFcn(hObject, eventdata, handles)% hObject handle to yt_value (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns calledset(hObject,'String','');% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');end

四、运行结果

五、matlab版本及参考文献

1 matlab版本

a

2 参考文献

[1] 包子阳,余继周,杨杉.智能优化算法及其MATLAB实例(第2版)[M].电子工业出版社,.

[2]张岩,吴水根.MATLAB优化算法源代码[M].清华大学出版社,.

[3]张萍.四旋翼飞行器姿态控制建模与仿真[J].电机与控制应用. ,46(12)

[4]刘岩,杨牧.四旋翼飞行器飞行控制系统研究与设计[J].山东工业技术. ,(07)

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。