RRT算法学习及MATLAB演示

文章目录

  • 1 前言
  • 2 算法简介
  • 3 MATLAB实现
    • 3.1 定义地图
    • 3.2 绘制地图
    • 3.3 定义参数
    • 3.4 绘制起点和终点
    • 3.5 RRT算法
      • 3.5.1 代码
      • 3.5.2 效果
      • 3.5.3 代码解读
  • 4 参考
  • 5 完整代码

1 前言

RRT(Rapid Random Tree)算法,即快速随机树算法,是LaValle在1998年首次提出的一种高效的路径规划算法。RRT算法以初始的一个根节点,通过随机采样的方法在空间搜索,然后添加一个又一个的叶节点来不断扩展随机树。当目标点进入随机树里面后,随机树扩展立即停止,此时能找到一条从起始点到目标点的路径。

两个代码文件见最后一节。

2 算法简介

效果预览图
在这里插入图片描述
算法的计算过程如下:
step1:初始化随机树。将环境中起点作为随机树搜索的起点,此时树中只包含一个节点即根节点;
stpe2:在环境中随机采样。在环境中随机产生一个点,若该点不在障碍物范围内则计算随机树中所有节点到的欧式距离,并找到距离最近的节点,若在障碍物范围内则重新生成并重复该过程直至找到;
stpe3:生成新节点。在和连线方向,由指向固定生长距离生成一个新的节点,并判断该节点是否在障碍物范围内,若不在障碍物范围内则将添加到随机树 中,否则的话返回step2重新对环境进行随机采样;
step4:停止搜索。当和目标点之间的距离小于设定的阈值时,则代表随机树已经到达了目标点,将作为最后一个路径节点加入到随机树中,算法结束并得到所规划的路径 。

3 MATLAB实现

3.1 定义地图

地图是模拟的栅格地图,resolution表示每个格子的长度,这里设置为1,地图范围为 x ∈ [ − 15 , 15 ] x\in[-15,15] x[15,15], y ∈ [ − 15 , 15 ] y\in[-15,15] y[15,15]。障碍物的形状为矩形,定义方式为矩形的左下角坐标及其水平长度和竖直长度。wall_obstacle位于地图边界,block_obstacle位于地图内部。

%% Define the map
resolution = 1; % resolution, cell length% Map boundaries
left_bound = -15;
right_bound = 15;
lower_bound = -15;
upper_bound = 15;% Wall obstacle [left_down_x,left_down_y,horizontal_length,vertical_length]
wall_obstacle(1,:) = [   left_bound,   lower_bound,                        1, upper_bound-lower_bound-1]; % left boundary
wall_obstacle(2,:) = [ left_bound+1,   lower_bound, right_bound-left_bound-1,                         1]; % bottom boundary
wall_obstacle(3,:) = [right_bound-1, lower_bound+1,                        1, upper_bound-lower_bound-1]; % right boundary
wall_obstacle(4,:) = [   left_bound, upper_bound-1, right_bound-left_bound-1,                         1]; % up boundary% Blcok obstacle [left_down_x,left_down_y,horizontal_length,vertical_length]
block_obstacle(1,:) = [0,-10,10,5]; % block obstacle 1
block_obstacle(2,:) = [-5,5,5,9]; % block obstacle 2
block_obstacle(3,:) = [-5,-2,5,4]; % block obstacle 3ob = [block_obstacle; wall_obstacle];

3.2 绘制地图

%% Draw the map
figure(1); % create a figure% Figure setting
set(gca,'XLim',[left_bound right_bound]); % x axis range
set(gca,'XTick',[left_bound:resolution:right_bound]); % x axis tick
set(gca,'YLim',[lower_bound upper_bound]); % y axis range
set(gca,'YTick',[lower_bound:resolution:upper_bound]); % y axis tick
grid on
axis equal
title('RRT');
xlabel('x');
ylabel('y');hold on% Draw the obstacles
for i=1:1:size(ob,1)fill([ob(i,1),ob(i,1)+ob(i,3),ob(i,1)+ob(i,3),ob(i,1)],...[ob(i,2),ob(i,2),ob(i,2)+ob(i,4),ob(i,2)+ob(i,4)],'k');
end

结果如下图所示,这里用红框标出了wall_obstacle,用绿色数字表示block_obstacle。
在这里插入图片描述

3.3 定义参数

grow_distance指新生长出的节点与其父节点的距离,这里设为1;goal_distance指的是如果新生长出的节点落在这个范围里,则认为已经到达终点;goal的位置设为 [ − 10 , − 10 ] [-10,-10] [10,10],start的位置设为 [ 13 , 10 ] [13,10] [13,10]

%% Initialize parameters
grow_distance = 1; % distance between parent node and the derived child node
goal_radius = 1.5; % can be considered as reaching the goal once within this range
% Goal point position
goal.x = -10;
goal.y = -10;
% Start point position
start.x = 13;
start.y = 10;

3.4 绘制起点和终点

%% Draw the start point and the end point
h_start = plot(start.x,start.y,'b^','MarkerFaceColor','b','MarkerSize',5*resolution);
h_goal = plot(goal.x,goal.y,'m^','MarkerFaceColor','m','MarkerSize',5*resolution);% Draw the goal circle
theta = linspace(0,2*pi);
goal_circle.x = goal_radius*cos(theta) + goal.x;
goal_circle.y = goal_radius*sin(theta) + goal.y;
plot(goal_circle.x,goal_circle.y,'--k','LineWidth',0.8*resolution);

在这里插入图片描述

3.5 RRT算法

这一部分主要是用于演示RRT算法是怎么建树,怎么到达给定终点,侧重于展示RRT的思想,如果用于工程实现,则需要用C++等高级语言重写,并且使用严谨的数据结构。

3.5.1 代码

注意需要另外写一个函数find_closet_node.m

function [angle,min_idx] = find_closet_node(rd_x,rd_y,tree)distance = [];i = 1;while i <= length(tree.child) % should not use size() functiondx = rd_x - tree.child(i).x;dy = rd_y - tree.child(i).y;distance(i) = sqrt(dx^2 + dy^2);i = i+1;end[~,min_idx] = min(distance);angle = atan2(rd_y-tree.child(min_idx).y, rd_x-tree.child(min_idx).x);
end

下面的代码承接3.4节即可

%% RRT Algorithm
% Initialize the random tree(in the form of struct)
tree.child = []; % current node
tree.parent = []; % current node's parent
tree.distance = []; % current node's distance to the starttree.child = start;
tree.parent = start;
tree.distance = 0;new_node.x = start.x;
new_node.y = start.y;goal_distance = sqrt((goal.x - new_node.x)^2 + (goal.y - new_node.y)^2);% Main loop
while goal_distance > goal_radiusrandom_point.x = (right_bound - left_bound) * rand() + left_bound; % random x value between x limitrandom_point.y = (upper_bound - lower_bound) * rand() + lower_bound; % random y value between y limithandle_1 = plot(random_point.x,random_point.y,'p','MarkerEdgeColor',[0.9290 0.6940 0.1250],'MarkerFaceColor',[0.9290 0.6940 0.1250],'MarkerSize',8*resolution); % draw the randomly generated point[angle,min_idx] = find_closet_node(random_point.x,random_point.y,tree);% pause(0.5)handle_2 = plot([tree.child(min_idx).x,random_point.x],[tree.child(min_idx).y,random_point.y],'-','Color',[0.7 0.7 0.7],'LineWidth',0.8*resolution); % draw the segment between the closest tree node and the randomly generated point% pause(0.5)new_node.x = tree.child(min_idx).x + grow_distance*cos(angle);new_node.y = tree.child(min_idx).y + grow_distance*sin(angle);handle_3 = plot(new_node.x,new_node.y,'.r','MarkerFaceColor','r','MarkerSize',10*resolution); % draw the potential new nodeflag = 1; % default: valid node% Judge if the new node is inside the obstaclestep = 0.01;if new_node.x < tree.child(min_idx).xstep = -step;endfor k=1:1:size(ob,1)for i=tree.child(min_idx).x:step:new_node.xif angle>pi/2-5e-02 && angle<pi/2+5e-02j = tree.child(min_idx).y+1;elseif angle>-pi/2-5e-02 && angle<-pi/2+5e-02j = tree.child(min_idx).y-1;elsej=tree.child(min_idx).y+(i-tree.child(min_idx).x)*tan(angle);endif i>=ob(k,1) && i<=(ob(k,1)+ob(k,3))if j >=ob(k,2) && j<=ob(k,2)+ob(k,4)flag = 0; % invalid nodebreakendendendif flag==0breakendend% pause(0.5)if flag==1tree.child(end+1) = new_node;tree.parent(end+1) = tree.child(min_idx);tree.distance(end+1) = 1 + tree.distance(min_idx);goal_distance = sqrt((goal.x - new_node.x)^2 + (goal.y - new_node.y)^2);delete(handle_3)plot(new_node.x,new_node.y,'.g','MarkerFaceColor','g','MarkerSize',10*resolution); % draw the new node% pause(0.2)plot([tree.child(min_idx).x,new_node.x],[tree.child(min_idx).y,new_node.y],'-k','LineWidth',0.8*resolution); % draw the segment between the closest tree node and the new nodeend% pause(0.5)delete(handle_1);delete(handle_2);% pause(0.5)
end

