Indexing 'fkine' matrix problem
20 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have the following code for getting a robot (x,y,z) position when running an app in AppDesigner:
addpath('C:\Program Files\MATLAB\R2023b\toolbox\rvctools');
startup_rvc;
% Links of robot
l1=0.290; l2=0.270; l3=0.070; l4=0.302; l5=0.072;
L(1)=Link([0 l1 0 -pi/2]);
L(2)=Link([0 0 l2 0]);
L(3)=Link([0 0 l3 -pi/2]);
L(4)=Link([0 l4 0 pi/2]);
L(5)=Link([0 0 0 -pi/2]);
L(6)=Link([0 l5 0 0]);
% Creation of robot
app.irb120 = SerialLink(L,'name','Robot P3', ...
'offset',[0 -pi/2 0 0 0 pi],'tool',transl(0,0,0.16));
app.q_act = [0 0 0 0 -pi/2 0];
T = app.irb120.fkine(app.q_act)
app.pos_x = T(1,4);
app.pos_y = T(2,4);
app.pos_z = T(3,4);
When I execute that, I obtain an error for the line 'app.pos_x = T(1,4);' that says:
!Error using irb120_app/robot
!Index in position 2 exceeds array bounds. Index must not exceed 1.
How could I get the last column of the T matrix and then have the position of the robot's tool?
0 Commenti
Risposte (1)
SAI SRUJAN
il 9 Nov 2023
Hi Caio,
I understand that you are facing an issue getting the last column of 'T' matrix.
The error you are encountering occurs because you are trying to access an element that exceeds the array bounds. To extract the position of the robot's tool, you need to access the last column of the matrix 'T'.
To fix the error and obtain the position, you can modify the code as follows:
app.pos_x = T(1, end);
app.pos_y = T(2, end);
app.pos_z = T(3, end);
By using 'end' instead of a specific column index, you can access the last column of the matrix, which contains the position of the robot's tool in the x, y, and z coordinates.
You can refer to the following MATLAB answer which discusses another approach to resolve the issue. This resource provides a comprehensive solution and explanation for the similar issue of indexing the ‘fkine’ matrix, allowing you to gain valuable insights on how to proceed effectively.
I hope this helps.
0 Commenti
Vedere anche
Categorie
Scopri di più su ROS Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!