Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Matlab API Driving UR10

#1
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,
Jordan.
#2
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):
https://robodk.com/doc/en/PythonAPI/exam...rogramming

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(pose);

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
#3
Thanks Albert! just what i needed.

kind regards,
Jordan.
  




Users browsing this thread:
1 Guest(s)