MATLAb error using the Mindstorms NXT Toolbox for MATLAB

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
pyroblast
Posts: 4
Joined: 22 Feb 2013, 07:11

MATLAb error using the Mindstorms NXT Toolbox for MATLAB

Post by pyroblast »

Hi guys. I'm new here and new with the LEGO NXT Robot.

After installing the toolbox (I think that I've installed well) I managed to connect, through Bluetooth, to my robot. The first thing that I did was to test the connection making the robot doing a "beep".

After that, I tried to put my robot running using the example bellow (which I got somewhere in the web), just to see the robot moving, without success. The MATLAB prompt gave me this error: Matlab nxt Undefined function or method 'SetMotor' for input arguments of type 'double'. I've added the toolbox as it should (I think) using this kind of tutorial: http://www.mindstorms.rwth-aachen.de/tr ... wnload4.07 but even so I don't have a clue what might be causing this.

Can someone help me?

Code: Select all

Clean up
Close previous handles (if existing)
COM_CloseNXT all
clear all
close all
Constants
MaxDriveTime = 30; % in seconds, stop after this time...
USPort       = SENSOR_4;
Initialize NXT connection
handle = COM_OpenNXT('bluetooth.ini');
COM_SetDefaultNXT(handle);
Reset Motor / remember start position
ResetMotorAngle(MOTOR_B);
ResetMotorAngle(MOTOR_C);
StartPos = GetMotorSettings(MOTOR_B);
Prepare sensor
OpenUltrasonic(USPort)
And GO!
SetMotor(MOTOR_B);
    SyncToMotor(MOTOR_C);
    SetPower(60);
    SetAngleLimit(0);
    SetTurnRatio(0);
    SetRampMode ('off');
SendMotorSettings();
Detect wall (sensor loop)
tictic(1);
while(toctoc(1) < MaxDriveTime)
   if GetUltrasonic(USPort) < 30
       break
   end%if
end%while
Immediately stop all motors!
StopMotor('all', 'off');
% but where are we now?
CurPos = GetMotorSettings(MOTOR_B);
Signal
NXT_PlayTone(440, 1000);
Drive back home!
To try to understand what exactly the different rotation count values mean, we compare them just for fun
TotalAbsDist = StartPos.TachoCount - CurPos.TachoCount;
Dist         = CurPos.Angle;

SetMotor(MOTOR_B);
    SyncToMotor(MOTOR_C);
    SetPower(-60);
    SetAngleLimit(abs(Dist));
SendMotorSettings();
Wait until there
WaitForMotor(1, MaxDriveTime);

% brake
StopMotor('all', 'brake');

pause(1);
clean up
CloseSensor(SENSOR_4)
StopMotor ('all', 'off');
Close NXT connection
COM_CloseNXT(handle);
Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests