Society of Robots - Robot Forum
General Misc => Robot Videos => Topic started by: frank26080115 on December 15, 2007, 02:47:56 PM
-
My robot Charlie with a Wii Nunchuck R/C system
[youtube=425,350]rFN0P7389O8[/youtube]
I sound weird on a mic.
EDIT: I posted code and such a few posts after this one
Other videos on my Youtube account
http://youtube.com/frank26080115
More better neater photos on my flickr
http://www.flickr.com/photos/frank26080115/2125780153/
-
Very cool!
Where can I find more info on Charlie?
-
Nice!!!
post some code!
-
awesome
-
The Nunchuck reading code is an improvement upon the code from http://www.windmeadow.com/node/42
This is all done with the Arduino environment
You need one of my custom library (some weird functions i find handy), and you need to modify the existing Wire library with the steps in http://www.windmeadow.com/node/42
my library file is named basic.h, place it in /arduino-0010/hardware/libraries/basic/
i've attached this file to this post
the controller side uses the file inside my "charlie_wii_nunchuck.zip" attached to this post
I found that instructions here http://www.windmeadow.com/node/42 for the connection is not so reliable, I really think you should use a 3.3V regulator, PLUS 10K pull up resistors
Read this http://www.sparkfun.com/commerce/present.php?p=Sensor-Interfacing
The radio transmitter is one of those cheap RF modules Spark Fun sells, except mine only costs $5 each, not $15,
it is connected to the TX pin on the MCU
Don't bother with 4800 baud even though it's the speed the modules are advertised at, use 2400
http://www.robotshop.ca/home/products/robot-parts/communication-control/data-telemetry/on-shine-low-cost-tx-rx.html
the robot has pins defined to the various servos, the pin definitions can be changed in the code (file is servo.pde), the radio receiver is connected to the RX pin, the file is "charlie_advanced_rc.zip"
(I got lazy and used a bunch of switch cases instead of simply calculating out the servo pulse widths, floating point wasn't working right)
OH, and I made a connector to avoid cutting the nunchuck's cables, it's a stick of double sided copper clad board etched with 3 lines to match the inside of the connector, and i made a plastic housing so everything stays nicely together, it's great! The screws I used even lets the connector to "click in"
The pinouts of the connector is here:
http://www.hardwarebook.info/Wiimote_Expansion_Port
-
Very cool ;D
i gotta build me one of those...
-
Very nice indeed!
If I spotted it correctly, your Charlie bot uses the AVRcam?
Do you have some more info on how you use the cam and how you connected it to the Arduino?
-
It wasn't hard, but it's a pain in the ass to use.
I'll try and fish up some code, maybe even a library someday. But it's basically send your track command, then wait for a few packets, then end the tracking, and process the packets.
I'm also hoping to make my own image processor, but with a atmega128 instead of the atmega8
But the camera's datasheet is very very difficult to understand.
-
that is genius dude. Good freaking job! Seriously, that is cool as hell lol. That little bot has some serious application potential! :D
-
This is weird, you guys see the wire antenna i used on the breadboarded transmitter? removing the antenna gives me a huge boost in signal quality... I need to make a project boxed version of the transmitter, and now i'm wondering about an antenna, what should I do? use an antenna or stick with what works?
-
hmmm odd about the antenna . . .
is the antenna on your robot also vertical? antennas must be parallel for optimal transmission
-
Nice job, Frank!
Small request, can you post the code for the AVRcam processing sequence? I am struggling making mine work with a Arduino custom board...
-
Small request, can you post the code for the AVRcam processing sequence?
Same request from me. Thanks in advance!
-
Small request, can you post the code for the AVRcam processing sequence?
Same request from me. Thanks in advance!
and me . . . I tried to do it yesterday actually with the CMUcam on my ATmega168 and so far no luck. The code is basically the same for both cams . . .
-
// Cam Related Variables
// These needs to be written while reading buffer
byte objNum;
byte objColour[8]; // Refer to sensordef.h
// These are used by the robotic functions
boolean noObj;
byte objXCenter[8];
byte objYCenter[8];
byte objWidth[8];
byte objHeight[8];
byte objSize[8]; // Average between width and height used for ranging purposes
byte objShape[8]; // 0 for null, 1 for square, 2 for tall, 3 for wide
boolean objFound;
byte objAtt; // in view and right shape and colour
boolean objInterestFound;
byte objInterested; // not the right shape, but right colour on the edge of view
byte wantedColour = 1; // What colour you are looking for
boolean waitACK()
{
boolean incomeValid = true;
while(Serial.available() < 4);
if(Serial.read() != 65)
{
incomeValid = false;
}
if(Serial.read() != 67)
{
incomeValid = false;
}
if(Serial.read() != 75)
{
incomeValid = false;
}
if(Serial.read() != 13)
{
incomeValid = false;
}
return incomeValid;
}
void getObj()
{
byte objXMin[8];
byte objXMax[8];
byte objYMin[8];
byte objYMax[8];
byte waittimeout = 0;
byte temp;
Serial.println("ET");
while(waitAck() == false)
{
Serial.println("ET");
}
while((Serial.available() == 0) && (waittimeout != 10))
{
delay(1);
waittimeout++;
}
if(Serial.available() == 0)
{
noObj = true;
objNum = 0;
Serial.println("DT");
while(waitAck() == false)
{
Serial.flush();
Serial.println("DT");
}
} else {
temp = Serial.read(); // useless byte
while(Serial.available() == 0);
objNum = Serial.read();
noObj = false;
}
waittimeout = 0;
if(noObj == false)
{
for(temp = 0; temp < objNum; temp++)
{
while(Serial.available() == 0);
objColour[temp] = Serial.read();
while(Serial.available() == 0);
objXMin[temp] = Serial.read();
while(Serial.available() == 0);
objYMin[temp] = Serial.read();
while(Serial.available() == 0);
objXMax[temp] = Serial.read();
while(Serial.available() == 0);
objYMax[temp] = Serial.read();
}
}
Serial.println("DT");
delay(100); // there might be some junk left over, wait for finish
// for robots who need constant servo pulses, replace delay with
// for loops that sends the pulses for a similar amount of time
// 100 is only an estimate
Serial.flush(); // clear buffer
objFound = false;
objInterestFound = false;
if(noObj == false)
{
for(temp = 0; temp < objNum + 1; temp++)
{
objWidth[temp] = objXMax[temp] - objXMin[temp];
objHeight[temp] = objYMax[temp] - objYMin[temp];
objXCenter[temp] = objXMin[temp] + (objWidth[temp] / 2);
objYCenter[temp] = objYMin[temp] + (objWidth[temp] / 2);
objShape[temp] = 0;
if(similarTo(objWidth[temp], objHeight[temp]))
{
objShape[temp] = 1;
}
if(objShape[temp] != 1)
{
objShape[temp] = 2;
if(objWidth[temp] > objHeight[temp])
objShape[temp] = 3;
}
objSize[temp] = averageWH(objWidth[temp], objHeight[temp]);
if(objShape[temp] == 1)
{
if(objColour[temp] == wantedColour)
{
objAtt = temp;
objFound = true;
}
}
else {
if(objColour[temp] == wantedColour)
{
objInterested = temp;
objInterestFound = true;
}
}
}
}
}
I think that should do it, it doesn't configure the camera for you though
I am making various changes to the code, the current one might not work
I think you need these functions in another small library of mine
boolean similarTo(byte varAa, byte varBb) // used to compare length and width of objects to find shape
{
float varA = varAa;
float varB = varBb;
boolean isSimilar = 0;
if((varA < varB + (varA / 3)) && (varA > varB - (varA / 3)))
{
isSimilar = 1;
}
if((varB < varA + (varB / 3)) && (varB > varA - (varB / 3)))
{
isSimilar = 1;
}
return isSimilar;
}
boolean similarTo(int varAa, int varBb) // used to compare length and width of objects to find shape
{
float varA = varAa;
float varB = varBb;
byte divider = 10;
boolean isSimilar = 0;
if((varA < varB + (varA / divider)) && (varA > varB - (varA / divider)))
{
isSimilar = 1;
}
if((varB < varA + (varB / divider)) && (varB > varA - (varB / divider)))
{
isSimilar = 1;
}
return isSimilar;
}
byte averageWH(byte varAa, byte varBb)
{
float varA = varAa;
float varB = varBb;
byte avgSize;
varA = (varA + varB) / 2;
avgSize = varA;
return avgSize;
}
A Processing program I made for the computer is attached to this post, it can only do frame dumps, nothing else
-
are the Serial.whatever() commands for Wiring? or perhaps require some other header?
-
Serial.whatever works in Arduino without doing anything extra
But you have to initialize it with Serial.begin(115200); in initialization process.
-
Hi Frank! The Radio Module works "out of the box", I mean you don't need to configure anything? It works just like there would be a cable?
-
it acts as an invisible wire, but only for digital signals (so only binary 0 and 1s, nothing in between), but it can't handle more than 2400 changes per second.
ALSO you must change the input to the transmitter every second or else the receiver starts to output junk, apparently this is not needed if you run the transmitter at 12V, but I didn't try that yet.
To use it for a serial connection, just connect the transmitter to the TX pin on your microcontroller, and the receiver to the RX pin on another microcontroller, and set the baud rate on both microcontrollers to 2400 baud.
The black and white answer is Yes, but with the above limitations you must look out for.
Dirt cheap compared to SparkFun, eh? Costs less than plain wire for that distance.
-
it acts as an invisible wire, but only for digital signals (so only binary 0 and 1s, nothing in between), but it can't handle more than 2400 changes per second.
ALSO you must change the input to the transmitter every second or else the receiver starts to output junk, apparently this is not needed if you run the transmitter at 12V, but I didn't try that yet.
To use it for a serial connection, just connect the transmitter to the TX pin on your microcontroller, and the receiver to the RX pin on another microcontroller, and set the baud rate on both microcontrollers to 2400 baud.
The black and white answer is Yes, but with the above limitations you must look out for.
Dirt cheap compared to SparkFun, eh? Costs less than plain wire for that distance.
What do you mean by "change the input to the transmitter every second" ?
-
oops i meant change the bit inputted to the transmitter, otherwise, the receiver goes nuts
-
Great job Frank! Nunchaku control and no host PC required!
-
lol i told my friend and now he hates you for dishonouring the wii ;D oh well freakin wiked tho
-
I just read this post. Awesome!!! If you can only control the robot with WII to go to the fridge and get a beer.
-
So if you are using the Arduino, you need to include "Wire.h" (i'm assuming that "stdio.h" and "string.h" are standard c libraries). say i wanted to do something similar, i.e: control servos and whatnot remotely using the Wii nunchuck and some cheap RF receivers/transmiters, but instead i have a homemade microcontroller similar to the $50 robot one (which will use the Atmega168). where would i find the required libraries, like "Wire.h" and any others that it may also include so that i can use the functions in your code? I could always just buy an Arduino, but im going to school for all this neato robotics jazz (Mechanical Engineering/Mechatronics) so i'd rather do EVERYTHING the hard way and make my own stuff. You learn more that way anyhow. thanks for any help.
-
Wiring.h should be compatible with both ATMEGA8 and ATMEGA168
-
No, basically what I'm saying is that i wanna do this without the Arduino. Where can I get "Wire.h"? doesnt that header file come with Arduino?
-
the "wire" library will work with AVR-GCC and with any AVR chips that has I2C
-
Cool man. So any tips you can give me for the cheapo RF Receiver/Transmitter set, like hoe to make them talk to each other? got any code snippets for that part?
-
dude that video is awesome. i didnt know you could do that with the nunchuck! ;D
-
Cool man. So any tips you can give me for the cheapo RF Receiver/Transmitter set, like hoe to make them talk to each other? got any code snippets for that part?
they behave like a wire, but only for digital signals, all you need to know is how to use USART on a microcontroller
-
nice one! good work :D
-
Hi Frank,
Question - can you please explain how you made the connector for the nunchuck? Im looking to use my nunchuck but i really don't want to cut the cable.
Thanks
-
I suggest you buy http://www.dealextreme.com/details.dx/sku.4115 (http://www.dealextreme.com/details.dx/sku.4115) , there's no point in making a connector my original way now
-
how you get the wireless stuff going and how much?
-
Has any one done something similar but with the axon?
-
if the same pins are connected, will this code work for a $50 board?
I mean, they both use c, or i there something special about the arduino
-
I was looking on youtube for wii hacks and the majority used the ardunio. Is there anything special about the ardunio? Is it just serial communication with the wii receiver?
-
Arduino has easy ways to communicate with I2C, which seems like why it is the most common board to be used with the wii stuff.
-
the arduino is just a mega168 with extras like usb and i2c... same *could* be achieved with the $50 board.
-
Can you guide me with the construction of charlie? i mean does it use Arduino as well? how did you interface so many servos there? I'm really sorry for my ignorance but i'm new to Arduino..... please help
-
And also that i never used RF modules before, can you guide me with the connections? rx and tx is fine, but the other connections....sorry again for my ignorance :(
-
I suggest you buy http://www.dealextreme.com/details.dx/sku.4115 (http://www.dealextreme.com/details.dx/sku.4115) , there's no point in making a connector my original way now
I <3 Deal Extreme, free shipping worldwide on cheap Hong Kong electronics!
I just bought a couple of these wii nunchucks, if you do cut them the wires inside aren't the same colours as those of the original parts. If you pull apart the connector you can see what colour on goes to which pin on the connector and check it against the original part. Its only a five minute job to do but don't get freaked out if you open it and the colours are different!
-
looks like you need to make a tutorial
-
lol i told my friend and now he hates you for dishonouring the wii ;D oh well freakin wiked tho
Thats not dishonoring the Wii. Actually, Nintendo may want to copy his idea likewith the little RC Mario Cart things. BTW Great Idea!
-
very good job.
although it'll be even more interesting if BLUETOOTH was used, instead of rc.
-
So i have a few questions on the arduino pwm. i want to control to ESC for my motors and they use a pwm input. how will this hook up to the arduino and still use the wii? i know this is a simple question but i havent see it explained, I.E. which pin to use and the code for it.
-
oops i meant change the bit inputted to the transmitter, otherwise, the receiver goes nuts
__________________________________________
Robots stepper motor:oyostepper.com (https://www.oyostepper.com/)