Error when calling RevoluteMDH function in MATLAB Function block of simulink

127 views
Skip to first unread message

Qian Yang

unread,
Sep 20, 2018, 1:53:15 AM9/20/18
to Robotics & Machine Vision Toolboxes
Hello, I am trying to build a robotic arm control system in simulink using Robotics Toolbox. A MATLAB Function block is added in simulink for building kinematic model of arm and real-time path planning. Here is part of code inside MATLAB Function block.

Link_tool = 0;
L
(1) = RevoluteMDH('alpha',  0,         'a',  0, 'offset', 0,           'd', 0.0892);
L
(2) = RevoluteMDH('alpha',  pi/2,      'a',  0, 'offset', pi/2,        'd', 0);
L
(3) = RevoluteMDH('alpha',  0,         'a',  0.425, 'offset', 0,       'd', 0);
L
(4) = RevoluteMDH('alpha',  0,         'a',  0.392, 'offset',  -pi/2,          'd', 0.1093);
L
(5) = RevoluteMDH('alpha',  -pi/2,     'a',  0, 'offset',  0,          'd', 0.09475);
L
(6) = RevoluteMDH('alpha',  pi/2,      'a',  0, 'offset',  0,          'd', 0.0825 + Link_tool);

When I run the simulink model,  some errors were reported, as following.

webwxgetmsgimg.jpeg


However, when I run the code as script outside the simulink model, it works fine. It seems that some functions of the toolbox are not supported in MATLAB Function block. I am rather confused. Could anyone help me?

Thanks.

Erik van Oene

unread,
Sep 20, 2018, 2:55:23 AM9/20/18
to Robotics & Machine Vision Toolboxes
Hi,

I don't know if it is changed in last releases, but usually you define a SerialLink instance in you matlab workspace where the Simulink block is referring to. You ca do that in a regular script or in on of the callback functions of the Simulink file.

Erik

Qian Yang

unread,
Sep 20, 2018, 10:13:12 PM9/20/18
to Robotics & Machine Vision Toolboxes
Thank you for your reply. I will try referring to the SerialLink object in matlab workspace.

Yang

在 2018年9月20日星期四 UTC+8下午2:55:23,Erik van Oene写道:

Peter Corke

unread,
Sep 23, 2018, 1:03:58 PM9/23/18
to Robotics & Machine Vision Toolboxes
The MATLAB function blocks in Simulink do not implement the full MATLAB language and I suspect this is the root cause of your trouble.

Define the robot in the workspace, say as object called robot.  Then enter that variable name into the parameters box for any of the RTB simulink blocks.

peter

Qian Yang

unread,
Oct 15, 2018, 5:14:38 AM10/15/18
to Robotics & Machine Vision Toolboxes
You are right. It works. Thank you.

Yang

在 2018年9月24日星期一 UTC+8上午1:03:58,Peter Corke写道:
Reply all
Reply to author
Forward
0 new messages