Robotics: Aerial Robotics 第3+4周

  • WEEK - 3
    • Quiz
    • Programming Assignment: 2-D Quadrotor Control
  • WEEK - 4
    • Quiz
    • Programming Assignment: 3-D Quadrotor Control

第1和2周在另一篇帖子下… 分开好写一点
附上链接: 1 Robotics: Aerial Robotics 第1+2周 课程学习记录及课后习题解答

此课程在Coursera需要科学上网才能观看,但是b站有人搬运,只是无中英字幕,放一下B站和Coursera的课程链接

  1. UP主 博主自己做的字幕版本(只是没更新完 而且空中机器人是打算放最后慢慢更新…)
  2. Coursera的链接介绍

建议将Coursera自身翻译的中文对着b站看,虽然视频播不了,但是能看字幕的txt文件。
此文仅为听课记录以及做题思考,可以的话我会将题目和代码题都搬运一下
VS 为视频字幕,MI为个人想法,有所错误或是好的想法欢迎评论区交流。

  • 2.7:明天开始学习并更新吧,这么一看,我进度有点迅猛…
  • 2.8:急性之下… 都看完了,感想都在文字里了… 3D的调着真累
  • 2.9:大晚上… 一看怎么这么多阅读量,感觉万一误人子弟了咋办 /狗头,终于我看懂了最后一个代码的意思了… 回来把后面补充完整(我觉得今天补充不完,最后那个轨迹的生成写起来需要时间… 所以… 大家看看注释?),顺便附上这一个单元课完结证书。然后… 发现自己的笔记都没上传(其实没啥看的,我听的也云里雾里的,论文值得一看,大家下载下来看看吧~)
  • 论文标题如下:
    1 AUTONOMOUS NAVIGATION IN COMPLEX INDOOR AND OUTDOOR
    2 INFORMATION-THEORETIC ACTIVE PERCEPTION FOR MULTI-ROBOT TEAMS
    3 Minimum Jerk Trajectory Planning for Trajectory Constrained Redun
    4 The GRASP Multiple Micro-UAV
    5 Trajectory Generation and Control for Quadrotors

WEEK - 3

Quiz

1.In the nested feedback control loop
The inner loop corresponds to orientation and the outer loop corresponds to position.

2.argminx(t)∫0T∥x(5)(t)∥2dtargmin_{x(t)}{\int\limits_0^T {\left\| {{x^{(5)}}(t)} \right\|} ^2}dtargminx(t)​0∫T​∥∥​x(5)(t)∥∥​2dt is an kkkth degree polynomial trajectory where k=k=k=
9
解释:这里的x(5)(t){{x^{(5)}}(t)}x(5)(t)也就是等于c4x4+c3x3+c2x2+c1x1+c0x0c_4x^4+c_3x^3+c_2x^2+c_1x^1+c_0x^0c4​x4+c3​x3+c2​x2+c1​x1+c0​x0所以平方后最高阶是8,再一次积分成为9所以k=9k=9k=9

3.Which of the following are simplifying assumptions we made when designing the controller in this module?
Quadrotor is near equilibrium
Angular velocities are close to zero
Roll and pitch angles are close to zero

Programming Assignment: 2-D Quadrotor Control

太认真看pdf也会… /被坑,PS题目中,pdf最后一页是,阈值小于最小值能得满分,一开始… 我以为要在那个范围内,还说,我设计的好了还不行,现在想来是有点搞笑,\笑哭。正题:两个没反应过来的点:

  • 还记得我第2周作业里说到无法得到连续时间内,所以角度求导… 是0,一开始一直没反应过来,想着怎么求这个ϕ¨c\ddot \phi_cϕ¨​c​和ϕ˙c\dot \phi_cϕ˙​c​这两个是理想情况下,他们应该都是0,也就是四旋翼没有横滚…
  • 还有就是三个!PD控制器,PD值的测试。

直接贴一下没有三个参数的代码:

%这里参数有错噢,且看下文
Kpz=50;Kvz=2;
Kpf=50;Kvf=2;
Kpy=50;Kvy=2;
%这里参数有错噢,且看下文%% 这里是公式求推理,看下文公式对应
u1=params.mass*(params.gravity+des_state.acc(2)+Kvz*(des_state.vel(2)-state.vel(2))+Kpz*(des_state.pos(2)-state.pos(2)));
fc=-(des_state.acc(1)+Kvy*(des_state.vel(1)-state.vel(1))+Kpy*(des_state.pos(1)-state.pos(1)))/params.gravity;
u2=params.Ixx*(0+Kvf*(0-state.omega)+Kpf*(fc-state.rot));
%最大的u1,u2限制
if u1>params.maxFu1=params.maxF;
end

接下来看图,仔细看图,需要的平面是y-z哦!2D的。

剩下三个公式我也直接截图pdf的贴进来了,

现在应该就能对应上代码中u1,ϕc,u2u_1,\phi_c,u_2u1​,ϕc​,u2​了,这个pdf的公式顺序如果按求的来说其实有点问题,不过大家都能看懂了。
==然后!==最磨人的来了,找3个PD控制的值!(z平面,y平面,ϕ\phiϕ角度)
首先对于跟随直线来说,z平面只要保持在z=1即可,所以测试过程中,我截几张图给大家一起分析一下:
这是我随便设的值(一般调PID都是先P后D再I,详情转PID控制器即可)

Kpz=50;Kvz=0;
Kpf=50;Kvf=0;
Kpy=50;Kvy=0;


这个状态我们可以得知:1.角度的PD控制器不行,连基本的保持0°都没有,2.z无法维持在z=1,有一点维持迹象但是又下去了,y就是… 往右状态。那么!我们应该先解决问题1,加大对角度的控制!加!

Kpz=50;Kvz=0;
Kpf=500;Kvf=0;%直接来个500
Kpy=50;Kvy=0;


是不是至少到终点了。但是!由于我们没有加微分,所以很明显右边第3幅图抖的厉害,那么,接下来就很明显了,加大Kvf使角度先稳定。
一般来说PD的倍数有时候相差几倍的,按你自己感觉来吧(这里再次:如果以前做过电设可能调这个会得心应手,一下就知道了)

Kpz=50;Kvz=0;
Kpf=500;Kvf=10;%直接来个500
Kpy=50;Kvy=0;


再一看是不是好多了,但是,咦咦咦,为啥我的小四旋翼掉下去了… 没错我们对z,y的D都没有调呢,人家只有冲上去的劲,当然无法稳定来,那就随意点,都加上D也就是Kv(z,y我都加了5)

Kpz=50;Kvz=5;
Kpf=500;Kvf=10;%直接来个500
Kpy=50;Kvy=5;


哦呦!他终于能稳稳当当的停下来,而不掉下去了,接下来又有发现问题了吧,对!角度又有抖动了->Kfv(角度的D),后面过程我就不贴图了,找到值都在最低阈值下的,直接贴了,但是大家一点要自己理解哦:(那么正确参数的完整代码,hoho)当然这个参数答案不唯一,位置误差越小越好啦~

% FILL IN YOUR CODE HERE
Kpz=80;Kvz=12;
Kpf=1000;Kvf=30;
Kpy=20;Kvy=5;
u1=params.mass*(params.gravity+des_state.acc(2)+Kvz*(des_state.vel(2)-state.vel(2))+Kpz*(des_state.pos(2)-state.pos(2)));
fc=-(des_state.acc(1)+Kvy*(des_state.vel(1)-state.vel(1))+Kpy*(des_state.pos(1)-state.pos(1)))/params.gravity;
u2=params.Ixx*(0+Kvf*(0-state.omega)+Kpf*(fc-state.rot));
%最大的u1,u2限制
if u1>params.maxFu1=params.maxF;
end

这个仅为以上参数得出的图:

误差和如下:

Line trajectory:
Cumulative position error: 0.017743Sine trajectory:
Cumulative position error: 0.081424

然后submit,把生成的.mat上传就能知道自己的分数合格啦~

WEEK - 4

Quiz

1.What sensors would you rely on for state estimation in an office building with vertical walls without too much clutter due to furniture when the lighting is poor?
IMU
Laser Scanners
解释:这些传感器的使用失效如果自己做过东西用过,就特别好悬念,例如光线暗(摄像头就不要了),垂直的墙(墙内会有钢筋影响GPS的定位,一般室内就GPS不要了…)

2.Given a desired thrust vector t=sin(30∘)cos(45∘)a1+sin(30∘)sin(45∘)a2+cos(30∘)a3t=sin(30^∘)cos(45^∘)a_1+sin(30^∘)sin(45^∘)a_2+cos(30^∘)a_3t=sin(30∘)cos(45∘)a1​+sin(30∘)sin(45∘)a2​+cos(30∘)a3​ and a desired yaw angle, ψdes=45∘ψ_{des}=45^∘ψdes​=45∘. Compute the desired rotation matrix, RdesR_{des}Rdes​.
[0.6124 -0.7071 0.3536;0.6124,0.7071,0.3536;-0.5,0,0.8866]

3.What is the rotation matrix that describes the attitude error if the current rotation matrix is given by RR and the desired rotation matrix is RdesR_{des}Rdes​
[0.6424 0.25 0.7244;-0.483 0.866 0.1294;-0.595 -0.433 0.6771]

4.What sensors are most likely to fail when operating indoors in a building with glass walls?
GPS
Laser Scanners
Cameras
解释:此处解释玻璃,反射问题所以导致激光雷达基本gg

5.What sensors are most likely to fail when the robot is flying outdoors, close to the ground near the wall of a tall building?
GPS

Programming Assignment: 3-D Quadrotor Control

直接先贴代码了,这次… 我就不演示了怎么调参的过程了… 因为没有三幅图一起看着了,PS经常坠机,主要是稳住自身的角度后,也就是Moment那块先ok,这样不容易坠机,一看这参数就是我又是P=50,D=10开调的,大家可以试试改里面的数据。接下来就是公式代码说明贴了
第一个文件:controller.m如下

% =================== Your code goes here ===================
%   state.rot = [phi; theta; psi
%   state.omega = [p; q; r]% Thrust
Kp=[500;500;500];Kd=[20;20;20];
rdes_ddot=des_state.acc+Kp.*(des_state.pos-state.pos)+Kd.*(des_state.vel-state.vel);
F=params.mass*(params.gravity+rdes_ddot(3));% Moment
M = zeros(3,1);
Kp_ang=[100;100;100];
Kd_ang=[2;2;2];
phi_des=(rdes_ddot(1)*sin(des_state.yaw)-rdes_ddot(2)*cos(des_state.yaw))/params.gravity;
theta_des=(rdes_ddot(1)*cos(des_state.yaw)+rdes_ddot(2)*sin(des_state.yaw))/params.gravity;
rot_des=[phi_des;theta_des;des_state.yaw];%角度
omega_des=[0;0;des_state.yawdot];%角速度
M=Kp_ang.*(rot_des-state.rot)+Kd_ang.*(omega_des-state.omega);if F>params.maxFF=params.maxF;
end
% =================== Your code ends here ===================

来,好好说一下,这次和上次有什么不一样呢?-> 没错!我们有好多好多的PD要调了… 示意图看一下哈:

来直接翻到文档第5页,Attitude Control的第10个公式:我懒了我都贴图吧… LATex写公式我累了…

是不是一下就明白了代码中Moment的求值公式咋来的了? -> 是的。
哦吼,那么细心的伙伴又发现!hi你的 ϕdes\phi_{des}ϕdes​ 那些咋求的呀?看到公式14a,b中:
ϕdes=1g(r¨1,dessin⁡ψT−r¨2,descos⁡ψT){\phi _{des}} = \frac{1}{g}({\ddot r_{1,des}}\sin {\psi _T} - {\ddot r_{2,des}}\cos {\psi _T})ϕdes​=g1​(r¨1,des​sinψT​−r¨2,des​cosψT​)θdes=1g(r¨1,descos⁡ψT+r¨2,dessin⁡ψT){\theta_{des}} = \frac{1}{g}({\ddot r_{1,des}}\cos{\psi _T} + {\ddot r_{2,des}}\sin{\psi _T})θdes​=g1​(r¨1,des​cosψT​+r¨2,des​sinψT​)
是不是非常舒服了 -> 是的,最后的yaw角是希望能保持原状态,也就是偏航角,转向的那个,不会导致小四旋翼坠机操作的。

那么推力又是怎么写出来的呢?emm,首先看公式11
(r¨i,T−r¨i,des)+kd,i(r˙i,T−r˙i)+kd,i(ri,T−ri)=0({\ddot r_{i,T}} - {\ddot r_{i,des}}) + {k_{d,i}}({\dot r_{i,T}} - {\dot r_i}) + {k_{d,i}}({r_{i,T}} - {r_i}) = 0(r¨i,T​−r¨i,des​)+kd,i​(r˙i,T​−r˙i​)+kd,i​(ri,T​−ri​)=0把r¨i,des\ddot r_{i,des}r¨i,des​往右边一放,是不是就是我们求rdes_ddot的等式了。
然后F的公式,显而易见… 是力学而得 F=maF=maF=ma
F=m(g+a)F=m(g+a)F=m(g+a)
而a就是我们所求的 r¨i,des\ddot r_{i,des}r¨i,des​
接下来就轮到调参了… emm 大家感觉吧,这个我就不给啥意见了,(觉得上升速度太慢就加P适当来点D不然又得炸鸡)

轮到… 我看了一下午都不知道他要我干啥的Trajectory Generation了,一句话跟大家解释一下那个部分要干啥:我要从1->2->3请问:我的2->3我不想停,怎么得到让速度继续而不导致坠机的期望状态?
然后… 我gg了,没感觉一点感觉都没有,然后上github找感觉… 然后看到大佬的(写的真复杂)ajtrask的Robotics-3D-Quadcopter-Controller/traj_generator.m
不过其实人家注释的挺详细的,就是一开始我不知道干啥,加上… 限制条件一脸懵逼,看完,觉得emm是这么回事 /笑哭,直接贴进来了哈:

persistent coef_x coef_y coef_z waypoints0 traj_time d0
if nargin > 2% setup trajectory segment timesd = waypoints(:,2:end) - waypoints(:,1:end-1);d0 = 2 * sqrt(d(1,:).^2 + d(2,:).^2 + d(3,:).^2);traj_time = [0, cumsum(d0)];waypoints0 = waypoints;% solve for coefficients in x,y,zcoef_x = getCoef(waypoints0(1,1:end)');coef_y = getCoef(waypoints0(2,1:end)');coef_z = getCoef(waypoints0(3,1:end)');else% provide the trajectory point based on the coefficientsif(t > traj_time(end))t = traj_time(end) - 0.0001;endt_index = find(traj_time >= t,1)-1; %between 1:nif (t_index == 0)t_index = 1;endif(t == 0)desired_state.pos = waypoints0(:,1);desired_state.vel = 0*waypoints0(:,1);desired_state.acc = 0*waypoints0(:,1);else%create scaled time, value between 0 to 1scale = (t-traj_time(t_index))/d0(t_index);index = (t_index-1)*8+1:t_index*8;%calculate position:t0 = polyT(8,0,scale)';desired_state.pos = [coef_x(index)'*t0; coef_y(index)'*t0; coef_z(index)'*t0];%calculate velocity:t1 = polyT(8,1,scale)';desired_state.vel = [coef_x(index)'*t1; coef_y(index)'*t1; coef_z(index)'*t1].*(1/d0(t_index));%calculate acceleration:t2 = polyT(8,2,scale)';desired_state.acc = [coef_x(index)'*t2; coef_y(index)'*t2; coef_z(index)'*t2].*(1/d0(t_index)^2);end% leave desired yaw and yawdot at zerodesired_state.yaw = 0;desired_state.yawdot = 0;
end
endfunction [T] = polyT(n, k, t)
% One utility function we are going to build to help us with the above is creating the polynom coefficient-coefficient vector (for lack of better name, these are the actual values you would put into the matrix raws).
% To understand what this mean here is an example: Lets say I want to get a vector of 8 variables (for a 7th order polynom) for the first derivative when t=1. This utility function should return a vector of: 0 1 2 3 4 5 6 7.
% When we build matrix A we will use this utility function to create those vector for us.
% n is the polynom number of coefficients, k is the requested derivative and t is the actual value of t (this can be anything, not just 0 or 1).
T = zeros(n,1);
D = zeros(n,1);% Init:
for i=1:nD(i) = i-1;T(i) = 1;
end% Derivative:
for j=1:kfor i=1:nT(i) = T(i) * D(i);if D(i) > 0D(i) = D(i) - 1;endend
end% put t value
for i=1:nT(i) = T(i) * t^D(i);
endT = T';endfunction [coef, A, b] = getCoef(waypoints)
% Creates matrix A, b and solves for the coefficient vector coef.n = size(waypoints,1)-1;% b matrix is easy, it is just the waypoints repeated in a patter
% (note waypoints is passed one component (x,y,z) at a time, so
% this function would be called three times (once for x, y, and z)
b = zeros(1,8*n);
for i=1:nb(1,i) = waypoints(i);b(1,i+n) = waypoints(i+1);
end% A matrix is built up from all the constraints
A=zeros(8*n,8*n);% Constraint 1 ==> Pi(t=0) = wi for all i=1:n
% Ex: P1(0) = w1, a11 = w1
% Ex: A(1,:)=[1 0 0 0 0 0 0 0 zero(1,8*(n-1))]
% Ex: b(1)=w1
for i=1:nA(i,((i-1)*8)+1:i*8) = polyT(8,0,0);
end% Constraint 2 ==> Pi(t=1) = wi+1 for all i=1:n
% Ex: P1(1) = w2, a11+a12+?+a18 = w2
% Ex: A(n+1,:)=[1 1 1 1 1 1 1 1 zero(1,8*(n-1))]
% Ex: b(n+1)=w2
for i=1:nA(i+n,((i-1)*8)+1:i*8) = polyT(8,0,1);
end% Constraint 3 ==> P1_k(t=0) = 0 for all k=1..3 (derivative)
% Ex: P1_1(t=0)=0, a12 = 0
% Ex: A(2*n+1,:)=[0 1 0 0 0 0 0 0 zero(1,8*(n-1))]
% Ex: b(2*n+1)=0
for k=1:3A(2*n+k,1:8) = polyT(8,k,0);
end% Constraint 4 ==> Pn_k(t=1) = 0 for all k=1..3 (derivative)
% Ex: Pn_1(t=1)=0, a12 + 2a13 + 3a14 +?+ 7a18 = 0
% Ex: A(2*n+3+1,:)=[zero(1,8*(n-1)) 0 1 2 3 4 5 6 7]
% Ex: b(2*n+3+1)=0
for k=1:3A(2*n+3+k,(end-7):end) = polyT(8,k,1);
end% Constraint 5 ==> Pi-1_k(t=1) = Pi_k(t=0) for all i=2..n and k=1..6
% Ex: P1_1(t=1)-P2_1(t=0) = 0, a12 + 2a13 +?+7a18 - a22 = 0
% Ex: A(2*n+6+1,)=[0 1 2 3 4 5 6 7 0 -1 0 0 0 0 0 0 zeros]
% Ex: b(2*n+6+1)=0
for i=2:nfor k=1:6A(2*n+6+(i-2)*6+k, (i-2)*8+1:((i-2)*8+n*n)) = [polyT(8,k,1) -polyT(8,k,0)];end
end% Now solve for the coefficients
coef = A\b';

emm 这个就不是我的代码了,我就给大家解释一通,其实看注释也可以的…(对着文档看,不然又像我这样一脸懵逼…)PS等我领会精髓看看能不能写个简单点的,感觉这个好复杂…

然后submit一下可以看到输出是否符合题目要求:

Evaluating...Line trajectory:
Cumulative position error: 0.00093411Helix trajectory:
Cumulative position error: 0.013005Test trajectory generator:
Successfully passed through 5/5 waypoints in 13.5 sec with a trajectory length of 8.443 meters

此单元课程结业啦!附上几篇论文给大家一起看吧,是视频里的推荐阅读论文,有助于理解视频内容,我一并附在资源里面吧。

1 Robotics: Aerial Robotics 第3+4周 课程学习记录及课后习题解答相关推荐

  1. 2 Robotics: Computational Motion Planning 第2+3+4周 课后习题解答

    Computational Motion Planning 第2+3+4周 2 Robotics: Computational Motion Planning WEEK - 2 Quiz Config ...

  2. 2 Robotics: Computational Motion Planning 第1周(内含Dijkstra 和 A* MATLAB代码手把手教学)课后习题解答

    首先这个系列的第一个单元是空中机器人,博客如下: 1 Robotics: Aerial Robotics 第1+2周 课程学习记录及课后习题解答 1 Robotics: Aerial Robotics ...

  3. Robotics: Aerial Robotics(空中机器人)笔记(四):无人机动力学建模

    在这一章里,我们将探索四旋翼无人机动力学的相关知识. 我将主要讲刚体动力学中的牛顿-欧拉方程以及在四旋翼无人机上的形式. 上一章链接: Robotics: Aerial Robotics(空中机器人) ...

  4. Robotics: Aerial Robotics(空中机器人)笔记(三):无人机运动学建模

    在这一章里,我们将探索四旋翼无人机的运动学原理. 这章将会讲机器人学中的坐标转换(Transformation).旋转(Rotation).欧拉角(Euler Angles).角-轴旋转表示(Axis ...

  5. Robotics: Aerial Robotics(空中机器人)笔记(二):如何设计一架四旋翼无人机

    在这一章里,我们将探索四旋翼如何飞行的. 这章将会讲一些基本的力学原理以及如何设计无人机. 上一章链接: Robotics: Aerial Robotics(空中机器人)笔记(一): Introduc ...

  6. Robotics: Aerial Robotics(空中机器人)笔记(六):无人机运动规划

    在之前的学习中我们已经讨论了如何根据给定轨迹对四旋翼进行控制,在这一章里,我们将探索四旋翼无人机在三维空间中的运动规划,即给定一个三维的环境,我们希望能够在这个三维环境中指定具体的点,进而让四旋翼无人 ...

  7. 机器学习 周志华 第一章课后习题

    机器学习 周志华 第一章课后习题 1.1 1.2 1.3 1.4 1.5 1.1 在下面这张图片中若只包含编号为1和4的两个样例,试给出相应的版本空间. 书上实例: 1.表 1.1 对应的假设空间如下 ...

  8. 20200723:198周周赛学习记录

    198周周赛 第一题:换酒问题 题目 示例 解题思路 代码实现 第二题:子树中标签相同的节点数 题目 解题思路 代码实现 第三题:最多的不重叠子字符串 题目 示例 解题思路 第四题:找到最接近目标值的 ...

  9. 周志华西瓜书课后习题答案总目录

    https://blog.csdn.net/icefire_tyh/article/details/52064910 机器学习(周志华西瓜书)参考答案总目录 从刚开始学习机器学习到现在也有几个月了,期 ...

最新文章

  1. 高频交易都有哪些著名的算法
  2. 干货 | 应用性能提升 70%,探究 mPaaS 全链路压测的实现原理和实施路径
  3. 安卓活动间的传值问题
  4. (28)FPGA面试技能提升篇(SATA接口)
  5. Qt总结之七:QPaintEvent绘制雷达图(二)
  6. keil中C语言取反操作结果是32位数
  7. 毕业论文答辩ppt怎么做?
  8. python经纬度转换xy坐标公式_经纬度坐标转换为距离及角度(Python)
  9. Qwerty Learner:为键盘工作者设计的单词记忆与英语肌肉记忆锻炼网页
  10. css参考手册css3手册_CSS手册:面向开发人员CSS便捷指南
  11. JS Date英文转中文显示
  12. adams打不开提示msc license_Adams打开出现错误提示:
  13. 怎么样在Linux上使用AppImage?
  14. Landsat5数据下载中国地区1988年
  15. 大数据运维HBase
  16. php软件测试课程资源共享网站
  17. flex布局属性的伸展、收缩、基准属性
  18. 双 JK 触发器 74LS112 逻辑功能。真值表_D触发器示例
  19. Python安装库教程(解决安装报错)
  20. 智能自动化立体库|自动化立体仓库如何进行作业配置?

热门文章

  1. 通过XML转换下载.xlsx格式的excel文件
  2. 微信小游戏-海盗来了打金初体验
  3. 地壳中元素含量排名记忆口诀_地壳中含量最多的元素是什么?地壳中元素含量排名口诀...
  4. GDOI2016 退役记
  5. Ubuntu下视频播放加速软件SMPlyer
  6. 2.20 货币兑换-设置流程
  7. 大数据可视化热门工具
  8. 【我的架构师之路】- golang源码分析之协程调度器底层实现( G、M、P)
  9. ubuntu下的截图和图像编辑软件推荐
  10. 一学就会的无代码RPA,让“高效”成为你的竞争优势