Code covered by the MathWorks Limited License

Highlights from
Embedded Coder Robot NXT Demo

image thumbnail

Embedded Coder Robot NXT Demo

by

 

15 Dec 2006 (Updated )

Offers an enjoyable Model-Based Design experience using Simulink models with Lego robots

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

nxtusb(varargin)
function obj = nxtusb(varargin)
%NXTUSB Constructor
%   OBJ = NXTUSB creates a NXTUSB object if MindStormsNXT has been connected
% via USB and the initialization of USB device hase succeeded.
%
%   See also NXTUSB/OPEN, NXTUSB/CLOSE, NXTUSB/READ, NXTUSB/WRITE, NXTUSB/DELETE

if ~ispc
  error('This command is for the PC(Windows) version only.')
end

switch nargin
    case 0
        try
            % call the private MEX function
            [nxterr id name] = mexusb('usbinit');
        catch
            rethrow(lasterror)
        end
    otherwise
        error('Too many input arguments specified.')
end

% update the properties
obj.CurrentState =nxterr;
obj.Id = id;
obj.Name = name;
obj = class(obj,'nxtusb');

Contact us