“在代码的海洋里,有无尽的知识等待你去发现。我就是那艘领航的船,带你乘风破浪,驶向代码的彼岸。
💥💥💞💞欢迎来到本博客❤️❤️💥💥
🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。
⛳️座右铭:行百里者,半于九十。
📋📋📋本文目录如下:🎁🎁🎁
目录
💥1 概述
模拟无人水下航行器是一种通过软件、模型或实验装置来重现无人水下航行器运行特性和功能的方法。它旨在在无需实际部署实体航行器的情况下,对其性能、行为和在各种环境及任务中的表现进行研究和预测。 在模拟过程中,会考虑无人水下航行器的机械结构、动力系统、传感器配置、导航与控制系统等多个方面。通过输入不同的参数和条件,如水流速度、水深、任务目标等,可以模拟出航行器的运动轨迹、能源消耗、数据采集能力以及对各种突发情况的响应。 这种模拟有助于在设计阶段优化航行器的结构和性能,降低研发成本和风险。同时,也为操作人员提供训练平台,帮助他们熟悉控制流程和应对策略。此外,还能够用于评估不同的任务规划和算法,以提高无人水下航行器在实际应用中的效率和可靠性。
📚2 运行结果
部分函数代码:
clear;
N_states = 4;
N_inputs = 2;
tspan = (0:0.1:50)'; % ode time span
syms t
%%%%%%% nominal data setting (usually equilibrium) to get the linearized system
%%%%%%% and the nominal solution
% Note that X doesn't influence the states
% We have 3 system-dependent states, and 5 variables to set to get the
% desired motion. Therefore we need to set 2 parameters to get the rest of
% the steady motion states and inputs
nominal_data_setting = [1; 5]; % Set Z, u.
nominal_x0 = [0; nominal_data_setting(1); nominal_data_setting(2); 0]; % nominal initial state: X, Z, u, w
[A,B,nominal_x,nominal_input] = getLinearSys(nominal_x0,nominal_data_setting);
%%%%%%% initial states
x0 = nominal_x0;
x0(2) = x0(2)+1/3*0.05; % initial Z. Note that the vehicle height is 1/3
x0(3) = x0(3)*1.05; % initial Z. Note that the vehicle height is 1/3
%%%%%%% Control gains
%%% PID got from transfer fucntions
Ku = getPID(1,nominal_x,nominal_input);
Kw = getPID(2,nominal_x,nominal_input);
KGains = [0 0 Ku(1) 0; 0 Kw(1) 0 Kw(3)]
% solve ode of nonlinear system
UUVode = @(tt,x) systemUUV(tt,x,nominal_x,nominal_input,KGains);
[thist,xhist] = ode45(UUVode,tspan,x0);
% solve ode of linearized system
Detx0 = x0-nominal_x0;
UUVode_Linear = @(tt,Detx) systemUUVLinear(tt,Detx,A,B,KGains);
[thist_LinearDet,xhist_LinearDet] = ode45(UUVode_Linear,tspan,Detx0);
% force record. 1st row: Fu / 2nd row: Fw
forceNonlinear = repmat(nominal_input,1,length(tspan)) + KGains*(repmat(nominal_x,1,length(tspan))-xhist');
forceLinear = repmat(nominal_input,1,length(tspan)) + KGains*(0-xhist_LinearDet');
%%%%% pole placement
dampingRatio = sin(40/180*pi);
sigma = 0.5;
naturalFrequency = sigma/dampingRatio;
Frequency = sqrt(1-dampingRatio^2)*naturalFrequency;
timeConst = 5;
p = [-1/timeConst; -sigma+1i*Frequency; -sigma-1i*Frequency];
K = place(A(2:end,2:end),B(2:end,:),p);
KGains = [0 K(1,:); 0 K(2,:)]
% solve ode of nonlinear system
UUVode = @(tt,x) systemUUV(tt,x,nominal_x,nominal_input,KGains);
[thist2,xhist2] = ode45(UUVode,tspan,x0);
% solve ode of linearized system
Detx0 = x0-nominal_x0;
UUVode_Linear = @(tt,Detx) systemUUVLinear(tt,Detx,A,B,KGains);
[thist_LinearDet2,xhist_LinearDet2] = ode45(UUVode_Linear,tspan,Detx0);
% force record. 1st row: Fu / 2nd row: Fw
forceNonlinear2 = repmat(nominal_input,1,length(tspan)) + KGains*(repmat(nominal_x,1,length(tspan))-xhist2');
forceLinear2 = repmat(nominal_input,1,length(tspan)) + KGains*(0-xhist_LinearDet2');
%%%%% LQR
% equal "badness"
ZstdErr = 0.02;
ustdErr = 0.2;
wstdErr = 0.005;
Q = eye(N_states-1)*100;
Q(1,1) = Q(1,1)/ZstdErr^2;
Q(2,2) = Q(2,2)/ustdErr^2;
Q(3,3) = Q(3,3)/wstdErr^2;
🎉3 参考文献
文章中一些内容引自网络,会注明出处或引用为参考文献,难免有未尽之处,如有不妥,请随时联系删除。
[1]叶梦佳. 高速无人水下航行器运动控制系统设计与实现[D].浙江大学,2023.DOI:10.27461/d.cnki.gzjdx.2022.001512.
[2]王林. 基于多学科优化的无人水下航行器设计方法[D].汕头大学,2023.DOI:10.27295/d.cnki.gstou.2022.000220.