eProsima Micro XRCE-DDS GenΒΆ
eProsima Micro XRCE-DDS Gen is a Java application used to generate source code for the eProsima Micro XRCE-DDS software.
This tool can generate from a given IDL specification file, the C struct associated with the Topic, as well as the serialization and deserialization methods. Also, it can generate a sample demo that works with the proposed topic.
To find out how to install this package, refer to the Installing the Micro XRCE-DDS Gen tool section.
As an example of the potential of this tool, the following shows the source code generated from the ShapeDemo IDL file.
// ShapeType.idl
struct ShapeType {
@key string color;
long x;
long y;
long shapesize;
};
If we will perform the following command:
$ microxrceddsgen ShapeType.idl
it will generate the following header file and its corresponding source:
/*!
* @file ShapeType.h
* This header file contains the declaration of the described types in the IDL file.
*
* This file was generated by the tool gen.
*/
#ifndef _ShapeType_H_
#define _ShapeType_H_
#include <stdint.h>
#include <stdbool.h>
/*!
* @brief This struct represents the structure ShapeType defined by the user in the IDL file.
* @ingroup SHAPETYPE
*/
typedef struct ShapeType
{
char color[255];
int32_t x;
int32_t y;
int32_t shapesize;
} ShapeType;
struct ucdrBuffer;
bool ShapeType_serialize_topic(struct ucdrBuffer* writer, const ShapeType* topic);
bool ShapeType_deserialize_topic(struct ucdrBuffer* reader, ShapeType* topic);
uint32_t ShapeType_size_of_topic(const ShapeType* topic, uint32_t size);
#endif // _ShapeType_H_
eProsima Micro XRCE-DDS Gen is also able to generate both publisher and subscriber source code examples, related with the topic specified in the IDL file, by adding the flag -example
:
$ microxrceddsgen -example <file.idl>
The Client library must be compiled with the WRITE_ACCESS_PROFILE
option for the publisher, to use these examples
and the READ_ACCESS_PROFILE
option for the subscriber.
Note
At present, eProsima Micro XRCE-DDS Gen only supports Structs composed of integer, string, array and sequence types, even though it is planned to enhance the capabilities of the eProsima Micro XRCE-DDS Gen tool in a near future.