General Misc > Robot Videos
Wii Nunchuck Controlled Robot
Admin:
hmmm odd about the antenna . . .
is the antenna on your robot also vertical? antennas must be parallel for optimal transmission
Ro-Bot-X:
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...
Mega:
--- Quote ---Small request, can you post the code for the AVRcam processing sequence?
--- End quote ---
Same request from me. Thanks in advance!
Admin:
--- Quote ---
--- Quote ---Small request, can you post the code for the AVRcam processing sequence?
--- End quote ---
Same request from me. Thanks in advance!
--- End quote ---
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 . . .
frank26080115:
--- Code: ---// 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;
}
}
}
}
}
--- End code ---
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
--- Code: ---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;
}
--- End code ---
A Processing program I made for the computer is attached to this post, it can only do frame dumps, nothing else
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version