|
Ariles
|
| HEAD v2 | |
| CI status | |
| latest | |
| legacy |
Loosely speaking, ariles is a C++ reflection library, i.e., it provides meta-programming APIs for implementation of class visitors (processors). It also provides a number of (de)serializers based on these APIs, e.g., YAML, JSON, XML, ROS parameter server, ROS2 parameters; and serialization wrappers for some types, e.g., STL containers, smart pointers, Eigen matrices, etc.
Unlike many modern C++ reflection/serialization libraries (see a list of related software below) ariles uses macro approach for injecting code. This is not an archaism, but a design choice which enables a different set of features: virtual serialization methods, no constraints on class construction or inheritance, etc.
boost::serialization, ariles tries to be flexible while parsing by:XML,YAML <-> ROS parameter server. Note that the conversion is not data-agnostic, i.e., the complete data structure must be represented in C++ code.Octave or pythonscript for debugging purposes.URDF parser https://github.com/asherikov/ariles_urdf.Class [./tests/api_v2/types/minimal.h]:
Serialization:
Result:
Deserialization:
Conversion:
See demo for more examples: https://asherikov.github.io/ariles/2/DEMO.html [./ariles/tests/api_v2/demo_api_v2.cpp]
ariles includes a number of optional visitors that support various data representation formats, in particular:
YAML via yaml-cpp: https://asherikov.github.io/ariles/2/group__yaml__cpp.html.msgpack via msgpack-c: https://asherikov.github.io/ariles/2/group__msgpack.html.JSON via nlohmann_json, with optional Jsonnet preprocessing: https://asherikov.github.io/ariles/2/group__nlohmann__json.html and https://asherikov.github.io/ariles/2/group__jsonnet.html.XML via PugiXML: https://asherikov.github.io/ariles/2/group__pugixml.htmlOctave script, output only, no dependencies: https://asherikov.github.io/ariles/2/group__octave.htmlPython script, output only, no dependencies, uses numpy for vectors and matrices: https://asherikov.github.io/ariles/2/group__python.htmlROS parameter server, via ROS libs: https://asherikov.github.io/ariles/2/group__rosparam.htmlgraphviz dot files for diagram generation: https://asherikov.github.io/ariles/2/group__graphviz.htmlROS2 parameters, via rclcpp lib: https://asherikov.github.io/ariles/2/group__ros2param.html ROS2 parameters are not designed to fully reflect yaml structure as explained here https://github.com/ros2/rcl/issues/463, so while ariles can dump and read anything, there are certain workarounds in place that are described in more details in the ROS2 demo [./tests/api_v2/demo_api_v2_ros2.cpp] https://asherikov.github.io/ariles/2/DEMO_ROS2.html.There are also a few utility visitors, e.g.,
compare for class comparison;copyto for copying data to non-ariles classes;copyfrom for copying data from non-ariles classes.The complete list of modules is available at https://asherikov.github.io/ariles/2/modules.html
ariles provides serialization wrappers for the following types:
std::string, std::vector, std::map, std::pair, std::shared_ptr, std::unique_ptr, std::array, std::deque, std::list, std::set, std::unordered_map, std::unordered_set, std::chrono::duration, std::chrono::time_point, std::optional, std::filesystem::path, std::tuple.Eigen types: matrices, transforms, quaternions.Boost classes: boost::optional, boost::movelib::unique_ptr. boost::shared_ptr.The library is organized in a core package and a set of dependent visitor packages. It can be built in two different ways:
ariles subdirectory;ariles2_*_ws directories.cmake >= 3.13C++17 compatible compilerbooststd::pair is by default represented in the following way:
The default behavior is generic and robust, but some users prefer to use a more compact form provided that the first value is represented by std::string:
The alternative behavior can be enabled using sloppy_pairs_ flag in serialization::Parameters. Note that in general it is up to the user to ensure that first_value is a valid map key in the target serialization format. std::map with string keys are handled in a similar way when sloppy_maps_ parameter is enabled. If you are inheriting from a "sloppy" ariles base classes, e.g., ariles2::SloppyBase (see ariles2/extra.h header), both of these flags are enabled by default.
ariles2::Any2 class defined in ariles2/types.h provides functionality similar to protobuf::Any: it allows automatic instantiation and configuration reading of user-defined classes based on their string ids. See tests/api_v2/types/any.h for an example.
ariles class, try writing it first to get an example. ariles can parse its own output.boost::optional, which may be uninitialized. ariles automatically adds is_null flag for each of such variables in configuration files.ns_ros2param::Reader (pick desired reader namespace) directly or defining your own aggregate visitor. It would be necessary when reading data from multiple partially initialized sources to avoid resets.ariles2::rosparam::Reader, but its functionality is more limited.ariles it is more focused on reflection per se rather than applications, for example, it allows to set value by string name of a class member, handles class methods, etc. Ponder does not rely as much on preprocessor macro, but is more verbose.ponder. Partially inspired ariles 2.x.x API.pfr): C++14 library providing tuple like methods for aggregate initializable structures. Addresses a somewhat different but related problem.boost::serialization, https://github.com/USCiLab/cereal.Refer to changelog for more details.
To be removed:
ariles2::namevalue: replaced by ariles2::namevalue2ariles2::Any: replaced by ariles2::Any2rosparam: ROS1 is EOL.rapidjson: poorly maintained, Ubuntu packages are based on an old buggy release https://github.com/Tencent/rapidjson/issues/718. Replaced by nlohmann_json.