フィルターのクリア

unable to run pinv (Moore Penrose) with accuracy limit

3 ビュー (過去 30 日間)
Ken
Ken 2022 年 2 月 12 日
編集済み: Ken 2022 年 3 月 12 日
I am trying to use pinv to allow a robot system to converge.I tried but get errors. This is my script stateent :
dq=double(pinv(X)*(rGoal-r0),1e-4)
where X is the M.Penrose Jacobian; I am trying to minimize (rGoal-r0) to a tolerance of 1e-4

回答 (5 件)

John D'Errico
John D'Errico 2022 年 2 月 12 日
編集済み: John D'Errico 2022 年 2 月 12 日
What do you think the 1e-4 applies to?
dq=double(pinv(X)*(rGoal-r0),1e-4)
Do you think this is a tolerance for pinv? If so, then where did you put it, with respect to the parens? Yes, pinv takes a tolerance, used to define the cutoff on the SVD. But to use that, you need to pass the tolerance into pinv. As it is, you are passing this as a second argument to the function double. And double does not take a second argument.
So you MIGHT have done this instead:
dq=double(pinv(X,1e-4)*(rGoal-r0))
Does that do what you want? I'm not sure, since this is not really how pinv works. It does not do any explicit minimization of your objective, so it will not give you a result that is accurate to your desired tolerance. As such, you may be misusing the tolerance on pinv. But that is your choice to make, not mine.
  4 件のコメント
Ken
Ken 2022 年 2 月 12 日
Thanks. Tried it i.e. dq=double(pinv(X,1e-4)*(rGoal-r0));
get error: Too many input arguments.
Walter Roberson
Walter Roberson 2022 年 2 月 12 日
That would happen if your X is symbolic.

サインインしてコメントする。


Walter Roberson
Walter Roberson 2022 年 2 月 12 日
double() does not have any way of applying a tolerance. The tolerance has to be applied at the pinv() level. And whatever tolerance you use will be multiplied by (rGoal-r0) .
Suppose your tolerance for pinv() was 1e-7, but your (rGoal-r0) is 10000, then the uncertainty in the pinv() [because of the tolerance] times 10000 would be 1e-7 * 1e4 --> 1e-3 --- and you would have exceeded your tolerance budget for the overall system.
So you need to calculate
b = (rGoal-r0);
tolerance = 1e-4/max(abs(b),1);
dq = pinv(X, tolerance) * b;
  12 件のコメント
Ken
Ken 2022 年 2 月 13 日
Derivatives wrt q (3X1 matrix) which is the angular displacement of the robot arms wrt to each other. q0 =pi/180*(0,-30,60)'
Walter Roberson
Walter Roberson 2022 年 2 月 13 日
編集済み: Walter Roberson 2022 年 2 月 13 日
You have a 3 x 3 matrix. The derivative of a 3 x 3 matrix will respect to three variables would give you something that was 3 x 3 x 3.
If J_BF_inB is already the derivative, then you need the original function as well in the computation.

サインインしてコメントする。


Ken
Ken 2022 年 2 月 13 日
編集済み: Walter Roberson 2022 年 2 月 23 日
I think the NRaphson is overkill for this, so will go with your code posted at 5PM yesterday:
b = (rGoal-r0 );
tolerance = 1e-4/max(abs(b),1 );
DQ = pinv(X, tolerance) * b ;
newDQ = pinv(J_BF_inB)*b;
if dq >= 1e-4
q = q + DQ;
dq = newDQ;
if newDQ >= 1e-4
q = sign(newDQ) * inf;
pause(inf)
end
end
Why? Because
ThemeCopy
while newDQ >= 1e-4
q = q + newDQ;
end
It gives me error: "Error using svd
First input must be single or double.
Error in solution (line 25)
dq=pinv(J_BF_inB)*b;"
  20 件のコメント
Ken
Ken 2022 年 2 月 24 日
Thanks. Still error but now reduced to .38372.
while any(dq >= tolerance)
q(1)=q(1)+1e-4;
q(2)=q(2)+1e-4;
q(3)=q(3)+1e-4;
dq=pinv(J_BF_inB(q(1),q(2),q(3)))*b;
q=q+dq;
dr=J_BF_inB(q(1),q(2),q(3))*dq;
r=r+dr;
b=rGoal-r;
end
Ken
Ken 2022 年 2 月 25 日
Made some slight changes but the error b diverges instead of converging:
while n<5
dq=pinv(J_BF_inB(q(1),q(2),q(3)))*b;
q=q+dq;
dr=J_BF_inB(q(1),q(2),q(3))*dq;
r=r+dr;
b=rGoal-r;
n=n+1;
end

サインインしてコメントする。


Walter Roberson
Walter Roberson 2022 年 2 月 14 日
At each step:
  1. arrange an input vector of data (this might have already been set up in previous steps, but might for example involve putting a series of indivdual values together into a vector)
  2. evaluate the function itself itself at the input vector
  3. evaluate the hessian of the function at the input vector
  4. use \ or pinv() to calculate the ratio -- to calculate getting out a vector of values the same length as the vector of inputs
  5. subtract the result of the above step from the current guess to arrive at the updated guess
  6. calculate the function at the updated guess
  7. if the absolute value of the function at the updated guess is less than tolerance, leave the loop, and otherwise go back to step 1
  8. If appropriate, unpack the current guess into the destination variables
If you do a small bit of extra setup before step 1, then you can merge step 2 and step 6.
For the purpose of the above, it does not matter whether you evaluate the function or the hessian by using subs() into a symbolic expression, or invoking a previously-defined function handle with the appropriate inputs, as long as you do the right thing for your representation of the function or hessian.
  3 件のコメント
Ken
Ken 2022 年 2 月 23 日
After a few weeks and back / forth on this Q & A site, I am not much closer to understanding/solving this problem!
Walter Roberson
Walter Roberson 2022 年 2 月 24 日
Okay, so it seems to me that pinv(J_BF_inB(alpha,beta,gamma))*(rGoal-r0) is the function that you want to find the zero of. So use the Symbolic Toolbox (or hand calculations) and multiply that out, to get a vector of three values, each of which is a sum of trig terms. For the moment I will call that f . Now take the derivatives of JB with respect to alpha, beta, gamma, creating the Hessian; call that . Now follow the steps described above https://www.mathworks.com/matlabcentral/answers/1648515-unable-to-run-pinv-moore-penrose-with-accuracy-limit#answer_895320

サインインしてコメントする。


Ken
Ken 2022 年 3 月 9 日
編集済み: Ken 2022 年 3 月 11 日
Still not able to get this to converge. Problem is not sure whether to state a tolerance limit i.e. the foot should be in the goal position with a tolerance or should I iteratively determine if the angle change with each iteration is so small that it has effectively converged (chicken and egg?)
  1 件のコメント
Ken
Ken 2022 年 3 月 12 日
編集済み: Ken 2022 年 3 月 12 日
It compiles OK. Just the tolerance is out of whack.
while sqrt(dr(1)*dr(1)+dr(2)*dr(2)+dr(3)*dr(3)) >= tolerance
dq=pinv(J_BF_inB(q(1),q(2),q(3)))*b;
q(1)=q(1)+1e-6;
q(2)=q(2)+1e-6;
q(3)=q(3)+1e-6;
b=rGoal-r;
if b<0
q=q-dq;
else
q=q+dq;
q=q+dq;
dr=J_BF_inB(q(1),q(2),q(3))*dq;
if dr<0
r=r-dr;
else
r=r+dr;
end
end
end
end
qGoal=q;

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by