Skip to content
Snippets Groups Projects
Commit bfc8a1de authored by Tim Stadtmann's avatar Tim Stadtmann
Browse files

Fix issue #17

When calling stop() on a motor running synced, the both motors will now
stop (instead of an error being thrown). Therefore, the user does not
need to call syncedStop anymore.
parent f6412c71
No related branches found
No related tags found
No related merge requests found
......@@ -157,6 +157,12 @@ classdef Motor < MaskedHandle & dynamicprops
%isSynced (bool): True if motor is running in synced mode
isSynced;
% isMaster (bool): True if motor is running in synced mode and has a slave
isMaster;
% isSlave (bool): True if motor is running in synced mode and has a master
isSlave;
% physicalMotorConnected (bool): True if physical motor is connected to this port
physicalMotorConnected;
......@@ -336,8 +342,14 @@ classdef Motor < MaskedHandle & dynamicprops
error('Motor::stop: No physical motor connected to Port %s',...
port2str('Motor', motor.port));
elseif motor.isSynced && motor.isRunning
error(['Motor::stop: Motor is running synchronized with another motor. ' ,...
'Use ''syncedStop'' on the ''master''-motor.']);
if motor.isMaster
motor.syncedStop();
elseif motor.isSlave
motor.('master').syncedStop();
end
return;
% error(['Motor::stop: Motor is running synchronized with another motor. ' ,...
% 'Use ''syncedStop'' on the ''master''-motor.']);
end
motor.commInterface.outputStop(0, motor.port, motor.brakeMode_);
......@@ -931,8 +943,15 @@ classdef Motor < MaskedHandle & dynamicprops
end
function synced = get.isSynced(motor)
synced = (length(findprop(motor, 'slave'))==1 || ...
length(findprop(motor, 'master'))==1);
synced = motor.isSlave || motor.isMaster;
end
function isSlave = get.isSlave(motor)
isSlave = length(findprop(motor, 'master'))==1;
end
function isMaster = get.isMaster(motor)
isMaster = length(findprop(motor, 'slave'))==1;
end
function motorType = get.type(motor)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment