This version is just an incremental improvement of Beta 17f. It fixes a problem with nxt.Reboot() and that's about it.
There's also a new tutorial on setting up multiple Bluetooth connections with NXTs.
This version is just an incremental improvement of Beta 17e. It has an improved nxt.HeapInfo() funciton that lets you dump the current state of the heap to the console.
If you are using pbLua and have a website that features a model or tutorial based on pbLua, I'd like to put a link to it here! Feel free to email me details and I'll post it here.
This is the official place for news and downloads of pbLua, an exciting new text-based language for the Mindstorms NXT. Way back in 1998, I got one of the first Mindstorms RCX programmable bricks and promptly set about writing a text based language for it. The result was pbForth, which was used in many different applications around the world. The pbForth code was compiled on the RCX by the RCX - no external computer was needed. pbForth was very fast, but the language was frankly scary to read and learn.
Fast forward to 2005. Lego releases the next generation robotics kit - the Mindstorms NXT. Inside the NXT brick is a 32 bit ARM7 microcontroller with 256K of FLASH and 64K of RAM. The 3 motors in the kit are powerful, and have built in rotation sensors. There are 4 sensors in the kit, including touch, light, sound, and even an ultrasonic range finder.
The programming system is redesigned from the ground up and is GUI based. It's ideal for 95% of all robots you are likely to build, and it is especially kid-friendly. But for dinosaurs like me, it's not text based.
As many of you know, I was one of the 4 users selected for the Mindstorms User Panel that was profiled in the February 2006 issue of Wired Magazine. I was called a "firmware expert" in the article, and I guess that's what I do for a living. At the time I was already thinking about what kind of language would be ideal for programming the new NXT.
And that's when I discovered Lua. It's a really beautiful little language that's used in all kinds of applications. But more importantly for our purposes, it has these characteristics:
To see how simple Lua is to read and write, Steve Hassenplug designed a short line following program. I've taken the liberty of adding some comments so that even a non-Lua programmer can understand what's going on:
-- All NXT api functions are in the nxt table, so nxt.apiname() is the
-- standard way to access those functions
function FollowLine()
-- Set up sensor 3 to be an active light sensor
nxt.InputSetType(3,0)
nxt.InputSetState(3,1,0)
nxt.InputSetDir(3,1,1)
-- Motors 1 and 2 are in Brake Mode and have regulation enabled
nxt.OutputSetRegulation( 1, 1, 1 )
nxt.OutputSetRegulation( 2, 1, 1 )
-- Set up the light and dark thresholds and the motor speeds
local T1 = 600
local T2 = 630
local SpeedSlow = 50
local SpeedFast = 100
-- LoopCount is just to see how fast Lua is running the line
-- following loop for 10 seconds
local LoopCount = 0
-- Read the msec timer and get ready to run the loop for 10 seconds
local t=nxt.TimerRead()+10000
while t > nxt.TimerRead() do
-- Read the light sensor and save the result
local SV = nxt.InputGetGetStatus(3)
-- If the sensor is reading below the threshold (white) turn towards
-- the line
if SV < T2 then
nxt.OutputSetSpeed(1,32,SpeedFast)
else
nxt.OutputSetSpeed(1,32,SpeedSlow)
end
-- If the sensor is reading above the threshold (black) turn away
-- from the line
if SV > T1 then
nxt.OutputSetSpeed(2,32,SpeedFast)
else
nxt.OutputSetSpeed(2,32,SpeedSlow)
end
-- Count the number of times we've run the loop
LoopCount = LoopCount + 1
end
-- Make room on the LCD for a line of text, and print the number
-- of times we ran through the loop
nxt.DisplayScroll()
nxt.DisplayText(string.format("%i",LoopCount))
-- Don't forget to turn the motors off!
nxt.OutputSetSpeed(1,0,0)
nxt.OutputSetSpeed(2,0,0)
end
-- Now run the FollowLine function we just defined!
FollowLine()
Now that's readable code! Oh, and it runs the main loop 61,000 times in 10 seconds - so it's fast too!