3.5.2 效果

在这里插入图片描述

3.5.3 代码解读

  • 首先是初始化一个tree结构体,含有child, parent, distance三个成员,三者均为列表。child用于存储所有节点,在相同索引位置,parent存储child的父节点,distance存储child到起点的距离(沿着树的距离,不是直线距离)。然后对这三个成员进行初始化。

    % Initialize the random tree(in the form of struct)
    tree.child = []; % current node
    tree.parent = []; % current node's parent
    tree.distance = []; % current node's distance to the starttree.child = start;
    tree.parent = start;
    tree.distance = 0;
    
  • 定义全局变量,new_node,用于存储新衍生出来的节点,用起点对其初始化。
    定义全局变量,goal_distance,用于存储new_node到终点的距离。

    new_node.x = start.x;
    new_node.y = start.y;goal_distance = sqrt((goal.x - new_node.x)^2 + (goal.y - new_node.y)^2);
    
  • 进入主循环,只要new_node尚未到达终点范围,则循环继续。

    • 每个循环中,在地图范围内生成一个随机点,然后找到距离该随机点最近的树上的节点(借助自定义函数find_closet_node实现),返回该点的索引,以及这两点连线的角度。【生成的随机点用黄色五角星表示】【随机点与最近的树上节点的连线用灰色表示】

      random_point.x = (right_bound - left_bound) * rand() + left_bound; % random x value between x limit
      random_point.y = (upper_bound - lower_bound) * rand() + lower_bound; % random y value between y limit
      handle_1 = plot(random_point.x,random_point.y,'p','MarkerEdgeColor',[0.9290 0.6940 0.1250],'MarkerFaceColor',[0.9290 0.6940 0.1250],'MarkerSize',8*resolution); % draw the randomly generated point
      [angle,min_idx] = find_closet_node(random_point.x,random_point.y,tree);% pause(0.5)
      handle_2 = plot([tree.child(min_idx).x,random_point.x],		[tree.child(min_idx).y,random_point.y],'-','Color',[0.7 0.7 0.7],'LineWidth',0.8*resolution); % draw the segment between the closest tree node and the randomly generated point
      function [angle,min_idx] = find_closet_node(rd_x,rd_y,tree)distance = [];i = 1;while i <= length(tree.child) % should not use size() functiondx = rd_x - tree.child(i).x;dy = rd_y - tree.child(i).y;distance(i) = sqrt(dx^2 + dy^2);i = i+1;end[~,min_idx] = min(distance);angle = atan2(rd_y-tree.child(min_idx).y, rd_x-tree.child(min_idx).x);
      end
      
    • 在这两点连线上,生成一个新节点,新节点与树上的节点距离为1,默认该节点是有效的,也即不会与障碍物干涉的。【新节点用红色实心点表示】

      	% pause(0.5)new_node.x = tree.child(min_idx).x + grow_distance*cos(angle);new_node.y = tree.child(min_idx).y + grow_distance*sin(angle);handle_3 = plot(new_node.x,new_node.y,'.r','MarkerFaceColor','r','MarkerSize',10*resolution); % draw the potential new nodeflag = 1; % default: valid node
      
    • 然后判断生成的新节点与树上节点的连线上的点是否位于障碍物内,也即判断新节点是否会导致路径与障碍物干涉,如果发生干涉,则把flag设置为0。

      % Judge if the new node is inside the obstacle
      step = 0.01;
      if new_node.x < tree.child(min_idx).xstep = -step;
      end
      for k=1:1:size(ob,1)for i=tree.child(min_idx).x:step:new_node.xif angle>pi/2-5e-02 && angle<pi/2+5e-02j = tree.child(min_idx).y+1;elseif angle>-pi/2-5e-02 && angle<-pi/2+5e-02j = tree.child(min_idx).y-1;elsej=tree.child(min_idx).y+(i-tree.child(min_idx).x)*tan(angle);endif i>=ob(k,1) && i<=(ob(k,1)+ob(k,3))if j >=ob(k,2) && j<=ob(k,2)+ob(k,4)flag = 0; % invalid nodebreakendendendif flag==0breakend
      end
      
    • 如果没有发生干涉,则将该点加入child列表,并将上一个点加入parent列表,该点距离起点的距离等于grow_distance加上上一个点距离起点的距离。【如果新节点在可行区域,则将该节点画为绿色】【该可行新节点与上一个节点的连线为黑色】【擦除之前生成的五角星随机点】【擦除之前五角星随机点与树上节点的连线】

      % pause(0.5)
      if flag==1tree.child(end+1) = new_node;tree.parent(end+1) = tree.child(min_idx);tree.distance(end+1) = grow_distance + tree.distance(min_idx);goal_distance = sqrt((goal.x - new_node.x)^2 + (goal.y - new_node.y)^2);delete(handle_3)plot(new_node.x,new_node.y,'.g','MarkerFaceColor','g','MarkerSize',10*resolution); % draw the new node% pause(0.2)plot([tree.child(min_idx).x,new_node.x],[tree.child(min_idx).y,new_node.y],'-k','LineWidth',0.8*resolution); % draw the segment between the closest tree node and the new node
      end% pause(0.5)
      delete(handle_1);
      delete(handle_2);
      % pause(0.5)
      

4 参考

RRT, RRT* & Random Trees
全局路径规划 - RRT算法原理及实现

5 完整代码

将下面两个文件放在同一文件夹下,运行(或分节运行)RRT_learn.m即可。此外,需要动态观察算法效果则把所有pause语句取消注释。
find_closest_node.m

function [angle,min_idx] = find_closest_node(rd_x,rd_y,tree)distance = [];i = 1;while i <= length(tree.child) % should not use size() functiondx = rd_x - tree.child(i).x;dy = rd_y - tree.child(i).y;distance(i) = sqrt(dx^2 + dy^2);i = i+1;end[~,min_idx] = min(distance);angle = atan2(rd_y-tree.child(min_idx).y, rd_x-tree.child(min_idx).x);
end

RRT_learn.m

%%
clear all
clc
%% Notification
% 1,用户自定义的内容:地图范围,障碍物数量和大小,起点和终点的位置,终点范围的阈值,RRT树生长一次的长度,和绘图相关的设置
% 2,需要演示算法效果的时候,把所有pause取消注释;不需要演示算法效果的时候,把所有pause加上注释
%% Define the map
resolution = 1; % resolution, cell lengthleft_bound = -15;
right_bound = 15;
lower_bound = -15;
upper_bound = 15;% Wall obstacle [left_down_x,left_down_y,horizontal_length,vertical_length]
wall_obstacle(1,:) = [   left_bound,   lower_bound,                        1, upper_bound-lower_bound-1]; % left boundary
wall_obstacle(2,:) = [ left_bound+1,   lower_bound, right_bound-left_bound-1,                         1]; % bottom boundary
wall_obstacle(3,:) = [right_bound-1, lower_bound+1,                        1, upper_bound-lower_bound-1]; % right boundary
wall_obstacle(4,:) = [   left_bound, upper_bound-1, right_bound-left_bound-1,                         1]; % up boundary% Blcok obstacle [left_down_x,left_down_y,horizontal_length,vertical_length]
block_obstacle(1,:) = [0,-10,10,5]; % block obstacle 1
block_obstacle(2,:) = [-5,5,5,9]; % block obstacle 2
block_obstacle(3,:) = [-5,-2,5,4]; % block obstacle 3ob = [block_obstacle; wall_obstacle];
%% Draw the map
figure(1); % create a figure% Figure setting
set(gca,'XLim',[left_bound right_bound]); % x axis range
set(gca,'XTick',[left_bound:resolution:right_bound]); % x axis tick
set(gca,'YLim',[lower_bound upper_bound]); % y axis range
set(gca,'YTick',[lower_bound:resolution:upper_bound]); % y axis tick
grid on
axis equal
title('RRT');
xlabel('x');
ylabel('y');hold on% Draw the obstacles
for i=1:1:size(ob,1)fill([ob(i,1),ob(i,1)+ob(i,3),ob(i,1)+ob(i,3),ob(i,1)],...[ob(i,2),ob(i,2),ob(i,2)+ob(i,4),ob(i,2)+ob(i,4)],'k');
end%% Initialize parameters
grow_distance = 1; % distance between parent node and the derived child node
goal_radius = 1.5; % can be considered as reaching the goal once within this range
% Goal point position
goal.x = -10;
goal.y = -10;
% Start point position
start.x = 13;
start.y = 10;
%% Draw the start point and the end point
h_start = plot(start.x,start.y,'b^','MarkerFaceColor','b','MarkerSize',5*resolution);
h_goal = plot(goal.x,goal.y,'m^','MarkerFaceColor','m','MarkerSize',5*resolution);% Draw the goal circle
theta = linspace(0,2*pi);
goal_circle.x = goal_radius*cos(theta) + goal.x;
goal_circle.y = goal_radius*sin(theta) + goal.y;
plot(goal_circle.x,goal_circle.y,'--k','LineWidth',0.8*resolution);
%% RRT Algorithm
% Initialize the random tree(in the form of struct)
tree.child = []; % current node
tree.parent = []; % current node's parent
tree.distance = []; % current node's distance to the starttree.child = start;
tree.parent = start;
tree.distance = 0;new_node.x = start.x;
new_node.y = start.y;goal_distance = sqrt((goal.x - new_node.x)^2 + (goal.y - new_node.y)^2);% Main loop
while goal_distance > goal_radiusrandom_point.x = (right_bound - left_bound) * rand() + left_bound; % random x value between x limitrandom_point.y = (upper_bound - lower_bound) * rand() + lower_bound; % random y value between y limithandle_1 = plot(random_point.x,random_point.y,'p','MarkerEdgeColor',[0.9290 0.6940 0.1250],'MarkerFaceColor',[0.9290 0.6940 0.1250],'MarkerSize',8*resolution); % draw the randomly generated point[angle,min_idx] = find_closest_node(random_point.x,random_point.y,tree);% pause(0.5)handle_2 = plot([tree.child(min_idx).x,random_point.x],[tree.child(min_idx).y,random_point.y],'-','Color',[0.7 0.7 0.7],'LineWidth',0.8*resolution); % draw the segment between the closest tree node and the randomly generated point% pause(0.5)new_node.x = tree.child(min_idx).x + grow_distance*cos(angle);new_node.y = tree.child(min_idx).y + grow_distance*sin(angle);handle_3 = plot(new_node.x,new_node.y,'.r','MarkerFaceColor','r','MarkerSize',10*resolution); % draw the potential new nodeflag = 1; % default: valid node% Judge if the new node is inside the obstaclestep = 0.01;if new_node.x < tree.child(min_idx).xstep = -step;endfor k=1:1:size(ob,1)for i=tree.child(min_idx).x:step:new_node.xif angle>pi/2-5e-02 && angle<pi/2+5e-02j = tree.child(min_idx).y+1;elseif angle>-pi/2-5e-02 && angle<-pi/2+5e-02j = tree.child(min_idx).y-1;elsej=tree.child(min_idx).y+(i-tree.child(min_idx).x)*tan(angle);endif i>=ob(k,1) && i<=(ob(k,1)+ob(k,3))if j >=ob(k,2) && j<=ob(k,2)+ob(k,4)flag = 0; % invalid nodebreakendendendif flag==0breakendend% pause(0.5)if flag==1tree.child(end+1) = new_node;tree.parent(end+1) = tree.child(min_idx);tree.distance(end+1) = 1 + tree.distance(min_idx);goal_distance = sqrt((goal.x - new_node.x)^2 + (goal.y - new_node.y)^2);delete(handle_3)plot(new_node.x,new_node.y,'.g','MarkerFaceColor','g','MarkerSize',10*resolution); % draw the new node% pause(0.2)plot([tree.child(min_idx).x,new_node.x],[tree.child(min_idx).y,new_node.y],'-k','LineWidth',0.8*resolution); % draw the segment between the closest tree node and the new nodeend% pause(0.5)delete(handle_1);delete(handle_2);% pause(0.5)
end%% Draw the final path
final_distance = tree.distance(end);
title('RRT, distance:',num2str(final_distance));current_index = length(tree.child);
while current_index ~= 1plot([tree.child(current_index).x,tree.parent(current_index).x],[tree.child(current_index).y,tree.parent(current_index).y],'-','LineWidth',1.5*resolution,'Color',[0.8500 0.3250 0.0980]); % draw the segment between the closest tree node and the new node    for i=1:length(tree.child)if tree.child(i).x == tree.parent(current_index).xif tree.child(i).y == tree.parent(current_index).ycurrent_index = i;breakendendend
end

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://xiahunao.cn/news/2804102.html

如若内容造成侵权/违法违规/事实不符,请联系瞎胡闹网进行投诉反馈,一经查实,立即删除!

相关文章

ORA-02062: distributed recovery received DBID 9ad10df5, expected 38cc1cd5

今晚做重启维护&#xff0c;发现节点二上报错如下 Fri Feb 23 21:47:43 2024 Errors in file /u01/app/oracle/diag/rdbms/orcl/orcl2/trace/orcl2_reco_58540.trc: ORA-02062: distributed recovery received DBID 9ad10df5, expected 38cc1cd5 Errors in file /u01/app/oracl…

稀疏计算、彩票假说、MoE、SparseGPT

稀疏计算可能是未来10年内最有潜力的深度学习方向之一&#xff0c;稀疏计算模拟了对人脑的观察&#xff0c;人脑在处理信息的时候只有少数神经元在活动&#xff0c;多数神经元是不工作的。而稀疏计算的基本思想是&#xff1a;在计算过程中&#xff0c;将一些不重要的参数设置为…

yolov9目标检测报错AttributeError: ‘list‘ object has no attribute ‘device‘

最近微智启软件工作室在运行yolov9目标检测的detect.py测试代码时&#xff0c;报错&#xff1a; File “G:\down\yolov9-main\yolov9-main\detect.py”, line 102, in run pred non_max_suppression(pred, conf_thres, iou_thres, classes, agnostic_nms, max_detmax_det) Fil…

