使用模型预测控制对USV进行自主控制(Matlab代码实现)

这篇具有很好参考价值的文章主要介绍了使用模型预测控制对USV进行自主控制(Matlab代码实现)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

    目录

💥1 概述

📚2 运行结果

🎉3 参考文献

👨‍💻4 Matlab代码

💥1 概述

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

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

📚2 运行结果

使用模型预测控制对USV进行自主控制(Matlab代码实现)

使用模型预测控制对USV进行自主控制(Matlab代码实现)

使用模型预测控制对USV进行自主控制(Matlab代码实现)

主函数部分代码:

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]. 武汉理工大学.

部分理论引用网络文献,若有侵权联系博主删除。文章来源地址https://www.toymoban.com/news/detail-407746.html

到了这里,关于使用模型预测控制对USV进行自主控制(Matlab代码实现)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 博弈论在电动车和电网系统中分布式模型预测控制研究(Matlab代码实现)

    💥💥💞💞 欢迎来到本博客 ❤️❤️💥💥 🏆博主优势: 🌞🌞🌞 博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。 ⛳️ 座右铭: 行百里者,半于九十。 📋📋📋 本文目录如下: 🎁🎁🎁 目录 💥1 概述 📚2 运行结果 🎉3 文献来源 🌈4 Matlab代码、数据、文章

    2024年02月05日
    浏览(43)
  • 【机组组合】基于数据驱动的模型预测控制电力系统机组组合优化【IEEE24节点】(Matlab代码实现)

    💥💥💞💞 欢迎来到本博客 ❤️❤️💥💥 🏆博主优势: 🌞🌞🌞 博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。 ⛳️ 座右铭: 行百里者,半于九十。 📋📋📋 本文目录如下: 🎁🎁🎁 目录 💥1 概述 📚2 运行结果 2.1 UC_original  2.2 UC_compact 2.3 SCi结果  🎉

    2024年02月07日
    浏览(42)
  • 使用大型语言模型进行自主视觉信息搜索

    推荐:使用 NSDT场景编辑器助你快速搭建3D应用场景 视觉信息寻求查询的示例,其中需要外部知识来回答问题。图像取自 OK-VQA 数据集。 在”AVIS:使用大型语言模型的自主视觉信息搜索“,我们介绍了一种新颖的方法,该方法可以在视觉信息搜索任务上实现最先进的结果。我

    2024年02月11日
    浏览(34)
  • 模型预测控制(MPC)简介及matlab实现

    全称 :Model-based Predictive Control(MPC)—模型预测控制 本质 :MPC利用一个已有的模型、系统当前的状态和未来的控制量,来预测系统未来的输出,然后与我们期望的系统输出做比较,得到代价函数,通过优化的方法,优化出未来控制量,使得代价函数最小。优化出来的控制量即

    2023年04月08日
    浏览(36)
  • 【GUI】使用PID控制器进行台式过程控制实验,以保持热敏电阻的温度(Matlab代码实现)

    目录 💥1 概述 📚2 运行结果 🎉3 参考文献 🌈4 Matlab代码、操作说明 本实验是温度控制的反馈控制应用。特别是,本实验讲解: 手动和自动控制的区别 生成动态数据的 步进测试 拟合动态数据以构建简单的一阶加死区时间 (FOPDT) 模型 从标准调整规则 获取 PID 控制的 参数

    2024年02月15日
    浏览(43)
  • MATLAB 模型预测控制(MPC)控制入门 —— 设计并仿真 MPC 控制器

    MATLAB 模型预测控制(MPC) 模型预测控制工具箱™ 提供了用于开发模型预测控制 (MPC) 的函数、应用程序、Simulink® 模块和参考示例。对于线性问题,该工具箱支持设计隐式、显式、自适应和增益调度 MPC。对于非线性问题,您可以实现单级和多级非线性 MPC。该工具箱提供可部

    2024年02月02日
    浏览(46)
  • MPC模型预测控制数学推导以及MatLab实现

    研究动机:在一定的 约束条件 下达到 最优的 系统表现。 关于最优的,举个车变道的例子,从表面上来看,轨迹1行车轨迹很平滑,很舒适,没有什么急转弯;轨迹2是快速的,但是假如前面有了障碍物,也需要一种快速的紧急避障能力,所以关于最优的,还得分析特定的情况

    2023年04月08日
    浏览(34)
  • MATLAB - 利用非线性模型预测控制(Nonlinear MPC)来控制四旋翼飞行器

    本示例展示了如何利用非线性模型预测控制(MPC)为四旋翼飞行器设计一个跟踪轨迹的控制器。 四旋翼飞行器有四个向上的旋翼。从四旋翼飞行器的质量中心出发,旋翼呈等距离的正方形排列。四旋翼飞行器动力学数学模型采用欧拉-拉格朗日方程 [1]。 四旋翼飞行器的十二种

    2024年01月22日
    浏览(60)
  • 【轨迹跟踪】模型预测控制MPC无人机轨迹跟踪【含Matlab源码 3958期】

    获取代码方式1: 完整代码已上传我的资源:【轨迹跟踪】基于matlab模型预测控制MPC无人机轨迹跟踪【含Matlab源码 3958期】 点击上面蓝色字体,直接付费下载,即可。 获取代码方式2: 付费专栏Matlab物理应用(初级版) 备注: 点击上面蓝色字体 付费专栏Matlab物理应用(初级

    2024年02月21日
    浏览(41)
  • 数学建模之灰色预测模型代码(matlab版)

    灰色关联分析步骤 【1】确定比较对象(评价对象)(就是数据,并且需要进行规范化处理,就是标准化处理,见下面例题的表格数据)和参考数列(评价标准,一般该列数列都是1,就是最优的的情况) 【2】确定各个指标权重,可用层次分析确定 【3】计算灰色关联系数 【4】

    2024年02月09日
    浏览(41)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包