This tutorial covers how to write and read XML files that are used by yarprobotinterface tool and by the libYARP_robotinterface C++ library.
Collaboration diagram for YARP robotinterface XML files:This tutorial covers how to write and read XML files that are used by yarprobotinterface tool and by the libYARP_robotinterface C++ library.
Here is a minimal config file, let's call it "config.xml":
This configuration files create two devices: One fake_motor_device, that creates a fake motor control board. One fake_motor_nws_yarp, that creates a Network Wrapper Server (NWS) that exposes fake_motor_device functionality over YARP ports.
The robot element is the root element of the XML file. It contains the following attributes: name: The name of the robotinterface instance. portprefix: The portprefix to be used by the port created by the robotinterface instance. It can be used as ${portprefix} when specifying a parameter. It must start with a /. build: Not used.
The devices element is a child element of robot element.
It is a collector of YARP devices that are spawned by the robotinterface instance.
The device element is a child element of devices element.
It is used to specify a YARP device that is spawned by the robotinterface. It contains the following attributes: name: The name of the specific instance of YARP device that is created. type: The name of the type of YARP device to instantiate.
The group element is a child element of device or action element.
It is a collector of parameters under a specific group name.
The param element is a child element of device, action or group element.
This element it is used to specify a specific configuration parameter. It contain the following attributes: name: The name (i.e. key) of the attribute.
The inner text of the element represents the value of the parameter. If the inner text contains the string ${portprefix}, it will be substituted with the portprefix parameter specified in the portprefix attribute of the robot element.
This element still needs to be documented.
Here is an example of .xml config file which includes other xml files, using the xi:include tag:
Contents of the file "wrappers/odometry/odometry_nws_yarp.xml".
It must be noticed that the included file contains just a single device section, that will be incorporated inside the devices block in the parent file. In this way, it is possible to better organize the xml file and eventually add/remove/replace individual devices. Additionally each device included through a xi:include can be enabled/disabled by the the use of enabled_by and disabled_by attributes. By default, if no attribute is added, than the file is automatically included. If a enabled_by attribute is found, then the include line is not enabled by default and it is enabled only if yarprobotinterface has been executed with the option --enable_tags (xxx) (xxx should match the contents of the enabled_by attribute) If a disabled_by attribute is found, then the include line (either enabled by default or by an enable_by attribute ) can be disabled if yarprobotinterface has been executed with the specific option --disable_tags (yyy) (yyy should match the contetes of the disabled_by attribute)
Examples:
yarprobotinterface starts yarprobotinterface including the following devices: odometry_nws_yarp.xml odometry.xml body.xml body_nws_yarp.xmlyarprobotinterface --disable_tags (disable_odometry) starts yarprobotinterface including the following devices: body.xml body_nws_yarp.xmlyarprobotinterface --enable_tags (enable_ros) --disable_tags (disable_body) starts yarprobotinterface including the following devices: odometry_nws_yarp.xml odometry.xml odometry_nws_ros.xmlyarprobotinterface --enable_tags (enable_ros enable_ros2) --disable_tags (disable_body) starts yarprobotinterface including the following devices: odometry_nws_yarp.xml odometry.xml odometry_nws_ros.xml odometry_nws_ros2.xmlyarprobotinterface --enable_tags (enable_all) starts yarprobotinterface including the following devices: odometry_nws_yarp.xml odometry.xml odometry_nws_ros.xml odometry_nws_ros2.xml body.xml body_nws_yarp.xmlyarprobotinterface --enable_tags (enable_all) --disable_tags (disable_body) starts yarprobotinterface including the following devices: odometry_nws_yarp.xml odometry.xml odometry_nws_ros.xml odometry_nws_ros2.xmlThe latter two examples show the use of the special enable_all tag, which can be used to enable all optional devices (i.e. marked by a enabled_by attribute)
N.B. The disable_tags is always processed after the enable_tags and can be used to remove previously enabled devices. The enabled_by/disabled_by attributes are parsed by the yarprobotinterface pre-processor, hence they can be used only in combination with a xi:include tag.