Issue while using the class generated after CodeGeneration in Rapid Accelerator mode

27 views
Skip to first unread message

Himanshu Varshney

unread,
Jun 20, 2021, 5:12:29 AM6/20/21
to Robotics & Machine Vision Toolboxes
Sir/Ma'am,
I'm using Matlab 2021a.
I want to find acceleration for given Q, QD, Torque for 'Puma 560' robot in Simulink. I am designing a controller to control the Puma 560 trajectory. In order to design the controller, I need controller parameters to be optimized. For optimization, I am using a optimization algorithm written in Matlab script.

You might already know that, for optimization, we need to run the model so many times.
In my case, total 400 number of simulations will be done.

When running the Simulink simulation in normal mode, 1 simulation taking almost  10-15 minutes. So, more than 2-3 days for 400 simulations.
Then, I came across Rapid Accelerator mode in Simulink. But there are some limitation for me as follows,
1. I have to use non S-function blocks only because Matlab Coder can't generate code for S-function block.
2. Can't use class in Matlab Function block in Simulink.

Now, I have the following options,
1. By designing the robot dynamic model manually: When I made the robot dynamic model manually, I get the derivative or integrator error that "at some specific time derivative or integrator giving not defined value (may be divide by zero at that time). 
2. By using 'robot' Simulink block provided in Robotics Toolbox by Peter Corke sir: If I am using this block, Matlab Coder throws an error "cannot generate code for S-function blocks".
3. By using Matlab's in-built "Forward Dynamics block" under Robotics System Toolbox: To use this block, I have to make the 'rigidBodyTree' for the Puma 560. When I try to make the 'rigidBodyTree' for Puma 560 manually, it always gives me wrong output. When I try to make the 'rigirBodyTree' for Puma 560 by importing from a Puma 560 URDF file, it throws the derivative or integrator error again.
4. By using Matlab Function block: To use Matlab Function block, I generated c-code files, c-mex files and m-files for Puma560 by using the CodeGenerator feature embedded in Robotics Toolbox by Peter Corke sir. After creation of all the files, @Puma560 class also generated to access these files. Then, I wrote the following code in the Matlab Function Block,

function qdd = fcn(q,qd,T)
    p = Puma560 % create object of the @Puma560 class
    qdd = p.accel(q,qd,T) % access 'accel.m' method of class @Puma560 through object 'p'

After starting the simulation, I Matlab Coder throws an error "The 'dynamicprops' class does not support code generation". 

Now, I am out of options. Please help me out.

If you not understood the query or want any other information from my side, please feel free to ask me.



Reply all
Reply to author
Forward
0 new messages