(三)抛物线过渡的线性函数规划
前面说到,无论是三次还是五次多项式进行规划存在以下缺点:
- 位移往返
- 没有匀速段
这一节中,我们的研究对象是初速度和末速度都为0关节运动。
一、无过渡线性函数
假设时刻 t t t和角度 θ \theta θ是线性关系,其系数为 v v v,有:
θ ( t ) = v ∗ t \theta(t)=v*t θ(t)=v∗t
在整一段运动中,其速度恒定为 v v v,假设在这段运动前的速度为 v p r e v_{pre} vpre,如果速度差 Δ v = v − 0 = v ≠ 0 \Delta v=v-0=v\not=0 Δv=v−0=v=0,根据加速度计算公式,在一个极短的时间 Δ t \Delta t Δt有:
a = Δ v / Δ t = ∞ a=\Delta v/\Delta t=\infty a=Δv/Δt=∞

二、抛物线拟合的线性函数
为了避免端点处加速度的"冲击",在运动的起末两点采用用两段抛物线进行平滑地改变速度大小。记两端待求抛物线的时间为 t b t_b tb,总持续时间为 t t t,加速度为 a a a,速度从零变化到匀速 v v v,起末角为 θ 0 \theta_0 θ0和 θ f \theta_f θf,作出关节的角速度曲线:

红色面积代表运动的角度变化量即 θ f − θ 0 \theta_f-\theta_0 θf−θ0,有梯形面积公式有: S r e d = ( t − 2 t b + t ) ⋅ a ⋅ t b / 2 S_{red}=(t-2t_b+t)\cdot a\cdot t_b/2 Sred=(t−2tb+t)⋅a⋅tb/2,整理得:
a ⋅ t b 2 − a ⋅ t ⋅ t b + θ f − θ 0 = 0 a\cdot t_b^2-a\cdot t\cdot tb+\theta_f-\theta_0=0 a⋅tb2−a⋅t⋅tb+θf−θ0=0
二次方程有解的条件是: Δ = a 2 t 2 − 4 a ( θ f − θ 0 ) ≥ 0 \Delta=a^2t^2-4a(\theta_f-\theta_0)\ge0 Δ=a2t2−4a(θf−θ0)≥0,即加速度需要满足 a ≥ 4 ( θ f − θ 0 ) / t 2 a\ge4(\theta_f-\theta_0)/t^2 a≥4(θf−θ0)/t2,对应的解 t b = t / 2 − ( a 2 t 2 − 4 a ( θ f − θ 0 ) ) / 2 a t_b=t/2-\sqrt{(a^2t^2-4a(\theta_f-\theta_0))}/2a tb=t/2−(a2t2−4a(θf−θ0))/2a
三、Matlab验证程序
% Velocity plan according accelerate
% duration: total time of the motionfunction [real_a,line_v,line_duration]=plan(set_a,delta_x,duration)while(1)min_acc=4*delta_x/(duration^2); %minimun accif set_a<min_accduration=duration+0.5;elsereal_a=set_a;break;endendtb=duration/2-sqrt(real_a^2*duration^2-4*real_a*(delta_x))/(2*real_a);line_duration=duration-2*tb;line_v=real_a*tb;
endfunction x=move(start_x,end_x,ts,te,t,set_a)duration=te-ts;delta_x=end_x-start_x;[real_a,line_v,line_durasion]=plan(set_a,delta_x,duration);acc_duration=(duration-line_durasion)/2;tt=t-ts;if tt>=0&&tt<=acc_durationdx=1/2*real_a*tt^2;elseif tt>acc_duration&&tt<line_durasion+acc_durationdx=1/2*real_a*acc_duration^2+line_v*(tt-acc_duration);elsedx=1/2*real_a*acc_duration^2+line_v*line_durasion+(line_v*(tt-acc_duration-line_durasion)-1/2*real_a*(tt-acc_duration-line_durasion)^2);endx=start_x+dx;
endclear;
clc;
close all;ts=5;
te=10;
theta1=5;
theta2=185;h = figure(1);
axis tight manual % this ensures that getframe() returns a consistent size
filename = 'testAnimated.gif';
for set_a=50:50:1500theta=[]for t=ts:0.01:tetheta=[theta,move(theta1,theta2,ts,te,t,set_a)];end% figure(1);t=ts:0.01:te;subplot(3,1,1);plot(t,theta,'r','LineWidth',1.2);ylabel('position')subplot(3,1,2);plot(t(1:end-1),diff(theta/0.01),'g','LineWidth',1.2);ylabel('velocity')subplot(3,1,3);plot(t(1:end-2),diff(diff(theta/0.01)),'b','LineWidth',1.2);ylabel('acceleration') xlabel('time(t/s)')drawnow% Capture the plot as an imageframe = getframe(h);im = frame2im(frame);[imind,cm] = rgb2ind(im,256);% Write to the GIF Fileif set_a==50imwrite(imind,cm,filename,'gif', 'Loopcount',inf);elseimwrite(imind,cm,filename,'gif','WriteMode','append');end
end
仿真的结果如下:

随着加速度的增加,角位移的曲线逐渐变成线性,同时所需要的加速度也随之增加。
总结
为了防止起始和末端点速度的“冲击”,我们在两端添加两段抛物线进行过渡,抛物线加速度有最小值 4 ( θ f − θ 0 ) / t 2 4(\theta_f-\theta_0)/t^2 4(θf−θ0)/t2,对于确定的加速度 a a a对应的过渡时间 t b tb tb也相应确定,其大小为: t b = t / 2 − ( a 2 t 2 − 4 a ( θ f − θ 0 ) ) / 2 a t_b=t/2-\sqrt{(a^2t^2-4a(\theta_f-\theta_0))}/2a tb=t/2−(a2t2−4a(θf−θ0))/2a,相对于多项式插补,梯形规划方式既有匀速段且位置没有往返。
[1] M. G , Rodd. Introduction to robotics: Mechanics and control: John J. Craig[J]. Automatica, 1987.
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
