Showing posts with label remote control. Show all posts
Showing posts with label remote control. Show all posts

Saturday, November 5, 2011

Remotely controlling NXT robots using leJOS NXJ

For a project where multiple NXT bricks need to be remotely controlled by a single remote control, I decided to build that control with LEGO® MINDSTORMS NXT also, so that one (master) brick would control three other (slave) bricks wirelessly using Bluetooth.
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()

Tuesday, December 21, 2010

Google's AppInventor for Android supports LEGO® MINDSTORMS NXT now


On Friday, Google announced on the Google Code Blog that AppInventor, its Cloud-based programming platform for Android, supports LEGO® MINDSTORMS NXT now:


"[...] a fun 20% robotics project that resulted in three ways you can play with your iRobot Create®, LEGO® MINDSTORMS®, or VEX Pro® through the cloud. We did this by enhancing App Inventor for Android, contributing to the open source Cellbots Java app, and beefing up the Cellbots Python libraries. Together these apps provide new connectivity between robots, Android, the cloud, and your browser."

Seems the whole mobile-NXT thing is gaining momentum. :)

Try it out and tell us about your experiences.

Wednesday, March 24, 2010

NXT 2.0 Race Car, Remote Controls


I have posted a new Race Car design for NXT 2.0 and three remote control strategies to go along with it. This project was designed to look like a real car, steer like a car with pivoting front wheels, and go fast. It works best with remote control, but you can't control it with the built-in NXT 2.0 software remote control because of the way the steering works (nor very easily with the "nxt-remote" program), so I also posted three NXT-based remote control stategies: one wired, and two Bluetooth from a second NXT.

Now I know that a remote controlled car is not exactly the most original thing you can do with an NXT set, but at some point you need to do one... This was actually one of the first designs I did with the NXT 2.0 set when it came out because the parts selection was screaming out "car" to me with the new car-like tires, but I am just now getting around to finishing it off and posting it.

The 5 Button Remote Control (Bluetooth) was actually designed by my son. We were playing "Battle Bots" in our Robotics Club, and we kept finding that a LEGO remote control of any complexity when in the hands of a kid in the heat of battle will end up coming apart somehow. So I challanged the kids to come up with a remote design that was sturdy enough to not come apart, but still allowed decent control of driving and a weapon/action at the same time. This "5 button" design is so simple that you can build it under 1 minute, but it is super sturdy, and the controls are positioned so that you can use both the finger and thumb buttons at the same time. My son would also like to point out that it has Wii-style wrist safety straps as well :-)

The Steering Remote Control (Bluetooth) is mechanically similar to my earlier Dial Remote Control but puts the control wheel horizontal so that it feels and acts like a steering wheel, which is good for the Race Car and similar things, and I rearranged the ergonomics a bit. And the control strategy is different.

If you are not a fan of remote control, the Race Car can also do some simple autonomous tasks with the color sensor mounted underneath, although the car-like steering does not allow very tight or precise turning.

Here is a video of the Race Car using all the different control stratgies:

Tuesday, January 12, 2010

NXT 2.0 Dial Remote Control



I have posted an NXT 2.0 Dial Remote Control project, which is an updated version of the NXT 1.0 version posted last year. This is a simple-to-build and sturdy remote control designed for NXT-to-NXT Bluetooth control, which has a somewhat unique feature in that you can get very smooth and progressive movements based on the way that the dial control works (the speed of the dial rotation maps to the robot motor speed instead of the usual dial/lever position technique). This control works particularly well to control the Forklift project.

In addition to the Bluetooth programs (one for the remote and one for the controlled bot), the project includes a program that shows how you can use the Dial Remote Control to control two motors via wires, with only a single NXT kit. Along these lines (wired remote control), I also posted a separate Mini Rover with 3-Button Remote project that shows a much simpler wired remote program using only the 3 buttons on the NXT.

To throw in something new for the Dial Remote Control over the 1.0 version, I added a touch sensor to give you five total actions to choose from, and also a bar to prevent you from accidentally pressing the dark gray program abort button by mistake when using the remote.

The NXT 2.0 Dial Remote Control is similar enough to the 1.0 version that I didn't make a new video, but here is a video of the 1.0 version controlling the 1.0 Forklift project.

Thursday, December 31, 2009

NXT 2.0 Forklift


I have posted an NXT 2.0 Forklift project, which is a variation on my original NXT 1.0 version. The NXT 2.0 version adds the use of the color sensor as a "warning light" to shine three different colors depending on what the forklift is doing (e.g. light flashes red and NXT beeps when backing up).

The forklift can do autonomous tasks with the help of the ultrasonic sensor, and you can also control it via Bluetooth remote control. The built-in remote control feature in the NXT 2.0 software can be used to drive the forklift, but it is inconvenient to control the lift because you cannot easily reverse the 3rd motor on the fly using the built-in remote control. Fortunately, Anders Søborg has provided this free PC Bluetooth Vehicle Remote program, which is more flexible, so instructions for using this are included. Anders' program works fine with either NXT 1.0 or NXT 2.0, so it is a nice upgrade for 2.0 users or a great new tool for 1.0 users (PC only, sorry no Mac version).

Instructions and programs to control this forklift by Bluetooth from another NXT will follow in my next project post.

Here is a video of the forklift in action:

Saturday, August 29, 2009

NXT 2.0 Hammer Car


This Hammer Car project for NXT 2.0 extends the 3-Motor Chassis design to add a swinging hammer weapon up front, and extends the 2-Button Remote Control program to add wired remote control for the hammer (as well as a fun laughing sound) from the same two buttons that control the driving and steering. In order to squeeze 6 operations (left, right, forward, stop, hammer, laugh) out of only two buttons, timers are used to distinguish the difference between a button being pressed and held down vs. quickly tapped, as shown in this video:



I posted an NXT 1.0 Hammer Car project about a year ago that used only one touch sensor for the remote control. It used a similar timing trick, but was significantly harder to maneuver due to having only one button control.

Thursday, August 27, 2009

NXT 2.0 2-Button Remote Control

The NXT 2.0 kit doesn't come with a handheld remote control (there is a new software one for Bluetooth control from your computer), but it does come with two touch sensors, so you can use them to make some simple wired remote controls. A remote control is useful for several things like prototyping, experimenting, as well as just to have some fun controlling your creations. Also, some creations you build might be partailly autonomous and partially user-interactive, so it is useful to have some remote control programming strategies under your belt.

This NXT 2.0 2-Button Remote Control project is extremely simple mechanically, but the main point is to show some basic strategies for 2-button remote control programming. Two programs are provided, a simple one that just chooses one of four actions depending on the state of the buttons (left, right, both, neither), and a more complex one that adds timers to make driving motions that accelerate smoothly in each direction. More complex or different variations will follow in other projects.

Here is a video of these two programs used to drive the 3-Motor Chassis vehicle:


So what about NXT 1.0? Can you use this stuff too? Yes and No. NXT 1.0 only comes with one touch sensor, but you can easily buy another touch sensor. There is nothing really NXT 2.0-specific about the programs I have posted, but they were created and saved by NXT 2.0. I tried using them on NXT 1.0, and here's what happened. You can open and view them in the 1.X software, but I tried to compile and download to the brick, and I got "Internal Compiler Error". So, you can at least look at them to study how they work, then do something similar in a new 1.X program.

Sunday, May 24, 2009

NXT Steering Rover

This simple NXT Steering Rover vehicle steers by pivoting its front wheels like a real car, and is controlled by a wired remote control. The remote control has a steering wheel to control the steering, and buttons to make the rover go forward, backward, slower, and faster.

Two ways are shown to handle the steering. In the first method, the steering wheel on the remote control is used as an electrical generator to produce and send electrical power directly to the steering motor on the vehicle through a wire, without the NXT even being involved. In this mode, the steering even works when the NXT is off! In the second method, the steering wheel acts as a rotation sensor for the NXT, and the NXT then controls the vehicle's steering motor by program control through a different wire.

In the program-controlled steering method, the steering motor on the vehicle is acting like a "servo" motor, which seeks out the desired position as determined by the other motor (the steering wheel), which is acting like a rotation sensor. Doing this is surprisingly tricky, given that the end effect is so simple. The program measures the degree difference between the two motors and then continuously modifies the direction and power level of the servo motor to try to zero in on the desired position without any noticeable overshooting or oscillation (see the program provided).

Given the very simple construction of the rover (solid rear drive axle and parallel arm steering), turning very sharply doesn't work very well, so the model can also serve as a demonstration for why real cars need a differential and perhaps Ackermann steering. Some links are provided for users who want to try to investigate these topics.

Here is a video of the rover in action:

Sunday, April 5, 2009

Building instructions for Raven and NXT Switchboard


Finally, I've found the time to create building instructions for The Raven, my Black NXT model, and for the NXT Switchboard, a NXT remote control, both of which I posted about recently here, thus following a popular demand.

Sunday, March 15, 2009

NXT Switchboard: another remote control for the NXT

These days, I pondered about a way to test new robots already during development phase to figure out reasonable and working usage of the NXT motors, without the need to write (and frequently adapt) a separate program each time.
It occurred to me that (apart from approaches that use PC remote control) it might be a good strategy to create a NXT-based Bluetooth remote control that allows for separate control of each motor independently.
And here it is: the NXT Switchboard.



The program that actually runs on the robot in development (presently implemented in leJOS NXJ, the Java platform for the NXT) is a general-purpose one (it simply receives and handles the control signals sent by the remote control) and can be re-used for each robot.

Of course, one can use the NXT Switchboard also to remotely control finished robots (if required).

Addendum: in the video, the hand wheels are operated by my invisible Chesire Cat ;).

Thursday, January 29, 2009

PF IR Receiver as Wireless Touch Sensor


Here are the details on the trick that I used in my Battle Tank project to get the NXT to read sensor input from the Power Functions remote control. See the "Method 1". This allows the NXT to see the IR receiver as a single touch sensor, which is actually quite easy to do if you have the two wires needed (PF Extension Wire and RCX Conversion Cable). The "Method 2" was an earlier and much more complex way to get full control from both levers (9 states).

You only get one touch sensor out of this, but with a little timing trick in the NXT program, I made the single PF lever control two NXT-triggered functions on the Battle Tank. A quick press and release of one lever triggers the scissor stabber with one NXT motor, and a press and hold of the same lever triggers the dart gun with another NXT motor. This leaves the other lever on the same channel open to run a PF M-motor in both directions to implement the unfolding saw blade (same M-motor folds/unfolds via a worm gear while also spinning the blade by up-gearing). Then the other IR receiver is attached to the two PF XL-motors to do the driving on another channel.

It looks like you could extend this trick to get two touch sensors by connecting the other half of the IR receiver to a second sensor port on the NXT, but this doesn't work. Pressing either lever ends up triggering both touch sensors. Wondering what was going on here, I consulted Philo, who kindly explained that the whole setup is electrically questionable to begin with because the PF and NXT sides don't share a common ground, but it ends up working and being safe with one sensor, but attaching two creates a strange current flow and also results in a short circuit condition if the levers are pushed in opposite directions. So don't bother trying that...

Monday, January 26, 2009

NXT + PF Battle Tank



This "Battle Tank" creation uses parts from the NXT (8527) set and the 8275 Power Functions Bulldozer set (sadly, no longer available from LEGO). It combines the NXT and two NXT motors with a LEGO Power Functions setup of 2 XL motors, 1 M motor, 2 IR receivers, and 1 PF battery pack, and various parts from both sets. The whole model was designed from scratch from the ground up. The treaded chassis in particular outperforms the bulldozer chassis in several ways I think (faster, climbs better, treads don't fall off when turning on carpet, more compact, fewer parts), in addition to making space in the center down low for the NXT brick. I built this and filmed the video clips a while back but never got around to editing and posting the video. But now that I am on a roll with remote control...

The NXT part of this is not that complex or interesting, with one notable exception: I found a way to get the Power Functions IR receiver to give sensor input to the NXT, so that you can partially control NXT creations using the PF remote control, which is what made this project possible. I will blog on the details of this in a separate post.

I also put the ultrasonic sensor on it so that I could do something autonomous with it too, but I never got around to it because the remote control was too much fun :-). And then I needed the parts so I took it all apart...

Here is the video. Sorry, no building instructions for this one...

Saturday, January 24, 2009

NXT Dial Remote Control



By now you know that I like remote control... So, I set out to design an NXT-to-NXT Bluetooth remote control for my Forklift project, for people with two NXTs, and this Dial Remote Control is what I came up with. My goals for the remote were:

1. Simple and sturdy, low part count

2. High "on-center" stability (whenever you take your hands off the remote, the robot should stop, no need to find a center position)

3. The motor power is always applied very progressively (no jerking on or off) with easy fine-control for accurate small movements, but you can still get full power.


For these, I was willing to give up the ability to drive forward and steer at the same time (only straight and pivot turns are available), or drive and operate the 3rd motor at the same time.


The mechanics is very simple, basically just a single motor attached to the NXT. You choose one of four functions to control by pressing one of the 3 NXT buttons (or no button), then use the motor (dial) to apply power/value to that motor/function. The key is that it is the speed of the dial, not it's absolute position, that determines the power applied to the motor. This gives you a nice progressive feel, kind of like an iPod wheel, and the hands-off stability in any position.


The remote can control many different types of robots/machines, many with no modifications to the program (typical 2-motor vehicles with optional 3rd motor), and I also included a wired remote variation for those with only one NXT. All programs and instructions are included. The building is very simple, the programs are not so simple...


Here is a video of the remote in action:


Sunday, November 9, 2008

Robot Inspiration Series #14: Remote Controlled Robot

This week's inspiration is to build a robot that can be controlled by a human. Although remote controlled robots may seem relatively easy to program and perhaps build, they don't have to be. Building and programming the remote control system can be a big challenge by itself. In addition, a robot that is remote controlled can still have many autonomous functions so that the driver doesn't have too many things to keep track of. For example, since I'm competing in FTC, a competition involving remote controlled robots part of the time, I'm constantly looking for ways to program my team's robot to either help the driver or take care of functions entirely so that the driver doesn't need to worry about it.

One fun application of remote controlled robots is a Battle Bots game, where multiple robots try to flip or disable their opponents. Once I made a remote controlled robot to battle with some of my siblings' Spybots. Racing is another possible application of remote controlled robots. If you have a wireless camera to attach to your robot, you could make a robotic explorer that would let you explore a room while sitting at your computer.

Some robots you can use for inspiration include my PC-Controlled Robot, Jim's remote controlled robot with camera goggles, and Philo's Spy Camera Rover along with his NXT Joystick. There's lots of others out there, and feel free to comment with any good ones you know of!

-Jonathan