How to plot manipulability index of a 5dof robotic arm?

18 views (last 30 days)
Anoop Kumar Sinha on 22 Jan 2021
Commented: Anoop Kumar Sinha on 15 Feb 2021
Hi communinty,
I am trying to plot the manipulability index of my robotic arm. Here is the code:
clc; clear all;close all;
syms d1 th1 th2 th3 th4 th5 a2 a3 d5
a2 = 20;
a3 = 25;
d1 = 104;
d5 = 102;
px =(cos(th1)*(a2*cos(th2)+a3*cos(th2+th3)+d5*cos(th2+th3+th4)));
py = (sin(th1)*(a2*cos(th2)+a3*cos(th2+th3)+d5*cos(th2+th3+th4)));
pz = d1-a2*sin(th2)-a3*sin(th2+th3)-d5*sin(th2+th3+th4);
% Matlab function for Jacobian Calculation
J = jacobian([px; py; pz], [th1; th2; th3; th4; th5])
J1=J';
J2=J*J1
% discretization of joint angles (in rads)
delta=5; th1=[-pi:delta:pi]; th2=[-pi:delta:pi]; th3=[-pi:delta:pi]; th4=[-pi:delta:pi];th5=[-pi:delta:pi];
for i =1:length(th1), for j=1:length(th2), for k=1:length(th3), for m=1:length(th4), for n=1:length(th5),
H(i,j,k,m,n)=sqrt(det (J2));
end; end; end; end; end;
[X,Y]=meshgrid(px,py);
mesh(X,Y,H);
title('Manipulability index H of planar 3R robot');
xlabel('px');ylabel('py');zlabel('sqrt (det J*JT)');
The error I am getting is:
Error using mesh (line 71)
Data dimensions must agree.
Error in TwoDOFFKVisualisation (line 27)
mesh(X,Y,H);
Any idea how to correct this? or any alternate idea that you can suggest?

Reshma Nerella on 31 Jan 2021
Hi,
In this line of code,
[X,Y]=meshgrid(px,py);
>> X =
cos(th1)*(102*cos(th2 + th3 + th4) + 25*cos(th2 + th3) + 20*cos(th2))
>> Y
Y =
sin(th1)*(102*cos(th2 + th3 + th4) + 25*cos(th2 + th3) + 20*cos(th2))
The output variables X, Y from meshgrid function are of type 'sym', which can not be used as input for 'mesh' function.
Mesh function can only take vectors and matrices as input arguments.
Conisder converting variables to the type the required function(mesh) can take as inputs.
For more information and examples on meshgrid and mesh functions, refer to the documentation page.
Hope this helps!
Anoop Kumar Sinha on 15 Feb 2021
Thank you Reshma