Skip to main content

A ROS package providing a unified runtime interface for dynamic type support, enabling creation, reflection, and introspection of dynamic data.

Project description

Built using https://github.com/ycheng517/ros-python-wheels.

rosidl_dynamic_typesupport

Unified Interface for Dynamic (Runtime) Typesupport and Serialization

This library provides a unified interface for creating and reflecting dynamic types and dynamic data based off those types at runtime, as well as the utilities that support those objects.

It is meant to be used with serialization support libraries that fulfill the interface. Properly implemented, a user should be able to, given a serialized buffer, the serialization library used to serialize it, and the buffer's message/type description, obtain a way to introspect/reflect its contents.

Example Usage

// Init Serialization Support (in this case, using FastRTPS)
rosidl_dynamic_typesupport_serialization_support_t serialization_support;
  rosidl_dynamic_typesupport_serialization_support_init(
    rosidl_dynamic_typesupport_fastrtps_init_serialization_support_impl(),
    rosidl_dynamic_typesupport_fastrtps_init_serialization_support_interface(),
    rcutils_get_default_allocator(),
    &serialization_support);

// Configure Dynamic Type Builder
rosidl_dynamic_typesupport_dynamic_type_builder_t * flat_builder =
  rosidl_dynamic_typesupport_dynamic_type_builder_init(&serialization_support, "flat");
rosidl_dynamic_typesupport_dynamic_type_builder_add_bool_member(flat_builder, 0, "bool_field");
rosidl_dynamic_typesupport_dynamic_type_builder_add_int32_member(flat_builder, 1, "int32_field");
rosidl_dynamic_typesupport_dynamic_type_builder_add_string_member(flat_builder, 2, "string_field");

// Create Dynamic Type
rosidl_dynamic_typesupport_dynamic_type_t * flat_type =
  rosidl_dynamic_typesupport_dynamic_type_builder_build(flat_builder);
rosidl_dynamic_typesupport_dynamic_type_builder_fini(flat_builder);

// Create Dynamic Data
rosidl_dynamic_typesupport_dynamic_data_t * flat_data =
  rosidl_dynamic_typesupport_dynamic_data_init_from_dynamic_type(flat_type);

// Dynamic Data Setters
rosidl_dynamic_typesupport_dynamic_data_set_bool_value(flat_data, 0, true);
rosidl_dynamic_typesupport_dynamic_data_set_int32_value(flat_data, 1, 42);
rosidl_dynamic_typesupport_dynamic_data_set_string_value(flat_data, 2, "rar");

// Dynamic Data Getters
bool a;
int32_t b;
char * c;

rosidl_dynamic_typesupport_dynamic_data_get_bool_value(flat_data, 0, &a);  // true
rosidl_dynamic_typesupport_dynamic_data_get_int32_value(flat_data, 1, &b);  // 42
rosidl_dynamic_typesupport_dynamic_data_get_string_value(flat_data, 2, &c);  // "rar"

// Cleanup
free(c);
rosidl_dynamic_typesupport_dynamic_data_fini(flat_data);

Some Terminology

  • Serialization support: What this library provides; A unified, serialization library agnostic interface
  • Serialization support library: The implementation of the serialization support interface, which this library calls into
  • Type description (aka message description): A description of the buffer that fulfills the rosidl spec (this typically takes the form of the TypeDescription struct generated from the type_descripion_interfaces package)
  • Dynamic type: The serialization support library's best-effort internal representation of the type description
  • Dynamic type builder: The serialization support library's means of constructing the dynamic type (on a field-by-field basis)
  • Dynamic data: The serialization support library's internal representation of the serialized buffer, informed by the dynamic type

Why Dynamic Typesupport?

  • Dynamic: This library dynamically changes its internal behavior based off its runtime input (e.g. what serialization library is loaded to be used with it)
  • Typesupport: And it supports the creation of, and access of types

This package differs from the usual ROS 2 notion of "dynamic" typesupport in that it offers runtime functionalities that change based off its input (hence dynamic), rather than compile-time code generation like the "dynamic" rosidl_typesupport_introspection package does (which generates introspectable typesupports at compile time.)

Furthermore, since this package does not actually generate any code, it is stored separately from the rosidl repository.

The Serialization Support Interface

The serialization support interface is supposed to be an interface that is generic enough to support run-time type reflection (or in other words, dynamic type support), and is written in C to allow for easy language binding with any downstream libraries that use it.

Its interface is inspired by rosidl, and the DDS XTypes 1.3 language bindings spec (pg. 175), but is still intended to be generic, and so should support non-DDS middlewares.

The Serialization Support includes, for each supported middleware:

  • Setting type members (dynamic type)
    • Note the lack of ability to get type members
  • Getting and setting data members based off that type (dynamic data)
  • Support for sequences and nested members
  • Utilities

The interface makes heavy use of void * casting to abstract away any necessary objects used with each serialization library.

A Note On Proper Usage

The serialization support capabilities of this library are meant to be used alongside a rosidl-compliant description of the message a buffer is meant to represent (the type description).

