大家好!我想我已经找到了解决方案here it is if you're interested.
Ok so I found that there was indeed no defined function for adding a circular move to the program via the Matlab API.
In the RobolinkItem class at line 607, we can find this code for linear and joint movement :
Code:
function addMoveJ(this, itemtarget)
% Adds a new "Move Joint" instruction to a program.
% In 1 : item -> target to move to
this.link.check_connection();
command = 'Add_INSMOVE';
this.link.send_line(command);
this.link.send_item(itemtarget);
this.link.send_item(this);
this.link.send_int(1);
this.link.check_status();
end
function addMoveL(this, itemtarget)
% Adds a new "Move Linear" instruction to a program.
% In 1 : item -> target to move to
this.link.check_connection();
command = 'Add_INSMOVE';
this.link.send_line(command);
this.link.send_item(itemtarget);
this.link.send_item(this);
this.link.send_int(2);
this.link.check_status();
end
All I had to do is to implement another function that I called addMoveC. The only lines to change are the initializing of the "command" variable (set to Add_INSMOVEC instead of Add_INSMOVE) and the value to send via send_int(); Then, we need to add a second target to send via send_item(). So here is the function :
Code:
function addMoveC(this, itemtarget1, itemtarget2)
% Adds a new "Move Circular" instruction to a program.
% In 1 : item -> first target to move to
% In 2 : item -> second target to move to
this.link.check_connection();
command = 'Add_INSMOVEC';
this.link.send_line(command);
this.link.send_item(itemtarget1);
this.link.send_item(itemtarget2);
this.link.send_item(this);
this.link.send_int(3);
this.link.check_status()
end
The function call should look like this :
Code:
program.addMoveC(target1,target2)
I hope this helps the poor souls in search of answers regarding this matter. Please let me know if I forgot something.
JFCh
(06-20-2019, 02:07 PM)Albert Wrote:Hi Jean-François,
We just added support for circular movements through the Matlab API. I recommend you to use MoveC instead of addMoveC. You can use MoveC on a robot item to move circular or a program item to add a circular move instruction.
You can take the latest version from our GitHub repository:
https://github.com/RoboDK/RoboDK-API/tree/master/Matlab
Code:
%% Example to use circular motion
RDK = Robolink();
robot = RDK.Item('',RDK.ITEM_TYPE_ROBOT);
% Get the current robot pose:
pose0 = robot.Pose();
% Add a new program:
prog = RDK.AddProgram('TestProgram');
% Create a linear move to the current robot position
% (MoveC is defined by 3 points, the first point is the current robot position so we add a linear move to the first position)
target0 = RDK.AddTarget('First Point');
target0.setAsCartesianTarget(); % default behavior
target0.setPose(pose0);
prog.MoveL(target0);
% Calculate the circular move relative to the previous target:
pose1 = pose0*transl(50,0,0);
pose2 = pose0*transl(50,50,0);
% Add the first target for the circular move
target1 = RDK.AddTarget('Second Point');
target1.setAsCartesianTarget();
target1.setPose(pose1);
% Add the second target for the circular move
target2 = RDK.AddTarget('Third Point');
target2.setAsCartesianTarget();
target2.setPose(pose2);
% Add the circular move instruction:
prog.MoveC(target1, target2)
Albert
Albert,
Thank you for your message, I did not see it before replying back with my own solution. I will definitely go with your solution.
Thank you,
Jean-François