Changeset 775
- Timestamp:
- 08/31/09 21:53:47 (4 years ago)
- Location:
- trunk
- Files:
-
- 8 modified
-
doc/release.html (modified) (2 diffs)
-
mfiles/@NXTMotor/NXTMotor.m (modified) (1 diff)
-
mfiles/@NXTMotor/SendToNXT.m (modified) (1 diff)
-
mfiles/@NXTMotor/WaitFor.m (modified) (3 diffs)
-
mfiles/CalibrateCompass.m (modified) (1 diff)
-
mfiles/NXT_MessageRead.m (modified) (5 diffs)
-
mfiles/SwitchLamp.m (modified) (1 diff)
-
tools/ToolboxBenchmark.m (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/release.html
r774 r775 39 39 <li>Parameter <code>UseThisNXTMAC</code> of <code>COM_OpenNXTEx</code> can now also contain colons, 40 40 i.e. both <code>'00:16:12:34:56:78'</code> and <code>'001612345678'</code> are valid</li> 41 <li>Removed a possible "flood of warnings" in <code>NXTMotor.WaitFor()</code> if NXT program MotorControl is being terminated during 42 execution 41 43 <li>Added examples in motor documentation</code></li> 42 44 <li>Updated documentation in various places</code></li> … … 45 47 <ul> 46 48 <li>This release has <i>milestone</i> status, so there may be remaining bugs, or documentation might be outdated in some places</li> 47 <li>Tutorials in "Programming Robots", especially about USB connections and Motors, are not fully up-to-date and complete yet.</li>49 <li>Tutorials in "Programming Robots", especially about USB connections and motors, are not fully up-to-date and complete yet.</li> 48 50 <li>The toolbox programs <code>ToolboxTest</code> and <code>ToolboxBenchmark</code> are not up to date yet and are hence not included in this release. 49 51 <li>Mixing methods from the <code>NXTMotor</code> class and the function <code>DirectMotorCommand</code> can lead to warnings or other problems.</li> -
trunk/mfiles/@NXTMotor/NXTMotor.m
r765 r775 175 175 % 176 176 % 177 % See also: SendToNXT, ReadFromNXT, WaitFor, Stop, ResetPosition 177 % See also: SendToNXT, ReadFromNXT, WaitFor, Stop, ResetPosition, 178 % DirectMotorCommand 178 179 % 179 180 % -
trunk/mfiles/@NXTMotor/SendToNXT.m
r764 r775 39 39 %+ NXT_PlayTone(400,500); 40 40 % 41 % See also: NXTMotor, ReadFromNXT, Stop, WaitFor, ResetPosition41 % See also: NXTMotor, ReadFromNXT, Stop, WaitFor, DirectMotorCommand 42 42 % 43 43 % Signature -
trunk/mfiles/@NXTMotor/WaitFor.m
r764 r775 151 151 %% Actual waitfor-loop 152 152 153 warned236 = false; 153 154 mTimedOut = false; 154 155 hGlobalTimeOut = tic(); … … 175 176 end%while 176 177 178 177 179 reply = ''; 178 180 while(isempty(reply)) 179 181 % this loop is to ALWAYS collect all packets we request!!) 180 182 181 reply = NXT_MessageRead(OutboxNr, OutboxNr, true, handle); 183 % request statusByte so that we don't get flooded with error msgs... 184 [reply dummy statusByte] = NXT_MessageRead(OutboxNr, OutboxNr, true, handle); 185 186 % ignore error 64 187 if (statusByte ~= 0) && (statusByte ~= 64) % 64 = "Specified mailbox queue is empty" 188 if (statusByte == 236) && (~warned236) % MATLAB:RWTHMindstormsNXT:messageReadWithNoActiveProgram 189 warned236 = true; 190 warning('MATLAB:RWTHMindstormsNXT:embeddedMotorControlSeemsTerminated', 'The embedded NXC program MotorControl should be running on the NXT brick. It seems the program is not running and/or was terminated accidentally. Please restart it or create a new NXT handle! Continuing...') 191 end%if 192 %NOTE we're ignoring all other errors here... 193 end%if 194 195 182 196 %disp(sprintf(' WaitFor, Motor %d, reply = %s', obj.Port(1), reply)); 197 183 198 184 199 if ~isempty(reply) % some sort of reply … … 208 223 end%while 209 224 225 % check if warning236 -> noReplyFromEmbedded... warning was triggered: 226 if mTimedOut 227 break 228 end%if 229 210 230 % check "global timeout" 211 231 if (timeout ~= 0) && (toc(hGlobalTimeOut) > timeout) -
trunk/mfiles/CalibrateCompass.m
r670 r775 35 35 %+ 36 36 %+ % compass is attached to motor A, rotate 2 full turns 37 %+ SetMotor(MOTOR_A); 38 %+ SetPower(5); 39 %+ SetAngleLimit(720); 40 %+ SendMotorSettings; 37 %+ m = NXTMotor('A', 'Power', 5, 'TachoLimit', 720) 38 %+ m.SendToNXT(); 41 39 %+ 42 %+ WaitForMotor(MOTOR_A);40 %+ m.WaitFor(); 43 41 %+ 44 42 %+ % calibration should now be complete! -
trunk/mfiles/NXT_MessageRead.m
r551 r775 1 function [message localInboxReturn ] = NXT_MessageRead(localInbox, remoteInbox, removeFromRemote, handle)1 function [message localInboxReturn statusByte] = NXT_MessageRead(localInbox, remoteInbox, removeFromRemote, handle) 2 2 % Retrieves a "NXT-to-NXT message" from the specified inbox 3 3 % … … 6 6 % 7 7 % |[message localInboxReturn] = NXT_MessageRead(LocalInbox, RemoteInbox, RemoveFromRemote, handle)| 8 % 9 % |[message localInboxReturn statusByte] = NXT_MessageRead(LocalInbox, RemoteInbox, RemoveFromRemote)| 10 % 11 % |[message localInboxReturn statusByte] = NXT_MessageRead(LocalInbox, RemoteInbox, RemoveFromRemote, handle)| 8 12 % 9 13 % Description … … 23 27 % |localInboxReturn| is just the mailbox number that the message was read 24 28 % from (again, see official Mindstorms communication protocol). 29 % 30 % Optionally, the packet's statusbyte is returned in the output argument 31 % |statusByte|, if requested. Warning from this functions will then be 32 % supressed (i.e. no warnings are raised then). 25 33 % 26 34 % If no NXT handle is specified the default one (|COM_GetDefaultNXT|) is used. … … 51 59 % Signature 52 60 % Author: Linus Atorf (see AUTHORS) 53 % Date: 2009/0 2/2761 % Date: 2009/08/31 54 62 % Copyright: 2007-2009, RWTH Aachen University 55 63 % … … 107 115 108 116 %% Check for errors 117 statusByte = status; 109 118 [err errmsg] = checkStatusByte(status); 110 119 if err 111 120 112 % ignore error 64: "Specified mailbox queue is empty" 113 if status ~= 64 114 % special error 236: "No active program" 115 % received when indeed no program is running 116 % apparently MessageRead only works when an NXC 117 % program is running at the same time?! 118 if status == 236 119 warning('MATLAB:RWTHMindstormsNXT:messageReadWithNoActiveProgram', 'NXT_MessageRead was called while no program (NXT-G / NXC / NBC) is being executed on the NXT brick. Apparently, the direct command MessageRead will not work then. You can safely ignore this warning by calling warning(''off'', ''MATLAB:RWTHMindstormsNXT:messageReadWithNoActiveProgram'')'); 120 else 121 oldstate = DebugMode(); 122 DebugMode on; 123 % TODO It is probably better to display a real warning here instead 124 % of a "debug" textOut message that will be deactivated most of the 125 % time. However this is a very rare condition that should not occur 126 % using correctly implemented protocol commands anyway. 127 textOut(sprintf('Packet (reply to %s) contains error message %d: "%s"\n' ,commandbyte2name(cmd), status, errmsg)); 128 DebugMode(oldstate); 129 % increase handle's error-count by 1 130 handle.TransmissionErrors(1); 121 if nargout < 3 122 % ignore error 64: "Specified mailbox queue is empty" 123 if status ~= 64 124 % special error 236: "No active program" 125 % received when indeed no program is running 126 % apparently MessageRead only works when an NXC 127 % program is running at the same time?! 128 if status == 236 129 warning('MATLAB:RWTHMindstormsNXT:messageReadWithNoActiveProgram', 'NXT_MessageRead was called while no program (NXT-G / NXC / NBC) is being executed on the NXT brick. Apparently, the direct command MessageRead will not work then. You can safely ignore this warning by calling warning(''off'', ''MATLAB:RWTHMindstormsNXT:messageReadWithNoActiveProgram'')'); 130 else 131 oldstate = DebugMode(); 132 DebugMode on; 133 % TODO It is probably better to display a real warning here instead 134 % of a "debug" textOut message that will be deactivated most of the 135 % time. However this is a very rare condition that should not occur 136 % using correctly implemented protocol commands anyway. 137 textOut(sprintf('Packet (reply to %s) contains error message %d: "%s"\n' ,commandbyte2name(cmd), status, errmsg)); 138 DebugMode(oldstate); 139 % increase handle's error-count by 1 140 handle.TransmissionErrors(1); 141 end%if 131 142 end%if 132 143 end%if -
trunk/mfiles/SwitchLamp.m
r670 r775 31 31 %+ SwitchLamp(MOTOR_A, 'off'); 32 32 % 33 % See also: SetPower, SendMotorSettings, StopMotor, MOTOR_A, MOTOR_B, MOTOR_C33 % See also: NXTMotor, StopMotor, MOTOR_A, MOTOR_B, MOTOR_C 34 34 % 35 35 % Signature -
trunk/tools/ToolboxBenchmark.m
r668 r775 41 41 portMotor2 = MOTOR_B; 42 42 43 motor1 = NXTMotor(portMotor); 44 motor2 = NXTMotor(portMotor2); 43 45 44 46 %% Connect to NXT … … 129 131 130 132 % for motor read, we let the motor running... 131 SetMotor(portMotor) 132 SetPower(20) 133 SendMotorSettings 134 SetMotor(portMotor2) 135 SetPower(-20) 136 SendMotorSettings 133 DirectMotorCommand(portMotor, 20, 0, 'on', 'off', 0, 'off'); 134 DirectMotorCommand(portMotor2, -20, 0, 'on', 'off', 0, 'off'); 137 135 138 136 fprintf('- Testing MOTOR READ... '); … … 209 207 % randomly use different motors 210 208 if rand > 0.5 211 dummy = GetMotorSettings(portMotor);209 dummy = motor1.ReadFromNXT(); 212 210 else 213 dummy = GetMotorSettings(portMotor2);211 dummy = motor2.ReadFromNXT(); 214 212 end%if 215 213 end%function … … 218 216 % randomly use different motors and settings 219 217 if rand > 0.5 220 SetMotor(portMotor) 221 SetPower(45) 222 SpeedRegulation on 223 SetAngleLimit(3446) 224 SetRampMode down 225 SendMotorSettings 218 DirectMotorCommand(portMotor, 45, 3446, 'on', 'off', 0, 'down'); 219 % SetMotor(portMotor) 220 % SetPower(45) 221 % SpeedRegulation on 222 % SetAngleLimit(3446) 223 % SetRampMode down 224 % SendMotorSettings 226 225 else 227 SetMotor(portMotor2) 228 SetPower(-80) 229 SpeedRegulation off 230 SetAngleLimit off 231 SetRampMode up 232 SendMotorSettings 226 DirectMotorCommand(portMotor2, -80, 3446, 'off', 'off', 0, 'up'); 227 % SetMotor(portMotor2) 228 % SetPower(-80) 229 % SpeedRegulation off 230 % SetAngleLimit off 231 % SetRampMode up 232 % SendMotorSettings 233 233 end%if 234 234
