Minimalistic remote control for the NXT


When using Philo's great NXT joystick remote control for my basketball-playing NXT robots at Fana'Briques in June, I noticed that the very young users had some difficulties in getting along with it (in particular due to the size and the problems they had with understanding how to manage turns). So for the SteinCHenwelt LEGO® event ten days ago, I decided to come up with a more simplified one that met the reduced requirements of my soccer robots that debuted there.
The result was the rather minimalistic Remote Control No 3, a Bluetooth-based NXT remote control that uses the four buttons on the NXT Brick itself to control the movement of a remote NXT robot (forward, backward, left, right).
The two attached touch sensors can be optionally used to trigger special functions on the controlled robot (in the case of the soccer robots, it was kicking the ball).

At SteinCHenwelt, the gamepad-oriented style of the remote control and its comparatively small size went down well with the youngsters (you can see its usage in the SteinCHenwelt movie).

Remote Control No 3
is a good option when you do not need to control the actual speed of the remote robot. For the SteinCHenwelt, I programmed it with leJOS NXJ, the Java platform for the NXT (the programs can be downloaded from the associated page at my NXT web site); however, writing NXT-G programs for it should not be that difficult, also.

Comments

Pe-ads said…
But, isn't it impossible to use the grey button? Doesn't it jsut shut the program down? Is there a way to change this in NXTG 2.0?

Thanks,

Pe-ads
NickNackGus said…
It would be difficult to use NXT-G without using a custom-made block to take control of the dark grey button, plus another block to read it; this is mainly because, by default, the dark grey button is the "escape" button. AKA, "Push this to close my program. Now."

However, RobotC supports the ability to take control of this button.

In case someone does some testing, takes control of the dark grey button, and can't end the program, one can easily remove the NXT's batteries to easily reset it. This also works when the brick freezes under other circumstances, and saves you from firmware update mode. I use this if my brick starts clicking, but appears to be in some weird cross between normal operation and firmware update mode...
Brian Davis said…
Actually, an NXT-G program that fully duplicates it would be impossible. While using the buttons for control is an easy concept, the grey "cancel" button has special limitations under the standard stock FW - it can *not* be read by the program, because it stops the running program. The rest of course would work fine.

I've often wondered why people use the touch sensors so much for manual input, when there are three built in to the NXT; thanks for another example of making good use of them.
Unknown said…
Ah, interesting to know that the grey button cannot be accessed programmatically in NXT-G that easily. In leJOS NXJ, you can attach a ButtonListener to it as easily as with the other three buttons.

To shut down the program, I used the two rectangular buttons pressed simultaneously.
Dave Parker said…
BTW, in NXT-G it is also not possible to read two NXT buttons (left, right, enter) being pressed simultaneously. The software interface does not prevent this, but in practice one button will always prevail by itself (unlike multiple touch sensors which works fine). So I have assumed that this is a hardware issue, but wasn't sure. Does anybody know if other NXT programming systems can see, e.g. the left and right arrow buttons being pressed at the same time?
NickNackGus said…
To Dave Parker: In NXT-G, I believe it is possible to read two pressed NXT buttons at once, (or close enough to trick humans into thinking so,) but it appears as though you did not write your program as you intended. In textual form, here is what I think your program looks like:

If(LeftIsPressed){
ActionLeft;/*always read*/
}
elseIf(MiddleIsPressed){
ActionMiddle;/*not read if left is pressed*/
}
elseIf(RightIsPressed){
ActionRight;/*not read if left or right are pressed*/
}
else{}

Your code should look like this:

If(LeftIsPressed){
ActionLeft;/*always read*/
}
If(MiddleIsPressed){
ActionMiddle;/*always read*/
}
If(RightIsPressed){
ActionRight;/*always read*/
}

"
Matthias Paul Scholz said...
Ah, interesting to know that the grey button cannot be accessed programmatically in NXT-G that easily. In leJOS NXJ, you can attach a ButtonListener to it as easily as with the other three buttons.

To shut down the program, I used the two rectangular buttons pressed simultaneously.
"

This is true. I have tried installing NXJ on my NXT (I got it on there, but couldn't get anywhere after that. I blame Vista, and am in the middle of a swap to Ubuntu. Help required for installing BricxCC, but that's another problem, if not post.)

