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

Documentation updates and general cleanup

parent 3980140a
Branches
Tags
No related merge requests found
...@@ -310,7 +310,7 @@ classdef EV3 < MaskedHandle ...@@ -310,7 +310,7 @@ classdef EV3 < MaskedHandle
% Example: % Example:
% b = EV3(); |br| % b = EV3(); |br|
% b.connect('bt', 'serPort', '/dev/rfcomm0'); |br| % b.connect('bt', 'serPort', '/dev/rfcomm0'); |br|
% b.playTone(50, 5000, 1000); % Plays tone with 50% volume and 5000Hz for 1 % b.playTone(40, 5000, 1000); % Plays tone with 40% volume and 5000Hz for 1
% second. |br| % second. |br|
% %
......
...@@ -9,6 +9,8 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -9,6 +9,8 @@ classdef Motor < MaskedHandle & dynamicprops
% * You don't need to create instances of this class. The EV3-class automatically creates % * You don't need to create instances of this class. The EV3-class automatically creates
% instances for each motor port, and you can work with them via the EV3-object. % instances for each motor port, and you can work with them via the EV3-object.
% * The Motor-class represents motor ports, not individual motors! % * The Motor-class represents motor ports, not individual motors!
% * If you start a motor with power=0, the internal state will still be set to
% 'isRunning'
% %
% Attributes: % Attributes:
% power (numeric in [-100, 100]): Power level of motor in percent. *[WRITABLE]* % power (numeric in [-100, 100]): Power level of motor in percent. *[WRITABLE]*
...@@ -32,7 +34,7 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -32,7 +34,7 @@ classdef Motor < MaskedHandle & dynamicprops
% Depending on limitMode, the input is interpreted either in degrees or % Depending on limitMode, the input is interpreted either in degrees or
% milliseconds. *[WRITABLE]* % milliseconds. *[WRITABLE]*
% limitMode ('Tacho'|'Time'): Mode for motor limit. *[WRITABLE]* % limitMode ('Tacho'|'Time'): Mode for motor limit. *[WRITABLE]*
% brakeMode ('Brake'|'Coast'): Mode for braking. If 'Coast', the motor will (at % brakeMode ('Brake'|'Coast'): Action done when stopping. If 'Coast', the motor will (at
% tacholimit, if ~=0) coast to a stop. If 'Brake', the motor will stop immediately % tacholimit, if ~=0) coast to a stop. If 'Brake', the motor will stop immediately
% (at tacholimit, if ~=0) and hold the brake. *[WRITABLE]* % (at tacholimit, if ~=0) and hold the brake. *[WRITABLE]*
% debug (bool): Debug turned on or off. In debug mode, everytime a command is passed to % debug (bool): Debug turned on or off. In debug mode, everytime a command is passed to
...@@ -49,31 +51,31 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -49,31 +51,31 @@ classdef Motor < MaskedHandle & dynamicprops
% power (numeric in [-100, 100]): Power level of motor in percent. [WRITABLE] % power (numeric in [-100, 100]): Power level of motor in percent. [WRITABLE]
power; power;
% speedRegulation (bool): Speed regulation turned on or off. When turned on, motor will % speedRegulation (bool): Speed regulation turned on or off. [WRITABLE]
% try to 'hold' its speed at given power level, whatever the load. In this mode, the % When turned on, motor will try to 'hold' its speed at given power level, whatever
% highest possible speed depends on the load and mostly goes up to around 70-80 (at % the load. In this mode, the highest possible speed depends on the load and mostly
% this point, the Brick internally input 100% power). When turned off, motor will % goes up to around 70-80 (at this point, the Brick internally input 100% power).
% constantly input the same power into the motor. The resulting speed will be % When turned off, motor will constantly input the same power into the motor. The
% somewhat lower, depending on the load. [WRITABLE] % resulting speed will be somewhat lower, depending on the load.
speedRegulation; speedRegulation;
% smoothStart (numeric s. t. smoothStart+smoothStop < limitValue): Degrees/Time % smoothStart (numeric s. t. smoothStart+smoothStop < limitValue): Degrees/Time indicating how far/long the motor should smoothly start. [WRITABLE]
% indicating how far/long the motor should smoothly start. Depending on limitMode, % Depending on limitMode, the input is interpreted either in degrees or
% the input is interpreted either in degrees or milliseconds. The first % milliseconds. The first {smoothStart}-milliseconds/degrees of limitValue the
% {smoothStart}-milliseconds/degrees of limitValue the motor will slowly accelerate % motor will slowly accelerate until reaching its defined speed.
% until reaching its defined speed. [WRITABLE] % See also MOTOR.LIMITVALUE, MOTOR.LIMITMODE
smoothStart; smoothStart;
% smoothStop (numeric s. t. smoothStart+smoothStop < limitValue): Degrees/Time % smoothStop (numeric s. t. smoothStart+smoothStop < limitValue): Degrees/Time indicating how far/long the motor should smoothly stop. [WRITABLE]
% indicating how far/long the motor should smoothly stop. Depending on limitMode, the % Depending on limitMode, the input is interpreted either in degrees or
% input is interpreted either in degrees or milliseconds. The last % milliseconds. The last [smoothStop]-milliseconds/degrees of limitValue the motor
% [smoothStop]-milliseconds/degrees of limitValue the motor will slowly slow down % will slowly slow down until it has stopped.
% until it has stopped. [WRITABLE] % See also MOTOR.LIMITVALUE, MOTOR.LIMITMODE
smoothStop; smoothStop;
% limitValue (numeric>=0): Degrees/Time indicating how far/long the motor should run. % limitValue (numeric>=0): Degrees/Time indicating how far/long the motor should run. [WRITABLE]
% Depending on limitMode, the input is interpreted either in degrees or % Depending on limitMode, the input is interpreted either in degrees or
% milliseconds. [WRITABLE] % milliseconds.
% See also MOTOR.LIMITMODE % See also MOTOR.LIMITMODE
limitValue; limitValue;
...@@ -81,14 +83,14 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -81,14 +83,14 @@ classdef Motor < MaskedHandle & dynamicprops
% See also MOTOR.SMOOTHSTART, MOTOR.SMOOTHSTOP, MOTOR.LIMITMODE % See also MOTOR.SMOOTHSTART, MOTOR.SMOOTHSTOP, MOTOR.LIMITMODE
limitMode; limitMode;
% brakeMode ('Brake'|'Coast'): Mode for braking. If 'Coast', the motor will (at % brakeMode ('Brake'|'Coast'): Action done when stopping. [WRITABLE]
% tacholimit, if ~=0) coast to a stop. If 'Brake', the motor will stop immediately % If 'Coast', the motor will (at tacholimit, if ~=0) coast to a stop. If 'Brake',
% (at tacholimit, if ~=0) and hold the brake. [WRITABLE] % the motor will stop immediately (at tacholimit, if ~=0) and hold the brake.
brakeMode; brakeMode;
% debug (bool): Debug turned on or off. In debug mode, everytime a command is passed to % debug (bool): Debug turned on or off. [WRITABLE]
% the sublayer ('communication layer'), there is feedback in the console about what % In debug mode, everytime a command is passed to the sublayer ('communication
% command has been called. [WRITABLE] % layer'), there is feedback in the console about what command has been called.
debug; debug;
end end
...@@ -99,8 +101,9 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -99,8 +101,9 @@ classdef Motor < MaskedHandle & dynamicprops
% tachoCount (numeric): Current tacho count. [READ-ONLY] % tachoCount (numeric): Current tacho count. [READ-ONLY]
tachoCount; tachoCount;
% currentSpeed (numeric): Current speed of motor. If speedRegulation=on this should % currentSpeed (numeric): Current speed of motor. [READ-ONLY]
% equal power, otherwise it will probably be lower than that. [READ-ONLY] % If speedRegulation=on this should equal power, otherwise it will probably be
% lower than that.
% See also MOTOR.SPEEDREGULATION % See also MOTOR.SPEEDREGULATION
currentSpeed; currentSpeed;
...@@ -146,7 +149,7 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -146,7 +149,7 @@ classdef Motor < MaskedHandle & dynamicprops
% See also PORTNO % See also PORTNO
portNo; portNo;
%portInput (PortInput): Internal number of motor port if accessed via input-opCodes % portInput (PortInput): Internal number of motor port if accessed via input-opCodes
% - Port 'A': 16 % - Port 'A': 16
% - Port 'B': 17 % - Port 'B': 17
% - Port 'C': 18 % - Port 'C': 18
...@@ -154,7 +157,7 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -154,7 +157,7 @@ classdef Motor < MaskedHandle & dynamicprops
% See also PORTINPUT % See also PORTINPUT
portInput; portInput;
%isSynced (bool): True if motor is running in synced mode % isSynced (bool): True if motor is running in synced mode
isSynced; isSynced;
% isMaster (bool): True if motor is running in synced mode and has a slave % isMaster (bool): True if motor is running in synced mode and has a slave
...@@ -166,7 +169,7 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -166,7 +169,7 @@ classdef Motor < MaskedHandle & dynamicprops
% physicalMotorConnected (bool): True if physical motor is connected to this port % physicalMotorConnected (bool): True if physical motor is connected to this port
physicalMotorConnected; physicalMotorConnected;
%internalTachoCount (numeric): internal tacho counter used for positioning the motor with a limit % internalTachoCount (numeric): internal tacho counter used for positioning the motor with a limit
internalTachoCount; internalTachoCount;
end end
...@@ -196,7 +199,7 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -196,7 +199,7 @@ classdef Motor < MaskedHandle & dynamicprops
% a tacholimit for some time using Coast, then stop using Coast, and then try % a tacholimit for some time using Coast, then stop using Coast, and then try
% to run the with a tacholimit, it will stop sooner or later than expected, % to run the with a tacholimit, it will stop sooner or later than expected,
% or may not even start at all. % or may not even start at all.
% * After calling one of the functions to control the motor with some kind of % * (OLD)After calling one of the functions to control the motor with some kind of
% limit (which is done if limit~=0), the physical brick's power/speed value for % limit (which is done if limit~=0), the physical brick's power/speed value for
% starting without a limit (i.e. if limit==0) is reset to zero. So if you want % starting without a limit (i.e. if limit==0) is reset to zero. So if you want
% to control the motor without a limit after doing so with a limit, you would % to control the motor without a limit after doing so with a limit, you would
...@@ -342,11 +345,7 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -342,11 +345,7 @@ classdef Motor < MaskedHandle & dynamicprops
error('Motor::stop: No physical motor connected to Port %s',... error('Motor::stop: No physical motor connected to Port %s',...
port2str('Motor', motor.port)); port2str('Motor', motor.port));
elseif motor.isSynced && motor.isRunning elseif motor.isSynced && motor.isRunning
if motor.isMaster motor.syncedStop();
motor.syncedStop();
elseif motor.isSlave
motor.('master').syncedStop();
end
return; return;
% error(['Motor::stop: Motor is running synchronized with another motor. ' ,... % error(['Motor::stop: Motor is running synchronized with another motor. ' ,...
% 'Use ''syncedStop'' on the ''master''-motor.']); % 'Use ''syncedStop'' on the ''master''-motor.']);
...@@ -400,7 +399,6 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -400,7 +399,6 @@ classdef Motor < MaskedHandle & dynamicprops
% % Do stuff % % Do stuff
% m.syncedStop(); |br| % m.syncedStop(); |br|
% %
turnRatio = 0; turnRatio = 0;
% Check parameters % Check parameters
...@@ -506,7 +504,7 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -506,7 +504,7 @@ classdef Motor < MaskedHandle & dynamicprops
error('Motor::syncedStop: Motor has not been started synchronized with another.'); error('Motor::syncedStop: Motor has not been started synchronized with another.');
else else
% Retrieve synced motor from cache % Retrieve synced motor from cache
if length(findprop(motor, 'slave'))==1 if motor.isMaster
syncMotor = motor.slave; syncMotor = motor.slave;
delete(motor.findprop('slave')); delete(motor.findprop('slave'));
delete(syncMotor.findprop('master')); delete(syncMotor.findprop('master'));
...@@ -615,6 +613,9 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -615,6 +613,9 @@ classdef Motor < MaskedHandle & dynamicprops
% %
% Notes: % Notes:
% * A better name would probably be resetPosition... % * A better name would probably be resetPosition...
% * Gets called automatically when starting the motor and the internal tacho
% count is > 0
%
% %
% See also MOTOR.RESETTACHOCOUNT % See also MOTOR.RESETTACHOCOUNT
...@@ -945,7 +946,7 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -945,7 +946,7 @@ classdef Motor < MaskedHandle & dynamicprops
busyFlag = 0; busyFlag = 0;
end end
assert(~(motor.state.startedNotBusy && busyFlag)); % assert(~(motor.state.startedNotBusy && busyFlag));
running = motor.state.startedNotBusy || busyFlag; running = motor.state.startedNotBusy || busyFlag;
end end
......
...@@ -17,20 +17,60 @@ classdef Sensor < MaskedHandle ...@@ -17,20 +17,60 @@ classdef Sensor < MaskedHandle
% mode and the default mode for a Sensor-object are the following (depending on the % mode and the default mode for a Sensor-object are the following (depending on the
% sensor type): *[WRITABLE]* % sensor type): *[WRITABLE]*
% %
% * Touch-Sensor: % * Touch-Sensor:
% * DeviceMode.Touch.Pushed [Default] % * DeviceMode.Touch.Pushed *[Default]*
% * DeviceMode.Touch.Bumps % * DeviceMode.Touch.Bumps
% * Ultrasonic-Sensor: % * Ultrasonic-Sensor:
% * DeviceMode.UltraSonic.DistCM [Default] % * DeviceMode.UltraSonic.DistCM *[Default]*
% * DeviceMode.UltraSonic.DistIn % * DeviceMode.UltraSonic.DistIn
% * DeviceMode.UltraSonic.Listen % * DeviceMode.UltraSonic.Listen
% * Color-Sensor: % * Color-Sensor:
% * DeviceMode.Color.Reflect [Default] % * DeviceMode.Color.Reflect *[Default]*
% * DeviceMode.Color.Ambient % * DeviceMode.Color.Ambient
% * DeviceMode.Color.Col % * DeviceMode.Color.Col
% * Gyro-Sensor: % * Gyro-Sensor:
% * DeviceMode.Gyro.Angular [Default] % * DeviceMode.Gyro.Angular *[Default]*
% * DeviceMode.Gyro.Rate % * DeviceMode.Gyro.Rate
% * Infrared-Sensor:
% * DeviceMode.InfraRed.Prox *[Default]*
% * DeviceMode.InfraRed.Seek
% * DeviceMode.InfraRed.Remote
% * NXTColor-Sensor:
% * DeviceMode.NXTColor.Reflect *[Default]*
% * DeviceMode.NXTColor.Ambient
% * DeviceMode.NXTColor.Color
% * DeviceMode.NXTColor.Green
% * DeviceMode.NXTColor.Blue
% * DeviceMode.NXTColor.Raw
% * NXTLight-Sensor:
% * DeviceMode.NXTLight.Reflect *[Default]*
% * DeviceMode.NXTLight.Ambient
% * NXTSound-Sensor:
% * DeviceMode.NXTSound.DB *[Default]*
% * DeviceMode.NXTSound.DBA
% * NXTTemperature-Sensor
% * DeviceMode.NXTTemperature.C *[Default]*
% * DeviceMode.NXTTemperature.F
% * NXTTouch-Sensor:
% * DeviceMode.NXTTouch.Pushed *[Default]*
% * DeviceMode.NXTTouch.Bumps
% * NXTUltraSonic-Sensor:
% * DeviceMode.NXTUltraSonic.CM *[Default]*
% * DeviceMode.NXTUltraSonic.IN
% * HTAccelerometer-Sensor:
% * DeviceMode.HTAccelerometer.Acceleration *[Default]*
% * DeviceMode.HTAccelerometer.AccelerationAllAxes
% * HTCompass-Sensor:
% * DeviceMode.HTCompass.Degrees *[Default]*
% * HTColor-Sensor:
% * DeviceMode.HTColor.Col *[Default]*
% * DeviceMode.HTColor.Red
% * DeviceMode.HTColor.Green
% * DeviceMode.HTColor.Blue
% * DeviceMode.HTColor.White
% * DeviceMode.HTColor.Raw
% * DeviceMode.HTColor.Nr,
% * DeviceMode.HTColor.All
% debug (bool): Debug turned on or off. In debug mode, everytime a command is passed to % debug (bool): Debug turned on or off. In debug mode, everytime a command is passed to
% the sublayer ('communication layer'), there is feedback in the console about what % the sublayer ('communication layer'), there is feedback in the console about what
% command has been called. *[WRITABLE]* % command has been called. *[WRITABLE]*
...@@ -38,22 +78,25 @@ classdef Sensor < MaskedHandle ...@@ -38,22 +78,25 @@ classdef Sensor < MaskedHandle
% sensor.mode. *[READ-ONLY]* % sensor.mode. *[READ-ONLY]*
% type (DeviceType): Type of physical sensor connected to the port. Possible types are: [READ-ONLY] % type (DeviceType): Type of physical sensor connected to the port. Possible types are: [READ-ONLY]
% %
% * DeviceType.NXTTouch % * DeviceType.NXTTouch
% * DeviceType.NXTLight % * DeviceType.NXTLight
% * DeviceType.NXTSound % * DeviceType.NXTSound
% * DeviceType.NXTColor % * DeviceType.NXTColor
% * DeviceType.NXTUltraSonic % * DeviceType.NXTUltraSonic
% * DeviceType.NXTTemperature % * DeviceType.NXTTemperature
% * DeviceType.LargeMotor % * DeviceType.LargeMotor
% * DeviceType.MediumMotor % * DeviceType.MediumMotor
% * DeviceType.Touch % * DeviceType.Touch
% * DeviceType.Color % * DeviceType.Color
% * DeviceType.UltraSonic % * DeviceType.UltraSonic
% * DeviceType.Gyro % * DeviceType.Gyro
% * DeviceType.InfraRed % * DeviceType.InfraRed
% * DeviceType.Unknown % * DeviceType.HTColor
% * DeviceType.None % * DeviceType.HTCompass
% * DeviceType.Error % * DeviceType.HTAccelerometer
% * DeviceType.Unknown
% * DeviceType.None
% * DeviceType.Error
properties % Standard properties to be set by user properties % Standard properties to be set by user
% mode (DeviceMode.{Type}): Sensor mode in which the value will be read. By default, % mode (DeviceMode.{Type}): Sensor mode in which the value will be read. By default,
...@@ -76,7 +119,46 @@ classdef Sensor < MaskedHandle ...@@ -76,7 +119,46 @@ classdef Sensor < MaskedHandle
% * Gyro-Sensor: % * Gyro-Sensor:
% * DeviceMode.Gyro.Angular [Default] % * DeviceMode.Gyro.Angular [Default]
% * DeviceMode.Gyro.Rate % * DeviceMode.Gyro.Rate
% % * Infrared-Sensor:
% * DeviceMode.InfraRed.Prox [Default]
% * DeviceMode.InfraRed.Seek
% * DeviceMode.InfraRed.Remote
% * NXTColor-Sensor:
% * DeviceMode.NXTColor.Reflect [Default]
% * DeviceMode.NXTColor.Ambient
% * DeviceMode.NXTColor.Color
% * DeviceMode.NXTColor.Green
% * DeviceMode.NXTColor.Blue
% * DeviceMode.NXTColor.Raw
% * NXTLight-Sensor:
% * DeviceMode.NXTLight.Reflect [Default]
% * DeviceMode.NXTLigth.Ambient
% * NXTSound-Sensor:
% * DeviceMode.NXTSound.DB [Default]
% * DeviceMode.NXTSound.DBA
% * NXTTemperature-Sensor
% * DeviceMode.NXTTemperature.C [Default]
% * DeviceMode.NXTTemperature.F
% * NXTTouch-Sensor:
% * DeviceMode.NXTTouch.Pushed [Default]
% * DeviceMode.NXTTouch.Bumps
% * NXTUltraSonic-Sensor:
% * DeviceMode.NXTUltraSonic.CM [Default]
% * DeviceMode.NXTUltraSonic.IN
% * HTAccelerometer-Sensor:
% * DeviceMode.HTAccelerometer.Acceleration [Default]
% * DeviceMode.HTAccelerometer.AccelerationAllAxes
% * HTCompass-Sensor:
% * DeviceMode.HTCompass.Degrees [Default]
% * HTColor-Sensor:
% * DeviceMode.HTColor.Col [Default]
% * DeviceMode.HTColor.Red
% * DeviceMode.HTColor.Green
% * DeviceMode.HTColor.Blue
% * DeviceMode.HTColor.White
% * DeviceMode.HTColor.Raw
% * DeviceMode.HTColor.Nr,
% * DeviceMode.HTColor.All
% See also SENSOR.VALUE, SENSOR.TYPE % See also SENSOR.VALUE, SENSOR.TYPE
mode; mode;
...@@ -87,13 +169,13 @@ classdef Sensor < MaskedHandle ...@@ -87,13 +169,13 @@ classdef Sensor < MaskedHandle
end end
properties (Dependent) % Parameters to be read directly from physical brick properties (Dependent) % Parameters to be read directly from physical brick
% value (numeric): Value read from hysical sensor. What the value represents depends on % value (numeric): Value read from physical sensor. [READ-ONLY]
% sensor.mode. *[READ-ONLY]* % What the value represents depends on sensor.mode.
% See also SENSOR.MODE % See also SENSOR.MODE
value; value;
% type (DeviceType): Type of physical sensor connected to the port. Possible types are % type (DeviceType): Type of physical sensor connected to the port. [READ-ONLY]
% *[READ-ONLY]*: % Possible types are:
% * DeviceType.NXTTouch % * DeviceType.NXTTouch
% * DeviceType.NXTLight % * DeviceType.NXTLight
% * DeviceType.NXTSound % * DeviceType.NXTSound
...@@ -107,6 +189,9 @@ classdef Sensor < MaskedHandle ...@@ -107,6 +189,9 @@ classdef Sensor < MaskedHandle
% * DeviceType.UltraSonic % * DeviceType.UltraSonic
% * DeviceType.Gyro % * DeviceType.Gyro
% * DeviceType.InfraRed % * DeviceType.InfraRed
% * DeviceType.HTColor
% * DeviceType.HTCompass
% * DeviceType.HTAccelerometer
% * DeviceType.Unknown % * DeviceType.Unknown
% * DeviceType.None % * DeviceType.None
% * DeviceType.Error % * DeviceType.Error
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment