Skip to content
Snippets Groups Projects

Connector improvements

Merged Kyrre Ness Sjobaek requested to merge ConnectorImprov into GUI
+ 14
2
@@ -52,6 +52,9 @@ classdef robotConnector < handle
stepperInterlock = NaN; %Safety interlock enabled?
stepperIsMoving = 0; %Which axis (1/2/3) is moving? 0 if not moving.
stepperGotoTarget = NaN; %Where is it going to? NaN if not moving, 0 if ZEROSEEK,
% otherwise it the position it is currently moving to,
% along the axis indicated by stepperIsMoving.
%Grabber status
grabberPos = NaN;
@@ -155,7 +158,7 @@ classdef robotConnector < handle
obj.TCPport = 23;
end
disp(['Connecting to ', obj.address, ' on port ', num2str(obj.TCPport), '...']);
disp(strcat("Connecting to ", string(obj.address), " on port ", num2str(obj.TCPport), "..."));
obj.TCPconn = tcpclient(obj.address,obj.TCPport, "Timeout", 2);
disp('Connected!')
@@ -176,7 +179,7 @@ classdef robotConnector < handle
function delete(obj)
%DELETE Closes the TCP connection
disp(['Disconnecting from ', obj.address, ' on port ', num2str(obj.TCPport), '...']);
disp(strcat("Disconnecting from ", string(obj.address), " on port ", num2str(obj.TCPport), "..."));
clear obj.TCPconn;
end
@@ -703,15 +706,21 @@ classdef robotConnector < handle
lineSplitCMD = split(obj.lastCommand);
xyz = lineSplitCMD(3);
xyzID = find(obj.stepperXYZ==xyz);
if isempty(xyzID)
error(strcat("Axis name ", string(xyz), " not recognized"))
end
if startsWith(obj.lastCommand, 'STEPPER ZEROSEEK ')
obj.stepperGotoTarget = 0;
end
lineSplit = split(line);
if startsWith(line, '< STEPPER GO FINISHED') % This is always the final output line
obj.stepperIsMoving = 0;
obj.stepperGotoTarget = NaN;
obj.stepperPos(xyzID) = str2double(lineSplit(8));
if startsWith(obj.lastCommand, 'STEPPER ZEROSEEK ')
@@ -731,6 +740,9 @@ classdef robotConnector < handle
obj.callbackFunction(obj,true,false,false);
end
elseif line.startsWith("< STEPPER GOTO ")
obj.stepperGotoTarget = str2double(lineSplit(5));
elseif line.startsWith("< STEPPER MOVING ")
obj.stepperIsMoving = xyzID;
if obj.callbackEnabled
Loading