petercorke / robotics-toolbox-matlab

Robotics Toolbox for MATLAB
GNU Lesser General Public License v2.1
1.29k stars 444 forks source link

Error using codegenerator to generate jacob0 with rpy #55

Closed santdiego closed 4 years ago

santdiego commented 5 years ago

I can not generate the Jacobian matrix of a robot with rpy representation with CodeGenerator I tried to modify line 59 of "genjacobian.m" to use rpy: J0 = CGen.rob.jacob0 (q, 'rpy'); But I get the following error when generating the Jacobian:

Conversion to logical from sym is not possible. Error in tr2rpy (line 110) if abs(abs(R(3,1)) - 1) < eps % when |R31| == 1

Error in SO3/tr2rpy (line 278) rpy = tr2rpy(obj.R, varargin{:});

Error in SerialLink/jacob0 (line 84) rpy = tr2rpy(Tn);

Error in CodeGenerator/genjacobian (line 59) J0 = CGen.rob.jacob0(q,'rpy');

It seems that the underlying problem is that the tr2rpy() function does not work with symbolic expressions, for example :

syms r p y
T=rpy2tr(r,p,y)
rpy=tr2rpy(T)

Conversion to logical from sym is not possible.

Error in tr2rpy (line 110) if abs(abs(R(3,1)) - 1) < eps % when |R31| == 1

petercorke commented 5 years ago

the algorithm contains logic not just algebra so can’t be expressed symbolically.

why do you need to use an analytic Jacobian, RPY angles is a poor representation and subject to singularity.

peter

On 11 Jun 2019, at 7:54 am, santdiego notifications@github.com wrote:

I can not generate the Jacobian matrix of a robot with rpy representation with CodeGenerator I tried to modify line 59 of "genjacobian.m" to use rpy: J0 = CGen.rob.jacob0 (q, 'rpy'); But I get the following error when generating the Jacobian:

Conversion to logical from sym is not possible. Error in tr2rpy (line 110) if abs(abs(R(3,1)) - 1) < eps % when |R31| == 1

Error in SO3/tr2rpy (line 278) rpy = tr2rpy(obj.R, varargin{:});

Error in SerialLink/jacob0 (line 84) rpy = tr2rpy(Tn);

Error in CodeGenerator/genjacobian (line 59) J0 = CGen.rob.jacob0(q,'rpy');

It seems that the underlying problem is that the tr2rpy() function does not work with symbolic expressions, for example :

syms r p y T=rpy2tr(r,p,y) rpy=tr2rpy(T) Conversion to logical from sym is not possible.

Error in tr2rpy (line 110) if abs(abs(R(3,1)) - 1) < eps % when |R31| == 1

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/petercorke/robotics-toolbox-matlab/issues/55?email_source=notifications&email_token=AC2BIUTLO4UZ3KKWZ6OBJWTPZ3ERPA5CNFSM4HWY4VS2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GYVOM6Q, or mute the thread https://github.com/notifications/unsubscribe-auth/AC2BIUTVYNMBTZCTQJX7DDLPZ3ERPANCNFSM4HWY4VSQ.