【无人船】基于模型预测控制(MPC)对USV进行自主控制(Matlab代码实现)

👨‍🎓个人主页:研学社的博客  

💥💥💞💞欢迎来到本博客❤️❤️💥💥

🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。

⛳️座右铭:行百里者,半于九十。

📋📋📋本文目录如下:🎁🎁🎁

目录

💥1 概述

📚2 运行结果

🎉3 参考文献

🌈4 Matlab代码实现


💥1 概述

  无人船(unmanned surface vehicles,USV)是一种船端无人操控的水面船舶,近年来受到了广泛关注。如何实现自主航行是USV面临的核心问题,而设计一种具有精确航迹控制能力的运动控制器是解决该问题的基础。

  本文介绍了一种模型预控制(MPC)算法,旨在自动驾驶无人水面车辆(USV)驶向一组航路点。该算法的设计被认为对海洋环境中遇到的环境扰动具有鲁棒性。USV和扰动的建模已经简化,因为这项工作旨在证明概念:对于现实世界的实施,应该考虑更准确的建模。

📚2 运行结果

主函数部分代码:

clear
close all
​
%Boat and simulation parameters
m = 37;         %Mass of the boat
D = 0.7;        %Distance between the motors and the center of mass
I = 0.1;        %Moment of inertia      (arbitrary value, should be identified)
k = 0.1;        %Viscosity coefficient  (arbitrary value, should be identified)
Tfinal = 150;   %Total simulation time
Te = 0.1;       %Sampling period
​
%Vectors used to hold simulation data
x = zeros(7, ceil(Tfinal/Te));          %State vector
u = zeros(2, ceil(Tfinal/Te));          %Input vector
delta_u = zeros(2, ceil(Tfinal/Te));    %Input increment vector
a = zeros(3, ceil(Tfinal/Te));          %State vector
i = 1;                                  %Loop index
​
​
​
%Ordered list of waypoints
x_list = [2 4 32 40 25 10 2]';  %X coordinates of the waypoints
y_list = [2 15 17 7 0 -5 2]';   %Y coordinates of the waypoints
a_list = zeros(7,1);            %Angle of the boat between two successive waypoints
current_obj = 2;                %As the boat starts in the first waypoint, the current objective is the next
                                %ie. the second waypoint
​
%Compute all the angles between two successive waypoints
%The angles returned are between -pi and pi
for j=1:7
   a_list(mod(j,7)+1,1) = angle(complex(x_list(mod(j,7)+1)-x_list(j), y_list(mod(j,7)+1)-y_list(j)));
   
   if a_list(j,1) < 0
      a_list(j,1) = a_list(j,1);
   end
end
​
%Objectives list containing X,Y and Theta coordinates
r_list = [x_list y_list a_list];
nb_obj = size(r_list,1);                %Number of objectives
​
%MPC horizons
nu = 2;         %Control horizon (dof of the optimization problem)  
ny = 30;        %Prediction horizon
​
%State-space system used for the MPC
a(:,i) = [0 0 1.4181]';                 %Initial conditions : the boat is in the correct orientation
                                        %And has null angular speed and acceleration
u(:,i) = [k/2 k/2]';                    %Initial condition on the command : to maintain a speed of 1m/s
delta_u(:,i) = [0 0]';                  %Initial condition on the input increments
​
%System matrices
A = [1  0 0;...                         %State matrix
     Te 1 0;...
     0 Te 1];
B = [D/(2*I) -D/(2*I); 0 0; 0 0];       %Input matrix
​
%Augmented system matrices
A_tilde = [A B; zeros(2,3), eye(2)];    %State matrix
B_tilde = [zeros(3,2); eye(2)];         %Input matrix
C_tilde = [0 0 1 0 0];                  %Output matrix
n_output = size(C_tilde,1);                    %Dimension of the output
n_input = size(B,2);            %Number of inputs
n_state = size(B,1);            %Number of state variables
​
%State-space system used to provide an angle reference vector
x(:,i) = [2 2 1.4181 0 0 1 0]';         %State initial condition : the boat is in the first waypoint
                                        %and correctly oriented
Fx = [1 0 0 0 0 Te*cos(x(3,i)) 0;...    %Linearized state matrix
      0 1 0 0 0 Te*sin(x(3,i)) 0;...
      0 0 1 Te 0 0 0;...
      0 0 0 1 Te 0 0;...
      0 0 0 0 1  0 0;...
      0 0 0 0 0  1 Te;...
      0 0 0 0 0 -k/m 1];
Fu = [0 0; 0 0; 0 0; 0 0;...            %Linearized input matrix               
      D/(2*I) -D/(2*I); 0 0; 1/m 1/m];
​
r = zeros(n_output*ny,1);                      %Angle reference vector
​
%Matrices used for optimization
gainS = computeGainS(n_output, 1);             %Steady-state gain
gainQ = computeGainQ(n_output, 1);             %Running cost gain on the output
gainR = computeGainR(2, 1);             %Running cost gain on the input
Qbar = computeQbar(C_tilde, gainQ, gainS, ny);
Tbar = computeTbar(gainQ, C_tilde, gainS, ny);
Rbar = computeRbar(gainR, nu);
Cbar = computeCbar(A_tilde, B_tilde, ny, nu);
Abar = computeAbar(A_tilde, ny);
Hbar = computeHbar(Cbar, Qbar, Rbar);
Fbar = computeFbar(Abar, Qbar, Cbar, Tbar);
​
%Quadprog solver options
%Keep the solver quiet
options = optimoptions('quadprog');
options = optimoptions(options, 'Display', 'off');
​
for t=0:Te:(Tfinal-1)
    a_tilde = [a(:,i); u(:,i)]; %Build the augmented state space vector for MPC
    
    %Compute the ny next angle objectives
    tmp = x(:,i);           %Get the current state
    obj = current_obj;      %Get the current objective
    
    %Compute the angle of the line between the boat and the next waypoint
    goal_angle = angle(complex(r_list(obj,1)-tmp(1,1), r_list(obj,2)-tmp(2,1)));
    
    %If the distance between the goal angle and the current angle is
    %greater than pi, it means that there is a shorter path to this angle
    %than getting all the way around the unit circle
    dist = abs(goal_angle - tmp(3,1));
    if dist > pi
        if tmp(3,1) < 0
            goal_angle = tmp(3,1) - (2*pi - dist);
        else
            goal_angle = tmp(3,1) + (2*pi - dist);
        end
    end
 

🎉3 参考文献

[1]柳晨光. 基于预测控制的无人船运动控制方法研究[D]. 武汉理工大学.

部分理论引用网络文献,若有侵权联系博主删除。

🌈4 Matlab代码实现

  • 2
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
根据引用,该论文提出了一种考虑避碰规则的复杂遭遇场景模型预测人工势场(MPAPF)运动规划方法,用于船舶运动规划。该方法通过建立一个新的船舶域和闭区间势场函数来表示船舶域的不可侵犯属性,并使用Nomoto模型生成符合船舶运动学的可遵循路径。为了解决传统人工势场(APF)方法的局部最优问题,保证复杂遭遇场景下的防撞安全,该方法将船舶运动规划问题转化为具有多重约束的非线性优化问题。仿真结果表明,该方法能够生成可行的运动路径,并避免复杂遭遇场景下的船舶碰撞。 基于以上信息,matlab船舶模型预测控制方法可以使用该论文中提出的MPAPF算法进行实现。这种算法考虑了船舶运动学、避碰规则和复杂遭遇场景下的防撞安全,并将运动规划问题转化为非线性优化问题。通过使用闭区间势场函数来表示船舶域的不可侵犯属性,并结合Nomoto模型生成可遵循路径,该算法能够生成可行的运动路径,确保船舶在复杂遭遇场景下避免碰撞。因此,使用matlab实现船舶模型预测控制可以参考该论文中所提出的MPAPF算法。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [基于模型预测人工势场的船舶运动规划方法,考虑复杂遭遇场景下的COLREG(Matlab代码实现)](https://blog.csdn.net/weixin_46039719/article/details/127776733)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *3* [使用模型预测控制USV进行自主控制Matlab代码实现)](https://blog.csdn.net/m0_73907476/article/details/130026837)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

荔枝科研社

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值