Skip to content

Generator configuration

Matt Windsor edited this page Mar 8, 2023 · 1 revision

The generator configuration file, read by rtcg-gen, is an XML file with the root tag rtcg-gen.

Tags

rtcg-gen/cpp: generate C++

The cpp tag contains configuration for generating a particular C++ output.

This tag has one attribute, variant, which can be either of:

  • animate: produces a C++11 standard library-only binary that 'animates' (interactively steps through) the test; see C++ animate;
  • ros: produces source targeting ROS1 Noetic; see C++ ROS.

rtcg-gen/cpp/makefile: generate Makefile

The makefile tag, if present, causes the generator to add a basic POSIX Makefile into the C++ output directory.

Note: Makefile generation has only been tested with the animate variant.

Example

<makefile />

rtcg-gen/cpp/channel: configure a channel

The channel tag configures a channel through its attributes, which are:

  • name: names the channel being configured;
  • type: specifies the value type of the channel (as used to communicate with, for instance, ROS).

If type is specified, the generator will not provide an automatic definition for to[ChannelName] and from[ChannelName]. Instead, a file [variantName]/convert.cpp should be provided (relative to the config file) with definitions for these functions.

Example

The following maps channel batteryInfo to type sensor_msgs::BatteryState:

<channel name="batteryInfo" type="sensor_msgs::BatteryState" />

In ROS1, the ros/convert.cpp file will then need to implement the following functions (supposing that the native type of batteryInfo is a natural number):

unsigned int fromBatteryInfo(const sensor_msgs::BatteryState::ConstPtr& msg);
sensor_msgs::BatteryState toBatteryInfo(unsigned int value);

rtcg-gen/cpp/include: insert an include

The include tag adds an include to the list of includes generated in the various C++ files. This is useful if a channel tag has mapped a channel to a type defined in another header.

There are two attributes:

  • src names the include file;
  • isSystem determines whether the include is "non-system" or <system>.

Example

Following on from the example for channel, we might require:

<include src="sensor_msgs/BatteryState.h" />