Advertisement
Guest User

Untitled

a guest
May 25th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.89 KB | None | 0 0
  1. function y  = fcn(cq,dq,x,v)
  2.     y=0;
  3.     m=0.109;
  4.     l=0.25;
  5.     g=9.8;
  6.     max=6;
  7.     xmax=0.6;
  8.     vmax=4;
  9.     % *******************************************
  10.     %能量控制策略
  11.     E=(2/3)*m*(l^2)*(dq)^2+m*g*l*(cq -1);
  12.     if (dq*cq>=0)
  13.         ue=-4.4*(E-0.21*m*g*l);
  14.     else
  15.         ue=4.4*(E-0.21*m*g*l);
  16.     end
  17.     % *******************************************
  18.     %小车位移极限
  19.     ucw = 0;
  20.     ucw = 3*sign(x)*log(abs(1-abs(x)/xmax));
  21.     % *******************************************
  22.     %小车速度极限
  23.     uvw = 0;
  24.     uvw = 3*sign(v)*log(abs(1-abs(v)/vmax));
  25.     % *******************************************
  26.     %系统能量保持
  27.     uem = 0;
  28.     uem  =-7*(exp(abs(E))-1)*sign(E)*sign(dq*cq);
  29.     % *******************************************
  30.     y=ue+uem+uvw+ucw;
  31.  
  32.     if y<-max
  33.         y=-max;
  34.     elseif y>max
  35.         y=max;
  36.     end
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement