Output argument "St" (and maybe others) not assigned during call to "function ".
Show older comments
I got an error
Output argument "St" (and maybe others) not assigned during call to "get_StCarretero".
Error in InverseVelocityCarretero (line 25)
[St,p]=get_StCarretero(t,P)
Error in RK4_PhRS (line 21)
[k1,~,~,P1,~,~,~,q1] = F(t,th,P,q);
Error in CarreterosPRS_20200812_Velocity (line 24)
[JointValue,Stm,MM,Pose,G,FRK,Rd,q_out,Pd]=
RK4_PhRS(@InverseVelocityCarretero,0,ts,1,th,p,q);
when running the following program.
function [St,p] = get_StCarretero(t,pint)
ts = 1/1000;
rp=1000;
L=1000;
alpha=2*pi/3;
beta=4*pi/3;
A=cos(alpha)-cos(beta);
B=sin(alpha)-sin(beta);
C=(cos(beta)-1)/tan(beta)-(cos(alpha)-1)/tan(alpha);
z=707.1068;
if t==0
x=pint(1);
y=pint(2);
z=pint(3);
else
th=0.2*cos(2*pi*t);
psi=0.2*sin(2*pi*t);
R=A*(cos(th)-cos(psi))+B*cos(th)*sin(psi);
S=A*sin(th)*sin(psi)-B*cos(th)+C*cos(psi);
phi=atan(-R/S);
x=-rp*(cos(th)*cos(phi)+sin(psi)*sin(th)*sin(phi))*cos(alpha)-rp*(-cos(th)*sin(phi)+sin(psi)*sin(th)*cos(phi))*sin(alpha)+(rp/tan(alpha))*(cos(psi)*sin(phi)*(cos(alpha)-1)+cos(psi)*cos(phi)*sin(alpha));
y=-cos(psi)*sin(phi)*rp;
p=[x;y;z]
yaw = phi;
pitch= th;
roll = psi;
vx=diff([x])/ts;
vy=diff([y])/ts;
vz=diff([z])/ts;
droll=diff([psi0,roll])/ts;
dpitch=diff([th0,pitch])/ts;
dyaw=diff([phi0,yaw])/ts ;
JT=[cos(pitch)*cos(yaw) sin(yaw) 0; cos(pitch)*sin(yaw) cos(yaw) 0; -sin(pitch) 0 0];
omg=JT*[dpitch;droll;dyaw];
wx=omg(1);
wy=omg(2);
wz=omg(3);
St =[vx;vy;vz;wx;wy;wz];
end
end
Any help is apperciated
Thank you
9 Comments
Walter Roberson
on 17 Aug 2020
x=-rp*(cos(th)*cos(phi)+sin(psi)*sin(th)*sin(phi))*cos(alpha)-rp*(-cos(th)*sin(phi)+sin(psi)*sin(th)*cos(phi))*sin(alpha)+(rp/tan(alpha))*(cos(psi)*sin(phi)*(cos(alpha)-1)+cos(psi)*cos(phi)*sin(alpha));
That looks like a scalar. diff(x) would be empty.
To remember x y z values from previous calls see
persistent
Walter Roberson
on 22 Aug 2020
persistent old_x old_y old_z
initializing = (t == 0 || isempty(old_x));
if initializing
do whatever is appropriate for first round
old_x = x;
old_y = y;
old_z = z;
else
do whatever is appropriate for other rounds,
making use of x, y, z, and old_x, old_y, old_z
end
Walter Roberson
on 22 Aug 2020
initializing = (t == 0 || isempty(th0) || isempty(psi0) || isempty(phi0) || isempty(x0) || isempty(y0) || isempty(z0));
However, chances are you only need to test one of the variables, because you always set all of the variables after a run, so testing any one of them for emptiness should tell you whether you have already initialized.
Walter Roberson
on 22 Aug 2020
After you have done the calculations, but before you return, you need to update x0, y0, z0 with the current x, y, z.
Answers (0)
Categories
Find more on Card games in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!