RoboDK Forum
Matlab API Driving UR10- Printable Version

+- RoboDK Forum (//www.sinclairbody.com/forum)
+-- Forum: RoboDK (EN) (//www.sinclairbody.com/forum/Forum-RoboDK-EN)
+--- Forum: RoboDK API (//www.sinclairbody.com/forum/Forum-RoboDK-API)
+--- Thread: Matlab API Driving UR10 (/Thread-Matlab-API-Driving-UR10)



Matlab API Driving UR10-jenkijr98-09-23-2019

Hi guys, please excuse my ignorance, i'm very new to RoboDK. I'm currently working on a project involving sorting parts using a vision system mounted to a UR10.

Im using Matlab to do some image acquisition and analysis, based on the outcome of the analysis, i need to call and run 1 of 5 preset programs on the UR10.

So my question is, can i do this in the RoboDK API for Matlab, and if so, would anyone have an example of the code needed to connect to and drive the UR10 (i'm using a Ethernet connection to the control box).

i can currently run the simulation of the program through the API, and can run the program on the robot directly through RoboDK, but i cant seem to run the program on the robot using the API.

kind Regards,
约旦.


RE: Matlab API Driving UR10-Albert-09-24-2019

Hi Jordan,

Yes, this is possible. You should be able to connect to a UR10 robot and move it directly from your Matlab code using the RoboDK API for Matlab.
I recommend you to take a look at this example (based on Python):
//www.sinclairbody.com/doc/en/PythonAPI/examples.html#online-programming

So a simplified version of this example for Matlab would look like this:
Code:
% Clear Matlab variables and screen
clc
clear
close all

% Generate a Robolink object RDK. This object interfaces with RoboDK.
RDK = Robolink;

% Get the robot item
robot = RDK.Item('UR10');

% Try to connect to the robot (make sure to first provide the IP in the RoboDK User Interface)
success = robot.Connect();
% success = robot.Connect('192.168.2.74'); % Optionally specify the robot IP

% Check if you are properly connected to the robot
[status, status_msg] = robot.ConnectedState();
if status ~= Robolink.ROBOTCOM_READY
fprintf(['Failed to connect to the robot:\n' , status_msg]);
fprintf('\nPress enter to continue in simulation mode.\n');
pause;
end

% Set the TCP as a pose, in mm and radians (important for linear movements)
robot.setTool(transl(0,0,100)*rotz(0))

% Set the linear speed in mm/s
robot.setSpeed(200);

% Move the robot using Joint coordinates
robot.MoveJ([0,-90,-90,0,90,0]);

% Move the robot using Cartesian target (pose)
pose = transl(750,0,500)*roty(90*pi/180);
robot.MoveL(构成);

I also recommend you to take the latest version of the Matlab API from this link (the Connect function was missing):
https://github.com/RoboDK/RoboDK-API/tree/master/Matlab


RE: Matlab API Driving UR10-jenkijr98-09-25-2019

Thanks Albert! just what i needed.

kind regards,
约旦.