Screenshots

RWTH - Mindstorms NXT Toolbox

click thumbnails to enlarge

Toolbox documentation Sensor Reading Functions by Category Watch Analog Sensor GUI Program Examples


Promotion Video

by Nene Vasquez and Angel Chacin - 30.06.2010



Applications

Roboarm

click thumbnails to enlarge

Roboarm Roboarm GUI for monitoring GUI for controlling Example Code


Arguments of Complex Numbers

click thumbnails to enlarge

LEGO machine Input dialog Machine output Visualization of calculated argument


Weighing machine

For more details on this weighing machine ("The resplendent Roman balance" built by University of Cambridge), see here.

click thumbnails to enlarge

Balance bot from University of Cambridge Balance plot from University of Cambridge
Weighing machine Results plot


Code Examples

Play Tone and Get Battery Level

Example to play a specific tone with the NXT Brick and retrieve the current battery level:

Prepare workspace by cleaning all old settings to be on the safe side.

COM_CloseNXT all
close all
clear all

% Open new Bluetooth connection according to the previously generated configuration file. handle = COM_OpenNXT('bluetooth.ini'); COM_SetDefaultNXT(handle);
% Play tone with frequency 800Hz and duration of 500ms. NXT_PlayTone(800,500);
% Get current battery level. voltage = NXT_GetBatteryLevel
% Close Bluetooth connection. COM_CloseNXT(handle);


Published with MATLAB® 7.5

Read Sound Sensor

Example to read the sound sensor value in db: Prepare workspace by cleaning all old settings to be on the safe side.

COM_CloseNXT all
close all
clear all

% Open new Bluetooth connection according to the previously generated configuration file. handle = COM_OpenNXT('bluetooth.ini'); COM_SetDefaultNXT(handle);
% Set the correct sound sensor mode and input port. OpenSound(SENSOR_2, 'DB');
% Get the current sound sensor value in dB. value = GetSound(SENSOR_2)
% Close the sound sensor. CloseSensor(SENSOR_2);
% Close Bluetooth connection. COM_CloseNXT(handle);


Published with MATLAB® 7.5

Drive Around Table (Motor Class)

Clear and close

COM_CloseNXT all
clear all
close all

Constants and so on

TableLength = 1000; % in degrees of motor rotations :-) QuarterTurnTicks = 219; % in motor degrees, how much is a 90° turn of the bot? Ports = [MOTOR_B; MOTOR_C]; % motorports for left and right wheel DrivingSpeed = 60; TurningSpeed = 40;

Open Bluetooth connetion

h = COM_OpenNXT('bluetooth.ini'); COM_SetDefaultNXT(h);

Initialize motor-objects:

mStraight = NXTMotor(Ports); % next command since we are driving in SYNC-mode. This should not be % necessary with correct default values, but at the moment, I have to set % it manually, mStraight.SpeedRegulation = false; % not for sync mode mStraight.Power = DrivingSpeed; mStraight.TachoLimit = TableLength; mStraight.ActionAtTachoLimit = 'Brake'; mTurn1 = NXTMotor(Ports(2)); % ports swapped because it's nicer mTurn1.SpeedRegulation = false; % we could use it if we wanted mTurn1.Power = TurningSpeed; mTurn1.TachoLimit = QuarterTurnTicks; mStraight.ActionAtTachoLimit = 'Brake'; mTurn2 = mTurn1; mTurn2.Port = Ports(1); % ports swapped again... mTurn2.Power = - mTurn1.Power;

Initialize Motors...

% we send this in case they should still be spinning or something... mStraight.Stop('off');

Start the engines, main loop begins (repeated 4 times)

% 4 times because we got 4 equal sides of the table :-) for j = 1 : 4

Drive

mStraight.SendToNXT();

Wait for the end end of table

mStraight.WaitFor();

Now please turn

mTurn1.SendToNXT(); mTurn1.WaitFor(); mTurn2.SendToNXT(); mTurn2.WaitFor();

Thats it. Repeat 4 times....

end%for

Done.

% Hey! End of a hard day's work Just to show good style, we close down our motors again: mStraight.Stop('off');

Close Bluetooth connection

COM_CloseNXT(h);


Published with MATLAB® 7.13

Last modified 6 years ago Last modified on Dec 30, 2011, 5:22:51 PM

Attachments (17)

Download all attachments as: .zip