unable to run pinv (Moore Penrose) with accuracy limit
5 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(5 个)
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 个评论
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 个评论
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.
Walter Roberson
2022-2-14
I refer you back to https://www.mathworks.com/matlabcentral/answers/1648515-unable-to-run-pinv-moore-penrose-with-accuracy-limit#comment_1982890
At each step:
- 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)
- evaluate the function itself itself at the input vector
- evaluate the hessian of the function at the input vector
- use \ or pinv() to calculate the ratio -- to calculate
getting out a vector of values the same length as the vector of inputs
- subtract the result of the above step from the current guess to arrive at the updated guess
- calculate the function at the updated guess
- 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
- 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 个评论
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/905040/image.png)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!