Let's Make Robots!

Using a wiimote with processing to control your robots

Communicates with your pc to control your robot
AttachmentSize
FireTracker.zip1.16 KB

The wiimote is a really cool controller to use with your robots. It has many buttons, accelerometers and even a camera which tells the coordinates of the four principal IR emitters that it sees.

There are many examples of applications using it, some of the most populars are from Johnny Chung Lee. But there are much more, just search for "wiimote" or "wiimote robot" on youtube or google. Here on LMR we have some examples too:

And others with just its camera:


But I wanted to use it, without having to hack it, to communicate with processing and control my robot TheBox.

On my computer I have installed WIDCOMM bluetooth software which I found here.

If you've never used processing you should take a look here


To install the processing libraries I followed this tutorial.

I had some problems placing the folders so here is a simple scheme:

+ Prossessing

    + libraries

        + Loc

            + library

                - Loc.jar

            + lll

                + Loc

                     - ...

        + wrj4P5

            + library

                - bluecove-2.1.0.jar

                - bluecove-gpl-2.1.0.jar

                - WiiRemoteJ.jar

                - wrj4P5.jar

                - Loc.jar (optional)

            + lll

                + wrj4P5     

                    - ...


To test if it is all working you can try these examples found here:

If they work, you can pass to the next step, the serial communication with your robot.


The application MyFirstWii is really easy to adapt. On the movie you can see my robot TheBox using it.

All you have to do is to import the serial library, create a serial object, define the COM port & the baud rate and add the serial communication where the data about the buttons is analyzed. Here is an example:

import processing.serial.*;

import lll.wrj4P5.*;

Wrj4P5 wii;

Serial TheBox;

void setup() {

  size(300,300,P3D);

  wii=new Wrj4P5(this);

  wii.connect();

  TheBox = new Serial(this, "COM5", 4800);

void draw() {

  background(0);

  stroke(255);

  translate(300/2,300/2,0);

  lights();

  rotateX((int) (wii.rimokon.senced.x*30+300));

  rotateY((int) (wii.rimokon.senced.y*30+300));

  rotateZ((int) (wii.rimokon.senced.z*30+300));

  box(100,100,100);

}

void buttonPressed(RimokonEvent evt, int rid) {

   if (evt.wasPressed(RimokonEvent.TWO)) println("2");

   if (evt.wasPressed(RimokonEvent.ONE)) println("1");

   if (evt.wasPressed(RimokonEvent.B)) {

     println("B");

     TheBox.write('g'); 

    }

   if (evt.wasPressed(RimokonEvent.A)) println("A");

   if (evt.wasPressed(RimokonEvent.MINUS)) println("Minus");

   if (evt.wasPressed(RimokonEvent.HOME)) println("Home");

   if (evt.wasPressed(RimokonEvent.LEFT)){

     println("Left");

     TheBox.write('a'); 

    }

   if (evt.wasPressed(RimokonEvent.RIGHT)){

     println("Right");

     TheBox.write('d');      

    }

   if (evt.wasPressed(RimokonEvent.DOWN)){

     println("Down");

     TheBox.write('s'); 

    }

   if (evt.wasPressed(RimokonEvent.UP)){

     println("Up");

     TheBox.write('w'); 

    }

   if (evt.wasPressed(RimokonEvent.PLUS)) println("Plus");

}


I didn't found the IR Sensor Tesr application  easy to understand and modify, so I decided to write a new one which I believe it's more practical to use:

 

import lll.wrj4P5.*;

import lll.Loc.*;

 

Wrj4P5 wii;

 

float x;

float y;

float w;

float h;

 

//Change here:

 //Size of the window

   int camWidth = 512;

   int camHeight = 384;

 //Number of IR Emmiters that you want to track

   int IREmitters = 4;

 

 

void setup() {

  size(camWidth,camHeight);

  wii=new Wrj4P5(this).connect(Wrj4P5.IR);

}

 

 

void draw() { 

//Defines Background color

  background(0);

 

//Draws ir emitters

  for (int i=0;i<IREmitters;i++) {

    Loc p=wii.rimokon.irLights[i];

    if (p.x>-1) {

     // Reads the value sent by the wiimote and multiplicities them by the size of the window

       x=((p.x)*camWidth);

       y=((1.-p.y)*camHeight);

       w=p.z*50;

       h=p.z*100;

 

     //Prints the values to the console

       print(x);

       print(" ");

       print(y);

       print(" ");

       print(w);

       print(" ");

       println(h);

 

     //Draws the circles

       noStroke();

       fill(255,255,0);

       ellipse(x, y, w, h);

 

     //Draws the lines

       stroke(255);

       line(x,0,x,camHeight);

       line(0,y,camWidth, y);

 

       delay(50);

     }

   }

 }

 


I developed this code and created another application to my robot which you can download here. It seems to work well, but how the robot is having some motors problems, I didn't had chance to test it with it, but you can see the test I did on the second movie. The application uses this library

 

 


 

Comments, advices, doubts and suggestions are always welcome! :)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I am still doing research, and I found someone who told to buy driver on eBay. I don't know what you think about eBay, but I found this:

http://cgi.ebay.fr/EL-Model-110A-RC-Motor-Speed-Controller-ESC-SE082-/390254839384?pt=FR_YO_Jeux_RadioComRobots_VehiculesRadiocommandes&hash=item5add004658#ht_4340wt_934 

 

I am sure it won't handle 110 A as said, but maybe it could handle the current of the drill motors? I just realize that it would be nescessary to buy 2 of them, 1 for each motor, and it means it will be more expensive than designing oneself....

I have some old drill motors (but useless because without gearbox) and I have tried to measure the current, but it seems my multimeter don't work in amp mode (maybe the fuse) but I powered it with an old PC alimentation:

It works on the 5V channel, wich is limited to 16A, but in doesn't works (my alimentation power down for saving itself) on the 12V channel, wich is limited to 7A. So I guess it use between 7 and 16 Amps, wich is quite big for no efforts current! with the gearbox it will be more, and with 2kgs of robot to move it will be much more ^^

 

And by the way, I have a good news! I succesfull installed jmyron, controlp5 etc... and I am testing TheBox's sketches and trying to adapt them to my robot (we don't have the same way to send orders) and I will give you a feedback soon.

When used in a drill, they usually use a clutch so they never really stall. If there is no clutch or set to "drill mode", the user normally lets off the trigger when the thing stops spinning. If one were to continue to stall the motor, it does pull upwards of 50 or 60 amps --all the way up to 100 or more (depending on the drill) and either a thermal shut-down happens or an internal, self-resetable fuse kicks in.

Look, all I am saying is that I have melted traces on the PCB and "welded" my relays shut. Easy solution is A) don't let them stall and B) use a fuse, period.

BTW --when a MOSFET fries, it stays "on"...

 

Yes I understand now, I am searching for a termical or electromecanical security shutdown, and I think I won't remove the cluch (is this what I think it is, some mecanical part who limit the torque?), and use weaker drills than you: I just need to move a small robot.

I can vouch for that..  (remove breakables from the front of bot when testing)

Not 8 amps... 80 amps!

If we are talking about drill motors, i.e. 12-18V cordless drill motors, they pull a lot more than 8 amps. I am not speaking from data sheets here, I am talking from my actual set-up. My motors draw around 8 amps with the wheels in the air, spinning freely. At start-up, they can draw 15 to 20. If you were to actually stall a motor (this is not easy to do) you can actually reach 80 or 100 amps. Seriously. If using drills, I would not use anything smaller than a 20amp x 2 controller. Bigger the better. Also, a fuse is manditory. I run a 40 amp "slow-blo" fuse and it has saved me many times.

DO NOT UNDERESTIMATE DRILL MOTORS!

After reading your comment I tested one again and didn't passed the 9A.

Their from these cheap ones:

are you serious? how can a drill battery supplies 100Amps? the small resistance of the wires between battery and motor would make them burn!

Wow, very well done!

Its a pleasure to read your posts XicoMBD !

Will need to get a wii remote soonish ... maybe Santa will pull through for me..

It's funny, I think the same of your posts :D

I am testing the Wii nunchuck, but i must say that the wiimote is really cool! wireless with a good skin. I used it at school, it is not very hard to obtain great results! I am improving my robot (http://letsmakerobots.com/node/23509) and I am still having problems with the hardware. I tried to get some infos about yours but it seems that there is the dead link: could you just tell me what kind of motors are you using and were did you get them?

Thnak you, keep the good job ;)