I have a webcam on a pantilt hooked up to a serializer (www.roboticsconnection.com). I have a c# app getting the COG of a green blob and I'm moving the servo to track it. I delay after ever step. If I set teh delay to 100ms then it works (slowly), if I decrease the delay I get a error
Value cannot be null.
Parameter name: String
on line
cogx = int.Parse(rr.getVariable("COG_X"));
are the variables not set that often, or is this not a roborealm problem?
Thanks
Ringo
Here is the entire loop.
sp.Open();
while (true)
{
cogx = int.Parse(rr.getVariable("COG_X"));
Console.WriteLine("X={0}", cogx);
cogy = int.Parse(rr.getVariable("COG_Y"));
Console.WriteLine("Y={0}", cogy);
offset = Math.Abs(centerx - cogx);
if(offset>10)
if (centerx < cogx)
pan --;// offset;
else
pan++;// offset;
Console.WriteLine("Offset={0} new pan value is {1}", offset,pan);
sp.Write("servo 1:" + pan + "\r");
System.Threading.Thread.Sleep(100);
}
|
|