From earlier projects I knew how laborious the programming of something like that is apt to become, in particular with NXT-G; so this time, I decided to use leJOS NXJ, the Java platform for the NXT.
Still, I expected to have to invest quite some amount of time with writing a lot of complex program code, both for the master brick and the three slave NXT bricks.
But far from it!
I'm still quite out of my mind how incredibly ease such a task has become when using the RemoteNXT class that comes with the most previous release 0.9 of leJOS NXJ!
One (!) single line of code, and your master NXT is connected to a remote NXT:
RemoteNXT remoteNXT1 = new NXTRemote("NameOfARemoteNXT",Bluetooth.getConnector().
You do need even have to manually pair the two bricks!
From that point on in your program, you have access to all motors and sensors of the remotely controlled bricks (same as if they were directly plugged into your own remote control brick*); for instance, to run motor A on the remote brick, just call
remoteNXT1.A.forward();
One can use up to three remote bricks that way at the same time in one single master program.
Now, that's what I call a programming tool for the NXT!
Well done, leJOS guys!
*Actually, sort of: in the current release, you cannot use all the methods remotely that you have at your disposal in the local context, just the simple ones like forward(), backward and setSpeed()
No comments:
Post a Comment