Changeset 272
- Timestamp:
- 09/18/08 17:57:06 (5 years ago)
- Location:
- branches/atorf/RWTHMindstormsNXT-Lejos-Combined/@NXTmotor
- Files:
-
- 1 added
- 10 modified
-
NXTmotor.m (modified) (1 diff)
-
get.m (modified) (5 diffs)
-
isRunning.m (added)
-
read.m (modified) (1 diff)
-
reset.m (modified) (1 diff)
-
send.m (modified) (1 diff)
-
set.m (modified) (8 diffs)
-
stop.m (modified) (1 diff)
-
subsasgn.m (modified) (1 diff)
-
subsref.m (modified) (1 diff)
-
wait.m (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/atorf/RWTHMindstormsNXT-Lejos-Combined/@NXTmotor/NXTmotor.m
r267 r272 77 77 % end 78 78 % 79 obj. port = 0;80 obj. power = 0;81 obj. motorOn = 1;82 obj. brake = 1;83 obj. regulationMode = 'SPEED';84 obj. turnRatio = 0;85 obj. runState = 'RUNNING';86 obj. tachoLimit = 0;79 obj.Port = 0; 80 obj.Power = 0; 81 obj.MotorOn = 1; 82 obj.Brake = 1; 83 obj.RegulationMode = 'SPEED'; 84 obj.TurnRatio = 0; 85 obj.RunState = 'RUNNING'; 86 obj.TachoLimit = 0; 87 87 end 88 88 -
branches/atorf/RWTHMindstormsNXT-Lejos-Combined/@NXTmotor/get.m
r267 r272 46 46 switch prop 47 47 case 'Port' 48 val = obj. port;48 val = obj.Port; 49 49 case 'Power' 50 val = obj. power;50 val = obj.Power; 51 51 case 'MotorOn' 52 if obj. motorOn == 152 if obj.MotorOn == 1 53 53 val = 'on'; 54 54 else … … 56 56 end 57 57 case 'Brake' 58 if obj. brake == 158 if obj.Brake == 1 59 59 val = 'on'; 60 60 else … … 62 62 end 63 63 case 'RegulationMode' 64 switch obj. regulationMode64 switch obj.RegulationMode 65 65 case 'IDLE' 66 66 val = 'idle'; … … 73 73 end 74 74 case 'TurnRatio' 75 val = obj. turnRatio;75 val = obj.TurnRatio; 76 76 case 'RunState' 77 switch obj. runState77 switch obj.RunState 78 78 case 'IDLE'; 79 79 val = 'idle'; … … 88 88 end 89 89 case 'TachoLimit' 90 val = obj. tachoLimit;90 val = obj.TachoLimit; 91 91 otherwise 92 92 error('MATLAB:RWTHMindstormsNXT:UnsupportedProperty',... -
branches/atorf/RWTHMindstormsNXT-Lejos-Combined/@NXTmotor/read.m
r267 r272 49 49 %% THIS HAS TO BE FIXED. ONLY THE OUTPUT STATE OF FIRST PORT IS RETURNED 50 50 %% WHEN APPLYING CHANGES BE AWARE OF USAGE IN WAIT 51 settings = NXT_GetOutputState(obj. port(motorindex));51 settings = NXT_GetOutputState(obj.Port(motorindex)); 52 52 53 53 % Translate output of NXT_GetOutputState to motor settings -
branches/atorf/RWTHMindstormsNXT-Lejos-Combined/@NXTmotor/reset.m
r267 r272 39 39 switch lower(type) 40 40 case 'absolute' 41 NXT_ResetMotorPosition(obj. port, 0);41 NXT_ResetMotorPosition(obj.Port, 0); 42 42 % case 'relative' 43 % NXT_ResetMotorPosition(obj. port, 1);43 % NXT_ResetMotorPosition(obj.Port, 1); 44 44 % case 'full' 45 45 % NXT_StartProgram('ResetCounter'); -
branches/atorf/RWTHMindstormsNXT-Lejos-Combined/@NXTmotor/send.m
r267 r272 39 39 40 40 out = NXT_SetOutputState(... 41 obj. port, ...42 obj. power, ...43 obj. motorOn, ...44 obj. brake, ...45 obj. regulationMode, ...46 obj. turnRatio, ...47 obj. runState, ...48 obj. tachoLimit, ...41 obj.Port, ... 42 obj.Power, ... 43 obj.MotorOn, ... 44 obj.Brake, ... 45 obj.RegulationMode, ... 46 obj.TurnRatio, ... 47 obj.RunState, ... 48 obj.TachoLimit, ... 49 49 'reply'... 50 50 ); 51 51 else 52 52 NXT_SetOutputState(... 53 obj. port, ...54 obj. power, ...55 obj. motorOn, ...56 obj. brake, ...57 obj. regulationMode, ...58 obj. turnRatio, ...59 obj. runState, ...60 obj. tachoLimit, ...53 obj.Port, ... 54 obj.Power, ... 55 obj.MotorOn, ... 56 obj.Brake, ... 57 obj.RegulationMode, ... 58 obj.TurnRatio, ... 59 obj.RunState, ... 60 obj.TachoLimit, ... 61 61 'dontreply'... 62 62 ); -
branches/atorf/RWTHMindstormsNXT-Lejos-Combined/@NXTmotor/set.m
r267 r272 108 108 end 109 109 110 obj. port = fix(val);110 obj.Port = fix(val); 111 111 else 112 112 error('MATLAB:RWTHMindstormsNXT:InvalidPort',... … … 122 122 'Power is not an integer.'); 123 123 end 124 obj. power = fix(val);124 obj.Power = fix(val); 125 125 else 126 126 error('MATLAB:RWTHMindstormsNXT:InvalidPower',... … … 130 130 case 'MotorOn' 131 131 if isscalar(val) && isnumeric(val) && (val == 0 || val == 1) 132 obj. motorOn = val;132 obj.MotorOn = val; 133 133 elseif islogical(val) 134 134 if val 135 obj. motorOn = 1;136 else 137 obj. motorOn = 0;135 obj.MotorOn = 1; 136 else 137 obj.MotorOn = 0; 138 138 end 139 139 elseif ischar(val) 140 140 if strcmpi(val,'on') 141 obj. motorOn = 1;141 obj.MotorOn = 1; 142 142 elseif strcmpi(val,'off') 143 obj. motorOn = 0;143 obj.MotorOn = 0; 144 144 else 145 145 error('MATLAB:RWTHMindstormsNXT:InvalidMotorOn',... … … 153 153 case 'Brake' 154 154 if isscalar(val) && isnumeric(val) && (val == 0 || val == 1) 155 obj. brake = val;155 obj.Brake = val; 156 156 elseif islogical(val) 157 157 if val 158 obj. brake = 1;159 else 160 obj. brake = 0;158 obj.Brake = 1; 159 else 160 obj.Brake = 0; 161 161 end 162 162 elseif ischar(val) 163 163 if strcmpi(val,'on') 164 obj. brake = 1;164 obj.Brake = 1; 165 165 elseif strcmpi(val,'off') 166 obj. brake = 0;166 obj.Brake = 0; 167 167 else 168 168 error('MATLAB:RWTHMindstormsNXT:InvalidBrake',... … … 178 178 switch lower(val) 179 179 case 'idle' 180 obj. regulationMode = 'IDLE';180 obj.RegulationMode = 'IDLE'; 181 181 case 'speed' 182 obj. regulationMode = 'SPEED';182 obj.RegulationMode = 'SPEED'; 183 183 otherwise 184 184 error('MATLAB:RWTHMindstormsNXT:InvalidRegulationMode',... … … 196 196 'TurnRatio is not an integer.'); 197 197 end 198 obj. turnRatio = fix(val);198 obj.TurnRatio = fix(val); 199 199 else 200 200 error('MATLAB:RWTHMindstormsNXT:InvalidTurnRatio',... … … 206 206 switch lower(val) 207 207 case 'idle' 208 obj. runState = 'IDLE';208 obj.RunState = 'IDLE'; 209 209 % Not supported at the moment 210 210 % case 'rampup' 211 211 % obj.runState = 'RAMPUP'; 212 212 case 'running' 213 obj. runState = 'RUNNING';213 obj.RunState = 'RUNNING'; 214 214 % Not supported at the moment 215 215 % case 'rampdown' … … 231 231 'TachoLimit is not an integer.'); 232 232 end 233 obj. tachoLimit = fix(val);233 obj.TachoLimit = fix(val); 234 234 else 235 235 error('MATLAB:RWTHMindstormsNXT:InvalidTachoLimit',... -
branches/atorf/RWTHMindstormsNXT-Lejos-Combined/@NXTmotor/stop.m
r267 r272 48 48 49 49 % Parameter checking is done in StopMotor 50 StopMotor(obj. port, brakemode);50 StopMotor(obj.Port, brakemode); -
branches/atorf/RWTHMindstormsNXT-Lejos-Combined/@NXTmotor/subsasgn.m
r267 r272 45 45 % *********************************************************************************************** 46 46 47 if ~isa(obj,'NXTmotor') 48 error('MATLAB:RWTHMindstormsNXT:InvalidObject',... 49 'No NXTmotor object.'); 50 end 51 47 52 StructLength = length(Struct); 48 53 -
branches/atorf/RWTHMindstormsNXT-Lejos-Combined/@NXTmotor/subsref.m
r267 r272 15 15 % obj(k) 16 16 17 % Author: Aulis Telle, IND, RWTH Aachen 17 % Signature 18 % Author: Aulis Telle (see AUTHORS) 19 % Date: 2008/08/15 20 % Copyright: 2007-2008, RWTH Aachen University 21 % 22 % 23 % *********************************************************************************************** 24 % * This file is part of the RWTH - Mindstorms NXT Toolbox. * 25 % * * 26 % * The RWTH - Mindstorms NXT Toolbox is free software: you can redistribute it and/or modify * 27 % * it under the terms of the GNU General Public License as published by the Free Software * 28 % * Foundation, either version 3 of the License, or (at your option) any later version. * 29 % * * 30 % * The RWTH - Mindstorms NXT Toolbox is distributed in the hope that it will be useful, * 31 % * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * 32 % * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * 33 % * * 34 % * You should have received a copy of the GNU General Public License along with the * 35 % * RWTH - Mindstorms NXT Toolbox. If not, see <http://www.gnu.org/licenses/>. * 36 % *********************************************************************************************** 37 38 if ~isa(obj,'NXTmotor') 39 error('MATLAB:RWTHMindstormsNXT:InvalidObject',... 40 'No NXTmotor object.'); 41 end 18 42 19 43 result = obj; -
branches/atorf/RWTHMindstormsNXT-Lejos-Combined/@NXTmotor/wait.m
r267 r272 27 27 % 28 28 29 % Author: Aulis Telle, IND, RWTH Aachen 29 % Signature 30 % Author: Aulis Telle (see AUTHORS) 31 % Date: 2008/08/15 32 % Copyright: 2007-2008, RWTH Aachen University 33 % 34 % 35 % *********************************************************************************************** 36 % * This file is part of the RWTH - Mindstorms NXT Toolbox. * 37 % * * 38 % * The RWTH - Mindstorms NXT Toolbox is free software: you can redistribute it and/or modify * 39 % * it under the terms of the GNU General Public License as published by the Free Software * 40 % * Foundation, either version 3 of the License, or (at your option) any later version. * 41 % * * 42 % * The RWTH - Mindstorms NXT Toolbox is distributed in the hope that it will be useful, * 43 % * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * 44 % * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * 45 % * * 46 % * You should have received a copy of the GNU General Public License along with the * 47 % * RWTH - Mindstorms NXT Toolbox. If not, see <http://www.gnu.org/licenses/>. * 48 % *********************************************************************************************** 49 50 51 if ~isa(obj,'NXTmotor') 52 error('MATLAB:RWTHMindstormsNXT:InvalidObject',... 53 'No NXTmotor object.'); 54 end 30 55 31 56 if nargout > 0 … … 41 66 42 67 data = read(obj); 43 if data.TachoLimit == 0 && ~ strcmp (data.RunState,'idle')68 if data.TachoLimit == 0 && ~ strcmpi(data.RunState,'idle') 44 69 warning('RWTHMINDSTORMS:MotorWait',... 45 70 'Motor running infinitely. Not waiting for this motor!'); … … 47 72 end 48 73 49 while ~ strcmp (data.RunState,'idle')74 while ~ strcmpi(data.RunState,'idle') 50 75 if exist('timedOut', 'var') && timeout > 0 && now >= endtime 51 76 timedOut = 1;
