Changeset 775

Show
Ignore:
Timestamp:
08/31/09 21:53:47 (4 years ago)
Author:
atorf
Message:
  • Removed flood of warnings in .WaitFor?, if MotorControl is terminated during WaitFor?
  • Added possibility to suppress warnings in NXT_MessageRead by requesting status byte, just as in NXT_LSGetStatus…
  • Documentation updates (removed references to old motor commands)
  • ToolboxBenchmark? up2date for version 4.* now
  • Updated changelog as usual
Location:
trunk
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • trunk/doc/release.html

    r774 r775  
    3939    <li>Parameter <code>UseThisNXTMAC</code> of <code>COM_OpenNXTEx</code> can now also contain colons, 
    4040        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  
    4143    <li>Added examples in motor documentation</code></li> 
    4244    <li>Updated documentation in various places</code></li> 
     
    4547  <ul> 
    4648    <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> 
    4850    <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. 
    4951    <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  
    175175% 
    176176% 
    177 % See also: SendToNXT, ReadFromNXT, WaitFor, Stop, ResetPosition    
     177% See also: SendToNXT, ReadFromNXT, WaitFor, Stop, ResetPosition, 
     178% DirectMotorCommand 
    178179% 
    179180% 
  • trunk/mfiles/@NXTMotor/SendToNXT.m

    r764 r775  
    3939%+        NXT_PlayTone(400,500); 
    4040% 
    41 % See also: NXTMotor, ReadFromNXT, Stop, WaitFor, ResetPosition 
     41% See also: NXTMotor, ReadFromNXT, Stop, WaitFor, DirectMotorCommand 
    4242% 
    4343% Signature 
  • trunk/mfiles/@NXTMotor/WaitFor.m

    r764 r775  
    151151%% Actual waitfor-loop  
    152152 
     153warned236 = false; 
    153154mTimedOut = false; 
    154155hGlobalTimeOut = tic(); 
     
    175176    end%while 
    176177     
     178     
    177179    reply = ''; 
    178180    while(isempty(reply)) 
    179181        % this loop is to ALWAYS collect all packets we request!!) 
    180182         
    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         
    182196        %disp(sprintf('    WaitFor, Motor %d, reply = %s', obj.Port(1), reply)); 
     197         
    183198 
    184199        if ~isempty(reply) % some sort of reply 
     
    208223    end%while 
    209224 
     225    % check if warning236 -> noReplyFromEmbedded... warning was triggered: 
     226    if mTimedOut 
     227        break 
     228    end%if 
     229     
    210230    % check "global timeout" 
    211231    if (timeout ~= 0) && (toc(hGlobalTimeOut) > timeout) 
  • trunk/mfiles/CalibrateCompass.m

    r670 r775  
    3535%+ 
    3636%+     % 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(); 
    4139%+ 
    42 %+     WaitForMotor(MOTOR_A); 
     40%+     m.WaitFor(); 
    4341%+ 
    4442%+     % calibration should now be complete! 
  • trunk/mfiles/NXT_MessageRead.m

    r551 r775  
    1 function [message localInboxReturn] = NXT_MessageRead(localInbox, remoteInbox, removeFromRemote, handle) 
     1function [message localInboxReturn statusByte] = NXT_MessageRead(localInbox, remoteInbox, removeFromRemote, handle) 
    22% Retrieves a "NXT-to-NXT message" from the specified inbox 
    33 
     
    66% 
    77%   |[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)|  
    812% 
    913% Description 
     
    2327%   |localInboxReturn| is just the mailbox number that the message was read 
    2428%   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). 
    2533% 
    2634%   If no NXT handle is specified the default one (|COM_GetDefaultNXT|) is used. 
     
    5159% Signature 
    5260%   Author: Linus Atorf (see AUTHORS) 
    53 %   Date: 2009/02/27 
     61%   Date: 2009/08/31 
    5462%   Copyright: 2007-2009, RWTH Aachen University 
    5563% 
     
    107115 
    108116%% Check for errors 
     117statusByte = status; 
    109118[err errmsg] = checkStatusByte(status); 
    110119if err 
    111120     
    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 
    131142        end%if 
    132143    end%if 
  • trunk/mfiles/SwitchLamp.m

    r670 r775  
    3131%+   SwitchLamp(MOTOR_A, 'off'); 
    3232% 
    33 % See also: SetPower, SendMotorSettings, StopMotor, MOTOR_A, MOTOR_B, MOTOR_C 
     33% See also: NXTMotor, StopMotor, MOTOR_A, MOTOR_B, MOTOR_C 
    3434% 
    3535% Signature 
  • trunk/tools/ToolboxBenchmark.m

    r668 r775  
    4141portMotor2  = MOTOR_B; 
    4242  
     43motor1 = NXTMotor(portMotor); 
     44motor2 = NXTMotor(portMotor2); 
    4345 
    4446%% Connect to NXT 
     
    129131 
    130132% for motor read, we let the motor running... 
    131 SetMotor(portMotor) 
    132     SetPower(20) 
    133 SendMotorSettings 
    134 SetMotor(portMotor2) 
    135     SetPower(-20) 
    136 SendMotorSettings 
     133DirectMotorCommand(portMotor, 20, 0, 'on', 'off', 0, 'off'); 
     134DirectMotorCommand(portMotor2, -20, 0, 'on', 'off', 0, 'off'); 
    137135 
    138136fprintf('- Testing MOTOR READ... '); 
     
    209207        % randomly use different motors 
    210208        if rand > 0.5 
    211             dummy = GetMotorSettings(portMotor); 
     209            dummy = motor1.ReadFromNXT(); 
    212210        else 
    213             dummy = GetMotorSettings(portMotor2); 
     211            dummy = motor2.ReadFromNXT(); 
    214212        end%if 
    215213    end%function 
     
    218216        % randomly use different motors and settings 
    219217        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 
    226225        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 
    233233        end%if 
    234234