基于ssm的校园帮系统设计与实现(源码+调试)

项目描述 临近学期结束&#xff0c;还是毕业设计&#xff0c;你还在做java程序网络编程&#xff0c;期末作业&#xff0c;老师的作业要求觉得大了吗?不知道毕业设计该怎么办?网页功能的数量是否太多?没有合适的类型或系统?等等。今天给大家介绍一篇基于ssm的校园帮系统设计…

一篇文章搞懂CDN加速原理

目录 一、什么是CDN CDN对网络的优化作用主要体现在以下几个方面&#xff1a; 二、CDN工作原理 CDN网络的组成元素&#xff1a; 三、名词解释 3.1 CNAME记录&#xff08;CNAME record&#xff09; 3.2 CNAME域名 3.3 DNS 3.4 回源host 3.5 协议回源 一、什么是CDN CD…

在Win11下安装pytorch3d

安装Visual Studio 安装的时候一定要选择language C。 安装成功后&#xff0c;将cl.exe的路径添加到环境变量Path中。 一般cl.exe的地址是在Microsoft Visual Studio***\VC\bin\amd64\里面。 安装依赖项 conda create -n pytorch3d python3.10 conda activate pytorch3d co…

Python实战:读取MATLAB文件数据(.mat文件)

Python实战&#xff1a;读取MATLAB文件数据(.mat文件) &#x1f308; 个人主页&#xff1a;高斯小哥 &#x1f525; 高质量专栏&#xff1a;Matplotlib之旅&#xff1a;零基础精通数据可视化、Python基础【高质量合集】、PyTorch零基础入门教程 &#x1f448; 希望得到您的订阅…

Linux设备模型(二) - kset/kobj/ktype APIs

一&#xff0c;kobject_init_and_add 1&#xff0c;kobject_init_and_add实现 /** * kobject_init_and_add() - Initialize a kobject structure and add it to * the kobject hierarchy. * kobj: pointer to the kobject to initialize * ktype: p…

【Docker快速入门】Docker部署MySQL

个人名片&#xff1a; &#x1f43c;作者简介&#xff1a;一名大三在校生&#xff0c;喜欢AI编程&#x1f38b; &#x1f43b;‍❄️个人主页&#x1f947;&#xff1a;落798. &#x1f43c;个人WeChat&#xff1a;hmmwx53 &#x1f54a;️系列专栏&#xff1a;&#x1f5bc;️…

探索D咖智能饮品机器人的工作原理:科技、材料与设计的相互融合

