Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

王老师,请教个问题,仿真报错:Index value 719 exceeds valid range [1-166] for array 'kappar'. #5

Open
LeBronUltraman opened this issue Dec 1, 2021 · 4 comments

Comments

@LeBronUltraman
Copy link

我用自己看您视频搭建的模型仿真,和下载您的模型,运行后都是同样的错误,不知道怎么调试,我在工作空间中查看kappar的值,就是1-167个值,没有看到这个719的索引,麻烦您帮忙看下,这个是报错信息:
An error occurred while running the simulation and the simulation was terminated
Caused by:
Index exceeds array dimensions. Index value 719 exceeds valid range [1-166] for array 'kappar'.
Error in 'ControlModel/Subsystem/err kappa Calculation module' (line 21)
projection_point_thetar = thetar(dmin) + kappar(dmin)*es;

@VincentWong3
Copy link
Owner

看我规划系列第二章第一节,那里有我写好的控制算法供你参考

@LeBronUltraman
Copy link
Author

看我规划系列第二章第一节,那里有我写好的控制算法供你参考
好的好的,谢谢王老师

@LeBronUltraman
Copy link
Author

LeBronUltraman commented Dec 2, 2021

王老师,我看了您的规划系列第二章第一节的视频,意识到这块的确是规划的问题,您在讲这里的时候说这个规划只是随便画一个,但是就这里的这个简单的规划,还是想请教您,我想把这块弄懂,我仔细看了这个计算方法,也自己稍微增加了一点点的修改,发现计算结果还是一样有问题,为什么同样是这样计算的,只有曲线的曲率kappar的值是1×136的,而xr,yr确是1×480的呢?是什么环节出了问题?怎么修改才能让kappar与xr,yx统一维度呢?
还请王老师不吝赐教,谢谢哈

count=60;
[x1,y1,theta1,kr1]=straight([0,0],[20,0],0,count);
[x2,y2,theta2,kr2]=arc([20,0],[30,10],0,pi/2,count);
[x3,y3,theta3,kr3]=arc([30,10],[40,20],pi/2,0,count);
[x4,y4,theta4,kr4]=arc([40,20],[40,40],0,pi,count);
[x5,y5,theta5,kr5]=arc([40,40],[35,35],pi,3pi/2,count);
[x6,y6,theta6,kr6]=arc([35,35],[5,35],3
pi/2,pi/2,count);
[x7,y7,theta7,kr7]=arc([5,35],[-35,35],pi/2,3pi/2,count);
[x8,y8,theta8,kr8]=arc([-35,35],[0,0],3
pi/2,2*pi,count);

xr=[x1,x2,x3,x4,x5,x6,x7,x8];
yr=[y1,y2,y3,y4,y5,y6,y7,y8];
thetar=[theta1,theta2,theta3,theta4,theta5,theta6,theta7,theta8];
kappar=[kr1,kr2,kr3,kr4,kr5,kr6,kr7,kr8];

scatter(xr,yr)

function [xr,yr,thetar,kr] = straight(init_coord,end_coord,init_angle,count)
delta_x = (end_coord(1) - init_coord(1))/(count-1);
delta_y = (end_coord(2) - init_coord(2))/(count-1);
for i = 1:count
xr(i) = init_coord(1) + delta_xi;
yr(i) = init_coord(2) + delta_y
i;
thetar(i) = init_angle;
kr(i) = 0;
end
end

function [xr,yr,thetar,kr] = arc(init_coord,end_coord,init_angle,end_angle,count)
L = sqrt((init_coord(1)-end_coord(1))^2 + (init_coord(2)-end_coord(2))^2);
R = L / sqrt(2*(1-cos(end_angle-init_angle)));
delta_angle = (end_angle-init_angle) / (count-1);
for i = 1:count
if delta_angle > 0
xr(i) = init_coord(1) - Rsin(init_angle) + Rsin(init_angle + delta_angle*(i-1));
yr(i) = init_coord(2) + Rcos(init_angle) - Rcos(init_angle + delta_angle*(i-1));
thetar(i) = init_angle + delta_anglei;
kr = 1/R;
else
xr(i) = init_coord(1) + R
sin(init_angle) - Rsin(init_angle + delta_angle(i-1));
yr(i) = init_coord(2) - Rcos(init_angle) + Rcos(init_angle + delta_angle*(i-1));
thetar(i) = init_angle + delta_angle*i;
kr = -1/R;
end
end
end

结果 :
kappar 1 * 136
xr 1 * 480
yr 1 * 480

@LeBronUltraman
Copy link
Author

LeBronUltraman commented Dec 3, 2021

王老师,我重新检查这个函数,发现了问题所在:
arc 函数中,for循环体中的 kr 没有循环体(i),应该修改为kr(i)=-1/R
OK,问题解决啦,还是感谢王老师哈!
您的视频真的太棒了!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants