loading
 
Update rate
Ringo from United States  [18 posts]
17 year
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);
            }



Anonymous 17 year
Ringo,

Try to isolate the code that just grabs the COG from RoboRealm and comment out briefly the sp object just to be sure that it is not an issue with that object. You should not need to use a sleep function in that mail loop. RoboRealm will return back variables very quickly without any wait (unless you use a wait for next frame command prior to the GetVariable or you are using a very slow camera). In your case the C# API should not return without a variable value UNLESS a network issue arises.

The variables within RoboRealm are always set unless explicitly cleared by some module that you add in. Thus when you access the variable using the API it just quickly reads the current value and sends that back. If you do this fast enough you'll notice the values does NOT always change since a new frame may not have been processed during the successive calls.

To be on the safe side I'd check the return value from GetVariable and if it is null then you probably had a network connection issue. You could then try reissuing a connect command to reestablish the connection.

Let us know what you find out.

STeven.

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index