智能饮品机器人是近年来随着人工智能和自动化技术的发展而崭露头角的一种创新产品。它将科技、材料和设计相互融合&#xff0c;为消费者带来了全新的饮品体验。下面D咖来探索智能饮品机器人的工作原理&#xff0c;以及科技、材料和设计在其中的作用。 首先&#xff0c;智能饮品…

C 嵌入式系统设计模式 09:硬件适配器模式

本书的原著为&#xff1a;《Design Patterns for Embedded Systems in C ——An Embedded Software Engineering Toolkit 》&#xff0c;讲解的是嵌入式系统设计模式&#xff0c;是一本不可多得的好书。 本系列描述我对书中内容的理解。本文章描述访问硬件的设计模式之二&…

ctx.drawImage的canvas绘图不清晰解决方案,以及canvas高清导出

ctx.drawImage的canvas绘图不清晰 原因&#xff1a; 查资料是这么说的&#xff1a;canvas 绘图时&#xff0c;会从两个物理像素的中间位置开始绘制并向两边扩散 0.5 个物理像素。当设备像素比为 1 时&#xff0c;一个 1px 的线条实际上占据了两个物理像素&#xff08;每个像素…

如何实现一个规则研究区域内数据的提取(matlab)

在利用经验正交分解&#xff08;EOF&#xff09;进行某一个研究区域分析时&#xff0c;我们需要将研究区域转换成N*M的矩阵&#xff0c;其中N为空间维度&#xff0c;M为时间维度&#xff0c;这意味着我们之前的数据加上时间维度是三维的&#xff0c;即&#xff08;lon,lat,rg&a…

【hot100】跟着小王一起刷leetcode -- 128. 最长连续序列

【hot100】跟着小王一起刷leetcode -- 128. 最长连续序列 128. 最长连续序列题目解读关键问题代码 总结 128. 最长连续序列 题目解读 128. 最长连续序列 ok&#xff0c;兄弟们&#xff0c;咱们看这个题哈&#xff0c;还是哈希分类下&#xff0c;然后一看题目&#xff0c;居然…

C# GTS四轴运动控制器实例(固高科技步进电机不带编码器)

注&#xff1a;由于电机不带编码器&#xff0c;无法做home和当前位置信息读取&#xff01; 功能&#xff1a; 三个轴的点位运动&#xff1a;前进后退&#xff0c;并分别显示每个轴的移动脉冲数(可以换算为距离)&#xff01; 开发环境&#xff1a;VS2017 硬件设备&#xff1a;固…

【知识整理】Git Commit Message 规范

一. 概述 前面咱们整理过 Code Review 一文&#xff0c;提到了 Review 的重要性&#xff0c;已经同过gitlab进行CodeReview 的方式&#xff0c;那么本文详细说明一下对CodeReivew非常重要的Git Commit Message 规范。 我们在每次提交代码时&#xff0c;都需要编写 Commit Mes…

IOS不使用默认的mainStroryboard作为首个controller的方法

步骤1&#xff1a; 删除info.plist文件下的一条配置&#xff0c;如图 步骤2&#xff1a; 编辑AppDelegate.m&#xff0c;参考以下代码 interface AppDelegate () //property (strong, nonatomic) UIWindow * window; property(nonatomic,strong) UIWindow * win; property(…

【常用】添加作者传记,部分期刊需要例如IEEE ACCESS TCVSVT

1 添加在下面位置 \begin{IEEEbiography} [{\includegraphics[width1in,height1.25in,clip,keepaspectratio]{moumouxu.png}}] {Moumou Xu} is currently a full professor at the School of Computer and Software, Nanjing University of Information Science and Technolo…

真Unity3D编辑器Editor二次开发

IMGUI Editor Label 改变颜色 分享一个很神奇的颜色 一开始这么写&#xff0c;以为不行的&#xff0c; private void OnGUI()(){GUILayout.Label("<colorred>name:</color>ffdasilufoi");//。。。。 } 结果这么写又好了&#xff0c; private GUIStyle m…

数据湖Iceberg、Hudi和Paimon比较

1.社区发展现状 项目Apache IcebergApache HudiApache Paimon开源时间2018/11/62019/1/172023/3/12LicenseApache-2.0Apache-2.0Apache-2.0Github Watch1481.2k70Github Star5.3k4.9k 1.7k Github Fork1.9k2.3k702Github issue(Open)898481263Github issue(closed)20542410488…