classdef RobolinkItem < handle
properties
item = 0;
link = 0;
end
methods
function this = RobolinkItem(rl, ptr_item)
if nargin < 2
ptr_item = 0;
end
this.item = ptr_item;
this.link = rl;
end
function type = Type(this)
this.link.check_connection();
command = 'G_Item_Type';
this.link.send_line(command);
this.link.send_item(this);
type = this.link.rec_int();
this.link.check_status();
end
function Copy(this)
this.link.Copy(this);
end
function newitem = Paste(this)
newitem = this.link.Paste(this.item);
end
function AddGeometry(this, fromitem, pose)
this.link.check_connection();
command = 'CopyFaces';
this.link.send_line(command);
this.link.send_item(fromitem);
this.link.send_item(this);
this.link.send_pose(pose);
this.link.check_status();
end
function Delete(this)
this.link.check_connection();
command = 'Remove';
this.link.send_line(command);
this.link.send_item(this);
this.link.check_status();
end
function valid = Valid(this)
valid = (this.item ~= 0);
end
function setParent(this, parent)
this.link.check_connection();
command = 'S_Parent';
this.link.send_line(command);
this.link.send_item(this);
this.link.send_item(parent);
this.link.check_status();
end
function setParentStatic(this, parent)
this.link.check_connection();
command = 'S_Parent_Static';
this.link.send_line(command);
this.link.send_item(this);
this.link.send_item(parent);
this.link.check_status();
end
function item_attached = AttachClosest(this)
this.link.check_connection();
command = 'Attach_Closest';
this.link.send_line(command);
this.link.send_item(this);
item_attached = this.link.rec_item();
this.link.check_status();
end
function DetachClosest(this, parent)
if nargin < 2
parent = 0;
end
this.link.check_connection();
command = 'Detach_Closest';
this.link.send_line(command);
this.link.send_item(this);
this.link.send_item(parent);
this.link.check_status();
end
function DetachAll(this, parent)
if nargin < 2
parent = RobolinkItem(this.link);
end
this.link.check_connection();
command = 'Detach_All';
this.link.send_line(command);
this.link.send_item(this);
this.link.send_item(parent);
this.link.check_status();
end
function parent = Parent(this)
this.link.check_connection();
command = 'G_Parent';
this.link.send_line(command);
this.link.send_item(this);
parent = this.link.rec_item();
this.link.check_status();
end
function itemlist = Childs(this)
this.link.check_connection();
command = 'G_Childs';
this.link.send_line(command);
this.link.send_item(this);
nitems = this.link.rec_int();
itemlist = cell(nitems,1);
for i=1:nitems
itemlist{i} = this.link.rec_item();
end
this.link.check_status();
end
function visible = Visible(this)
this.link.check_connection();
command = 'G_Visible';
this.link.send_line(command);
this.link.send_item(this);
visible = this.link.rec_int();
this.link.check_status();
end
function setVisible(this, visible, visible_frame)
if nargin < 3
visible_frame = visible;
end
this.link.check_connection();
command = 'S_Visible';
this.link.send_line(command);
this.link.send_item(this);
this.link.send_int(visible);
this.link.send_int(visible_frame);
this.link.check_status();
end
function name = Name(this)
this.link.check_connection();
command = 'G_Name';
this.link.send_line(command);
this.link.send_item(this);
name = this.link.rec_line();
this.link.check_status();
end
function setName(this, name)
this.link.check_connection();
command = 'S_Name';
this.link.send_line(command);
this.link.send_item(this);
this.link.send_line(name);
this.link.check_status();
end
function setPose(this, pose)
this.link.check_connection();
command = 'S_Hlocal';
this.link.send_line(command);
this.link.send_item(this);
this.link.send_pose(pose);
this.link.check_status();
end
function pose = Pose(this)
this.link.check_connection();
command = 'G_Hlocal';
this.link.send_line(command);
this.link.send_item(this);
pose = this.link.rec_pose();
this.link.check_status();
end
function setHtool(this, pose)
this.link.check_connection();
command = 'S_Htool';
this.link.send_line(command);
this.link.send_item(this);
this.link.send_pose(pose);
this.link.check_status();
end
function pose = Htool(this)
this.link.check_connection();
command = 'G_Htool';
this.link.send_line(command);
this.link.send_item(this);
pose = this.link.rec_pose();
this.link.check_status();
end
function setPoseAbs(this, pose)
this.link.check_connection();
command = 'S_Hlocal_Abs';
this.link.send_line(command);
this.link.send_item(this);
this.link.send_pose(pose);
this.link.check_status();
end
function pose = PoseAbs(this)
this.link.check_connection();
command = 'G_Hlocal_Abs';
this.link.send_line(command);
this.link.send_item(this);
pose = this.link.rec_pose();
this.link.check_status();
end
function color = check_color(~, color)
cs = numel(color);
color = reshape(color, 1, cs);
if cs > 4
color = color(1:4);
elseif cs < 4
color = [color(1:end), zeros(1,4-cs)];
color(4) = 1;
end
maxc = max(color);
if maxc > 1
color = color/maxc;
end
end
function Recolor(this, tocolor, fromcolor, tolerance)
this.link.check_connection();
if nargin < 3
fromcolor = [0,0,0,0];
tolerance = 2;
elseif nargin < 4
tolerance = 0.1;
end
tocolor = check_color(this,tocolor);
fromcolor = check_color(this,fromcolor);
command = 'Recolor';
this.link.send_line(command);
this.link.send_item(this);
this.link.send_array([tolerance(1), fromcolor, tocolor]);
this.link.check_status();
end
function Scale(this, scale)
this.link.check_connection();
if numel(scale) < 3
scale = [scale(1); scale(1); scale(1)];
end
command = 'Scale';
this.link.send_line(command);
this.link.send_item(this);
this.link.send_array(scale);
this.link.check_status();
end
function setAsCartesianTarget(this)
this.link.check_connection();
command = 'S_Target_As_RT';
this.link.send_line(command);
this.link.send_item(this);
this.link.check_status();
end
function setAsJointTarget(this)
this.link.check_connection();
command = 'S_Target_As_JT';
this.link.send_line(command);
this.link.send_item(this);
this.link.check_status();
end
function joints = Joints(this)
this.link.check_connection();
command = 'G_Thetas';
this.link.send_line(command);
this.link.send_item(this);
joints = this.link.rec_array();
this.link.check_status();
end
function setJoints(this, joints)
this.link.check_connection();
command = 'S_Thetas';
this.link.send_line(command);
this.link.send_array(joints);
this.link.send_item(this);
this.link.check_status();
end
function setFrame(this, frame)
this.link.check_connection();
if numel(frame) == 1
command = 'S_Frame_ptr';
this.link.send_line(command);
this.link.send_item(frame);
else
command = 'S_Frame';
this.link.send_line(command);
this.link.send_pose(frame);
end
this.link.send_item(this);
this.link.check_status();
end
function setTool(this, tool)
this.link.check_connection();
if numel(tool) == 1
command = 'S_Tool_ptr';
this.link.send_line(command);
this.link.send_item(tool);
else
command = 'S_Tool';
this.link.send_line(command);
this.link.send_pose(tool);
end
this.link.send_item(this);
this.link.check_status();
end
function pose = SolveFK(this, joints)
this.link.check_connection();
command = 'G_FK';
this.link.send_line(command);
this.link.send_array(joints);
this.link.send_item(this);
pose = this.link.rec_pose();
this.link.check_status();
end
function joints = SolveIK(this, pose)
this.link.check_connection();
command = 'G_IK';
this.link.send_line(command);
this.link.send_pose(pose);
this.link.send_item(this);
joints = this.link.rec_array();
this.link.check_status();
end
function joints_list = SolveIK_All(this, pose)
this.link.check_connection();
command = 'G_IK_cmpl';
this.link.send_line(command);
this.link.send_pose(pose);
this.link.send_item(this);
joints_list = this.link.rec_matrix();
if size(joints_list,1) > 6
joints_list = joints_list(1:end-2,:);
end
this.link.check_status();
end
function MoveJ(this, target, blocking)
if nargin < 3
blocking = 1;
end
this.link.moveX(target,this,1,blocking);
end
function MoveL(this, target, blocking)
if nargin < 3
blocking = 1;
end
this.link.moveX(target,this,2,blocking);
end
function collision = MoveJ_Collision(this, j1, j2, minstep_deg)
if nargin < 4
minstep_deg = -1;
end
this.link.check_connection();
command = 'CollisionMove';
this.link.send_line(command);
this.link.send_item(this);
this.link.send_array(j1);
this.link.send_array(j2);
this.link.send_int(minstep_deg*1000);
collision = this.link.rec_int();
this.link.check_status();
end
function setSpeed(this, speed, accel)
if nargin < 2
accel = -1;
end
this.link.check_connection();
command = 'S_Speed';
this.link.send_line(command);
this.link.send_int(speed*1000);
this.link.send_int(accel*1000);
this.link.send_item(this);
this.link.check_status();
end
function setZoneData(this, zonedata)
this.link.check_connection();
command = 'S_ZoneData';
this.link.send_line(command);
this.link.send_int(zonedata*1000);
this.link.send_item(this);
this.link.check_status();
end
function ShowSequence(this, sequence)
this.link.check_connection();
command = 'Show_Seq';
this.link.send_line(command);
this.link.send_matrix(sequence);
this.link.send_item(this);
this.link.check_status();
end
function busy = Busy(this)
this.link.check_connection();
command = 'IsBusy';
this.link.send_line(command);
this.link.send_item(this);
busy = this.link.rec_int();
this.link.check_status();
end
function WaitMove(this, timeout)
if nargin < 2
timeout = 300;
end
this.link.check_connection();
command = 'WaitMove';
this.link.send_line(command);
this.link.send_item(this);
this.link.check_status();
set(this.link.COM,'Timeout', timeout);
this.link.check_status();
set(this.link.COM,'Timeout', this.link.COM.TIMEOUT);
end
function prog_status = RunProgram(this)
this.link.check_connection();
command = 'RunProg';
this.link.send_line(command);
this.link.send_item(this);
prog_status = this.link.rec_int();
this.link.check_status();
end
function addMoveJ(this, itemtarget)
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)
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
end
end
Error using RobolinkItem (line 25)
Not enough input arguments.