Now, if only there was a way to terminate the program by pushing all buttons. That would leave 15 button combinations! (What, you mean that "normal people" don't know binary? Looks like I have a carreer in engineering ahead of me!)
Dave Parker said…
I don't think there's anything wrong with my programs. For example, the Sensor Meter program at http://www.nxtprograms.com/sensor_meter/index.html
displays the three buttons independently of each other without any "else" interaction, but you can't get it to display more than one NXT button.

Also, just now I tried a very simple test that displayed the state of just the right arrow button. It will never say pressed if the left button is also down.

I also tried two nested Switches to get a Left/Right/Both/Neither result, and you can never get it to say Both. Left always wins. If this worked, I would be all over it for remote control purposes, but I haven't been able to get it to work.
Pe-ads said…
Thanks for clearing up my problems, guys!
Also, @Tim, Ubuntu is so much better than Vista!

Pe-ads
NickNackGus said…
"Dave Parker said...
I also tried two nested Switches to get a Left/Right/Both/Neither result, and you can never get it to say Both. Left always wins. If this worked, I would be all over it for remote control purposes, but I haven't been able to get it to work."

Is this all in one switch? If so, then odds are, at some low level that you cannot get to, switches are supposed to check the tabs from left to right. Either seperate this into multiple switches, or move both to the left. Everything should be fine after that.
Dave Parker said…
Tim, I have tried several different approaches to Switch layout, all work with multiple touch sensors but none work with multiple NXT button presses. Give it a try and you'll see what I mean. If anyone gets it to work, let me know. I will try this with NXC when I get a chance to see if its just an NXT-G issue.
Dave Parker said…
I just tried NXC, both the high level and low-level button sensor functions, and it can't detect simultaneous NXT button presses either. The left arrow being pressed prevents the right arrow button from being seen. So it looks like a firmware or hardware issue to me.
NickNackGus said…
There are three intrinsic variables defined for NXT button management. nNxtButtonPressed This read-only variable contains the currently pressed button. [The NXT firmware only supports recognition of one button at a time]. The value is one of the following: typedef enum{ kNoButton = 0xFF, kExitButton = 0, kRightButton = 1, kLeftButton = 2, kEnterButton = 3} TButtonMasks; nNxtButtonTask This variable contains the task number that should be started whenever any NXT button is pushed. There are three value ranges: -1 Indicates that the normal system processing for exit button should be used. Anything else will over-ride the system actions. Note if overwritten, you will not be able to stop program running with button control. 1..9 Indicates that the indicated task (1..9) should be started whenever the exit button is pressed. Task will only be started once per keypress. Other Standard processing is overwritten. No task will be started when exit button is pushed; user program must used nNxtButtons to check for nNxtExitClicks Contains the number of 'clicks' that must be received to abort a running program. The default value is one. But if you want to use the EXIT button in your program you can set this to 2 (for a double click) or 3 (triple click) or higher so that there is always an escape sequence, independent of your user program, for existing your program. This variable is reset to 1 before the start of any program. If you really want to override the 'abort' check, you can continually modify this variable. The count of current EXIT clicks is reset whenever this variable is written. It may be easier to use the method of starting a task whenever a button is pressed. The user program can look at the 'nNxtButtonPressed' variable to determine which button has been pressed. How to Terminate/Abort A Program when Buttons are Hijacked When user program has gained control of the NXT buttons, the regular processing of the buttons is stopped. This means the EXIT button will not be recognized as a command to stop the end user program. So there must be an escape sequence to allow for this. Several different schemes were tried and the following was finally adopted for ROBOTC. A program is aborted by counting the number of "clicks" on the EXIT button. The normal default case is that a single click will abort a program. Setting this to a higher value (double or tripe clicks) will still allow user program to use EXIT button, but firmware will still have the capability to abort program Notes on NXT Hardware: 1. Buttons on the NXT are not individually read. Instead there is are several resistors in series that are shorted by pressing the individual keys. This is fed into a single input pin where an A-to-D conversion is performed. Analyzing the result indicates which key is pressed. 2. A byproduct of this is that the NXT can only properly handle a single keypress at a time. If multiple keys are pressed, then the firmware recognizes the key that generates the lowest resistance. Only this key is reported to the user program. 3. A byproduct is that you cannot design a user interface that tries to use two keys depressed at the same time. 4. The firmware recognizes button depresses in the following order(low to high): left, right, enter, exit.

From "NXT button.c" sample of RobotC. Formatting lost in order to fit within char limit of this post.

With new blocks/low-level calls, this should work outside of RobotC.

Popular Posts