Wrapper classes for reading variables from RR_API
from United States  [60 posts]
13 year
I'm attaching three files of C++. These put wrappers around variables to be read from RR using the RR_API. These classes only do reads, so far, since that is all I've needed to date. I'll add writing at some point in the future but though some might find limited routines these useful before I get write opeartions.

The first class is RoboRealmVar which wraps individual variables. Its a template class. I've created specific instanctiations for int, float and string. It should be easy to add more if necessary. The only thing you might have to write is a simple conversion from ascii to data type routine. See the string instatiation for how it was done there.

To declare a var is done by:

    rrIntVar mCogX;
    rrIntVar mCogBoxSize;
    rrIntVar mImageWidth;

Instatiate it with

    mCogX("COG_X", mRoboRealm),
    mImageWidth("IMAGE_WIDTH", mRoboRealm),
    mCogBoxSize("COG_BOX_SIZE", mRoboRealm),

where mRoboRealm is the instance of RR from RR_API.

All the examples are for the COG module and are using class members, hence the 'm' prefix.

You can retrieve the values with:

   int cogX =  mCogX();

which uses an overload of operator();

If you want to retrieve mutliple variables with one call use the class RoboRealmVars. You may have noticed the class RoboRealmVarBase which is a base class for RoboRealmVars. It is used to provide an interface to individual vars when working with multiple vars.

Do this for multiple variables:

    RoboRealmVars mCogVars;



and then:


and finally:


which is another operator() overload for reading multiple vars. All the individual vars then have values that can be accessed as shown above in the individual var example.

Hope someone finds these useful. I know reading multiple vars took a lot of detail chasing that this new class how hides.

from United States  [60 posts] 13 year
The forum won't allow uploading C++ files so it gave me an error on my posting, but I see it posted the message without the files.

I just wrote this up on my blog at http://mysticlakesoftware.blogspot.com/2010/02/roborealm-vision-processing-wrappers.html

I zipped the files for uploading here.
Anonymous 13 year

This is fantastic! I hope you don't mind but we added a link from our homepage and the rss feed to your blog.

We'd also like to ask permission to include your classes along with the API as I'm sure other folks would appreciate the ease of use they provide. They would be included as is along with the other C++ files with all your information preserved. Let us know if this is ok with you.

from United States  [60 posts] 13 year

I am fine with the link and the inclusion of the files with the API.

I will be updating the files over time. Should we make contact via email to facilitate that? I have your email address.
Anonymous 13 year
Yes, if you do make modifications you can email me/us directly and/or post your update summary to keep others informed.


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