This is because there is a distinction between the rosidl description of a message, and what a serialization library can describe or express (in its dynamic type.) As such, the rosidl description should be the sole source of determine what specific dynamic data getter functions are called during the unpacking of the message. And the serialization support library is in charge of supporting mapping to and from what types it can support, and the rosidl types.

Consider the following, contrived example, where you have a message layout like so:

int int_field

Suppose you had a serialization library that only provisions support for raw bytes. In that case, the serialization support library written would probably end up treating the int_field field as raw bytes when constructing its dynamic type, which means that when the message gets deserialized, something must retain the knowledge that the int_field was supposed to be an int type.

This is precisely what the type description is for, which a user should programmatically traverse, and use to determine the appropriate int dynamic data getter to call. The serialization support library then should implement its int dynamic data getter to extract the field from the buffer (as raw bytes, since that is what the serialization library supports), and coerce the extracted type (raw bytes) to output an int value to return.

Additionally, this means that, in order to support such cases, the serialization library must either:

  • Use the same member/field indexing as is used in the type description
  • Have an alternate means to find the field described in the type description (e.g. by matching field names)

Note: There was a consideration to populate the dynamic type/data objects with the type description instead. But as the type description and dynamic type encompasses two subtly different concerns (rosidl compliance, and serialization library specific type support, respectively), it makes sense to keep them separate. And this is especially true given the fact that users are supposed to use the type description to call the appropriate getters.

Type IDs

The type IDs used by this library (in types.h) are pulling from the type_descripion_interfaces message definitions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ros_rosidl_dynamic_typesupport-0.3.1-cp314-cp314t-manylinux_2_28_x86_64.whl (76.9 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.28+ x86-64

ros_rosidl_dynamic_typesupport-0.3.1-cp314-cp314-manylinux_2_28_x86_64.whl (76.9 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

ros_rosidl_dynamic_typesupport-0.3.1-cp313-cp313-manylinux_2_28_x86_64.whl (76.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

ros_rosidl_dynamic_typesupport-0.3.1-cp312-cp312-manylinux_2_28_x86_64.whl (76.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

ros_rosidl_dynamic_typesupport-0.3.1-cp311-cp311-manylinux_2_28_x86_64.whl (76.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

ros_rosidl_dynamic_typesupport-0.3.1-cp310-cp310-manylinux_2_28_x86_64.whl (76.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

File details

Details for the file ros_rosidl_dynamic_typesupport-0.3.1-cp314-cp314t-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ros_rosidl_dynamic_typesupport-0.3.1-cp314-cp314t-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 617e7a7ecb39a0f2cd989e70d1ce7312a6126a8ff02f40f2389c195a4f65a239
MD5 b84d61b5b14932ea1e61b54c590adc90
BLAKE2b-256 c261a07e12484d58d09f67c595d38d33b1b217607dd18aa3ac905d0ed932db5b

See more details on using hashes here.

File details

Details for the file ros_rosidl_dynamic_typesupport-0.3.1-cp314-cp314-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ros_rosidl_dynamic_typesupport-0.3.1-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6dcbffffefd7e390455f9872eaab955500ac646e0c12a42f8b42451d2aeb5ed6
MD5 71d6e3b7e90831489c92f1fd5c5c0aa1
BLAKE2b-256 73a5961a747de73b860bf1faf7505529d85d8e82f0267b89d6038e3920114c41

See more details on using hashes here.

File details

Details for the file ros_rosidl_dynamic_typesupport-0.3.1-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ros_rosidl_dynamic_typesupport-0.3.1-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 365d601ef94bc417c9e050a022fe9409d928904f1023daf053434473a6a3c772
MD5 5538470c1d343273e1452c2c67046736
BLAKE2b-256 6ad5156cb389369f7b928784bc3f2331c5aba5f88cc9cdc6393742aca59b2883

See more details on using hashes here.

File details

Details for the file ros_rosidl_dynamic_typesupport-0.3.1-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ros_rosidl_dynamic_typesupport-0.3.1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c55e3bcc76d55ad11ab8339fd7000a4fe0bee09b1c95c22596da2b290fcee5d0
MD5 a545c11fdd02c9f3339ffbf9b51b500d
BLAKE2b-256 9cc5b69c411bda3e611af51613d110df530ccda082f2ae0433919fb22ed2e191

See more details on using hashes here.

File details

Details for the file ros_rosidl_dynamic_typesupport-0.3.1-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ros_rosidl_dynamic_typesupport-0.3.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e419ae8ef26bc96a86313fd5c085129a8b12d65f789f14af830a27bece225c44
MD5 f79711bd7639311625d1d2d07603e6f4
BLAKE2b-256 fe74ffa65af6d4d9ad67ee60ba87d098af7cc34214ec154cac3f2b2876b7664b

See more details on using hashes here.

File details

Details for the file ros_rosidl_dynamic_typesupport-0.3.1-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ros_rosidl_dynamic_typesupport-0.3.1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b1ea2258e8b139f246928274ebc6d09527e096f4fee366f566bfaf22b4a3fbac
MD5 f855bf60672b2b2b5b9c22b8e3ce1bf4
BLAKE2b-256 98930002e08121cce76af1b3ce91a36802215dab5de11828053b7860fc069114

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page