loading
 
Wrapper classes for reading variables from RR_API
from United States  [60 posts]
7 years
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;

then:

    mCogVars(mRoboRealm)

and then:

    mCogVars.add(mCogX);
    mCogVars.add(mImageWidth);
    mCogVars.add(mCogBoxSize);

and finally:

    mCogVars();

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.

[image1]
[image2]
[image3]
fred miller from United States  [72 posts] 7 years
where are the c++ files
Anonymous 7 years
See the API.zip download ... they are now incorporated into that file.

http://www.roborealm.com/downloads/API.zip

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