Code Generated Blocks for Seriallink return error "Index expression out of bounds" - Peter Corke Robotics Toolbox
Show older comments
Hi, I am trying to simulate a Seriallink manipulator in Simulink, and am attempting to solve for the coriolis matrix at a current configuration and velocity. For this I have decided to use the Peter Corke Robotics toolbox as I saw in the docs that it supports code generation. In fact, it has the capability to generate blocks for direct use in simulink (as stated in the following link: https://www.petercorke.com/RTB/r9/html/CodeGenerator.html):
% The Simulink block library containing robot-specific blocks can be
% opened by
open robot/robotslib.slx
% and the blocks dragged into your own models.
This is the Seriallink manipulator and code generation .m file.
%mod DH
% Peter corkes: theta, d, a, alpha
dhparams = [0 0 0 pi/2;
0 0 0 pi/2;
0 0 0.5 -pi/2;
0 0 0.5 0];
L(1) = Link(dhparams(1,:), 'modified');
L(1).m = 0.5; %mass
L(1).r = [0 0 0]; %COM
L(1).I = [1 0 0;
0 1 0;
0 0 1];
L(1).Jm = 0; % this is motor inertia
L(2) = Link(dhparams(2,:), 'modified');
L(2).m = 1; %mass
L(2).r = [0.325 0 0]; %COM
L(2).I = [1 0 0;
0 1 0;
0 0 1];
L(2).Jm = 0;
L(3) = Link(dhparams(3,:), 'modified');
L(3).m = 1; %mass
L(3).r = [0.2175 0 0]; %COM
L(3).I = [1 0 0;
0 1 0;
0 0 1];
L(3).Jm = 0;
T_tool = [1 0 0 0.5;
0 1 0 0;
0 0 1 0;
0 0 0 1];
myrobot2 = SerialLink(L, 'name', 'myrobot2', 'gravity',[0,0,-9.81], 'tool', T_tool); %gravity compensated
myrobot2 = myrobot2.nofriction('all');
% and to generate all the Simulink blocks
cg = CodeGenerator(myrobot2);
cg.geneverything();
This generates a .slx (Simulink) file which contains blocks such as inertia, coriolis, etc.
When using these blocks however, I am obtaining the following error (specifically for the coriolis block in this case):
Index expression out of bounds. Attempted to access element 2. The valid range is 1-1.
More information
Function 'coriolis/coriolis_row_3' (#1334.164.165), line 7, column 12:
"2"
Launch diagnostic report.
As well as more errors concerning the functions to calculate the coriolis matrix (coriolis_row_1, coriolis_row_2, coriolis_row_3).
I could not find any examples where these code generated blocks are used in Simulink.
NOTE: In Matlab the functions do work. For example doing the following returns a result (where q and qd are defined):
myrobot2.coriolis(q,qd)
Does anyone have a solution? Any input would be much appreciated. Thank you in advance.
Accepted Answer
More Answers (0)
Categories
Find more on General Applications in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!