|
ARON (ArmarX Object Notation) is the ArmarX implementation of variants which can be transferred over the network via ZeroC Ice. It is our instantiation of an Interpretable Data Format (IDF). Further, ARON is the data representation used in the ArmarX Memory System.
When sending data over the network we distinguish between different representations: The Ice object, which is the object transferred over the network, the Aron Data Transfer Object (ARON DTO) and the Business Object (BO).
We also distinguish between different types of objects: data objects and type objects.
To support easier conversion of ARON Data Objects - which hold actual informational data - we use ARON Type Objects, which explain what kind of data is stored in a transferred object. If we want to send a PointCloud over the network, the data will be represented as an NDArray, but the additional information that this ARON Data Object should be interpreted as a point cloud is useful for conversion in business objects. The Aron Type Objects we support are listed at aron_specification . As a user working with ARON you can use those Aron Type Objects to define your own - more complex - Aron Data Transfer Objects. They can consist of Dictionaries containing List, Floats, Strings etc. and can be nested as needed.
If you want to send data over the network, e.g. because you want to send data to the memory, the data will be converted several times. You start out with the Business Object, which you defined yourself as a C++ or Python class and contains all business logic, as well as the data itself. This is not connected to Aron in any way. Then it will be converted to an ARON Data Transfer Object, using the toAron(arondto::YourType& dto, const YourType& bo)
method, which is defined by hand (usually in a aron_conversions.h\.cpp
file) and is not part of the arondto::
namespace. If you are developing in C++ the class of the ARON Data Transfer Object is generated automatically from an Ice Definition (and ususally resides in an arondto::
namespace), if you are developing in Python, this class has to be written by hand. Once you have the ARON Data Transfer Object it needs to be converted to an actual Ice Object so it can be transferred over the network in a language independent format. For this we use toAron()
functions in the arondto::
namespace, defined as part of the automatically generated ARON Data Transfer Object. The resulting object can now be transferred over the network using Ice.
An example of this can be seen in the following:
In Python an example looks like this:
Once it was received somewhere the whole process is repeated the other way around. We use arondto::fromAron()
methods to get the C++/Python Wrapper of the ARON Data Transfer Object out of the Ice object we received. Then we use the fromAron(const arondto::YourType& dto, YourType& bo)
methods to get the actual Business Object in C++/Python.
While we already support a wide range of possible Data Types we can send over the network, they might not fit your need 100%, especially if you write a new memory segment or entity. To deal with this you can define a new ARON Type using xml. There are two steps involved:
All Definitions follow the same pattern.
You can add an arbitrary amount of other ARON types you want to include and use, you can define ARON types and use them in the same xml, you can use dictionaries and lists of other ARON types...
For a more detailed example and explanation on how to write such a new xml file see code_generation .
Define a normal C++ class containing the data and the business logic of the object. Add the .cpp/.h
files to your CMakeLists.txt
An optional but recommended step consists of adding forward declarations. A forward declaration is a declaration of a class without definition of its implementation. This tells the compiler that the symbol YourType
is a class, but not how it is comprised (i.e. which member variables and methods it has). Even without the definition, the class name can already be used as reference, pointer, function argument and function return type. Using forward declarations can heavily reduce the amount of includes the users of a class or header file pull into their code, and thus can heavily speed up compilation.
You file should look something like this:
Following conventions we define conversions from ARON DTOs to C++ BOs in a specific C++ file called aron_conversions.cpp/.h
. To do so, first add the files to your SOURCES and HEADERS in your CMakeLists.txt. Then add the definition of two methods per AronTypeDefinition you wrote to the aron_conversions.h
file.
Your file should look something like this:
Next implement the conversion functions in aron_conversions.cpp
:
You CMakeLists.txt
file should contain:
aron_conversions.cpp/h
in SOURCES/HEADERSyour_type_aron
in DEPENDENCIESaroncommon
in DEPENDENCIES if you use common aron conversionsforward_declarations.h
in HEADERS if you use forward declarationsaron/YourType.xml
in ARON_FILES in armarx_add_aron_library(your_type_aron)YourType.cpp/.h
in SOURCES/HEADERS for your business objectExample:
To be able to use defined Data Types in Python similar steps as in C++ are needed. If you have not yet done all the steps to use the new type in C++ you can start from step 1, otherwise start from step 2 and leave out step 4.
Define your business object, for example:
There is no exact standard of where to put your ARON DTO, but for Python you need to define it by hand, as it is not generated automatically yet. The ARON DTO is a python class inheriting from AronDataclass
defined in armarx_memory.aron.aron_dataclass
. The class also needs the methods from_aron()
and to_aron()
as classmethods. These methods convert from business object to ARON DTO and vice versa. AronDataClass
itself defines methods converting the objects from AROn DTOs to Aron Ice objects (from_aron_ice()
and to_aron_ice()
).
An example corresponding to the business object above could look like this:
See
For an example on how to use aron type definitions in python together with the memory see (Example)