micro-ROS Utils

micro-ROS Types Utilities

Classes

  Name
struct micro_ros_utilities_memory_rule_t
Memory rule.
struct micro_ros_utilities_memory_conf_t
Memory configuration string.

Functions

  Name
MICRO_ROS_UTILITIES_PUBLIC rosidl_runtime_c__String micro_ros_utilities_type_info(const rosidl_message_type_support_t * type_support)
Returns a string with the type introspection data.
MICRO_ROS_UTILITIES_PUBLIC size_t micro_ros_utilities_get_dynamic_size(const rosidl_message_type_support_t * type_support, const micro_ros_utilities_memory_conf_t conf)
Returns the dynamic memory size that will be used for a type.
MICRO_ROS_UTILITIES_PUBLIC size_t micro_ros_utilities_get_static_size(const rosidl_message_type_support_t * type_support, const micro_ros_utilities_memory_conf_t conf)
Returns the static memory size that will be used for a type.
MICRO_ROS_UTILITIES_PUBLIC bool micro_ros_utilities_create_message_memory(const rosidl_message_type_support_t * type_support, void * ros_msg, const micro_ros_utilities_memory_conf_t conf)
Allocates the dynamic memory required for a message.
MICRO_ROS_UTILITIES_PUBLIC bool micro_ros_utilities_create_static_message_memory(const rosidl_message_type_support_t * type_support, void * ros_msg, const micro_ros_utilities_memory_conf_t conf, uint8_t * buffer, size_t buffer_len)
Allocates the memory required for a message in a user-provided buffer.
MICRO_ROS_UTILITIES_PUBLIC bool micro_ros_utilities_destroy_message_memory(const rosidl_message_type_support_t * type_support, void * ros_msg, const micro_ros_utilities_memory_conf_t conf)
Deallocates the dynamic memory of a message.

Functions Documentation

function micro_ros_utilities_type_info

MICRO_ROS_UTILITIES_PUBLIC rosidl_runtime_c__String micro_ros_utilities_type_info(
    const rosidl_message_type_support_t * type_support
)

Returns a string with the type introspection data.

Parameters:

  • type_support ROS 2 typesupport

Return: rosidl_runtime_c__String string containing data


Attribute Adherence
Allocates Memory Yes
Thread-Safe No
Uses Atomics No
Lock-Free Yes

function micro_ros_utilities_get_dynamic_size

MICRO_ROS_UTILITIES_PUBLIC size_t micro_ros_utilities_get_dynamic_size(
    const rosidl_message_type_support_t * type_support,
    const micro_ros_utilities_memory_conf_t conf
)

Returns the dynamic memory size that will be used for a type.

Parameters:

  • type_support ROS 2 typesupport
  • conf Utils configurator

Return: size_t Size in Bytes that will be used


Attribute Adherence
Allocates Memory Yes
Thread-Safe No
Uses Atomics No
Lock-Free Yes

function micro_ros_utilities_get_static_size

MICRO_ROS_UTILITIES_PUBLIC size_t micro_ros_utilities_get_static_size(
    const rosidl_message_type_support_t * type_support,
    const micro_ros_utilities_memory_conf_t conf
)

Returns the static memory size that will be used for a type.

Parameters:

  • type_support ROS 2 typesupport
  • conf Utils configurator

Return: size_t Size in Bytes that will be used


Attribute Adherence
Allocates Memory Yes
Thread-Safe No
Uses Atomics No
Lock-Free Yes

function micro_ros_utilities_create_message_memory

MICRO_ROS_UTILITIES_PUBLIC bool micro_ros_utilities_create_message_memory(
    const rosidl_message_type_support_t * type_support,
    void * ros_msg,
    const micro_ros_utilities_memory_conf_t conf
)

Allocates the dynamic memory required for a message.

Parameters:

  • type_support ROS 2 typesupport
  • ros_msg ROS 2 msg with no type
  • conf Utils configurator

Return: bool true if success


Attribute Adherence
Allocates Memory Yes
Thread-Safe No
Uses Atomics No
Lock-Free Yes

function micro_ros_utilities_create_static_message_memory

MICRO_ROS_UTILITIES_PUBLIC bool micro_ros_utilities_create_static_message_memory(
    const rosidl_message_type_support_t * type_support,
    void * ros_msg,
    const micro_ros_utilities_memory_conf_t conf,
    uint8_t * buffer,
    size_t buffer_len
)

Allocates the memory required for a message in a user-provided buffer.

Parameters:

  • type_support ROS 2 typesupport
  • ros_msg ROS 2 msg with no type
  • conf Utils configurator
  • buffer User buffer
  • buffer_len User buffer length

Return: bool true if success


Attribute Adherence
Allocates Memory Yes
Thread-Safe No
Uses Atomics No
Lock-Free Yes

function micro_ros_utilities_destroy_message_memory

MICRO_ROS_UTILITIES_PUBLIC bool micro_ros_utilities_destroy_message_memory(
    const rosidl_message_type_support_t * type_support,
    void * ros_msg,
    const micro_ros_utilities_memory_conf_t conf
)

Deallocates the dynamic memory of a message.

Parameters:

  • type_support ROS 2 typesupport
  • ros_msg ROS 2 msg with no type
  • conf Utils configurator

Return: bool true if success


Attribute Adherence
Allocates Memory Yes
Thread-Safe No
Uses Atomics No
Lock-Free Yes

Attributes Documentation

variable micro_ros_utilities_memory_conf_default

static const micro_ros_utilities_memory_conf_t micro_ros_utilities_memory_conf_default =
{20, 5, 5, NULL, 0, NULL};

micro-ROS String Utilities

Functions

  Name
MICRO_ROS_UTILITIES_PUBLIC rosidl_runtime_c__String micro_ros_string_utilities_init(const char * data)
Create a rosidl_runtime_c__String from a char pointer.
MICRO_ROS_UTILITIES_PUBLIC rosidl_runtime_c__String micro_ros_string_utilities_init_with_size(const size_t size)
Create a rosidl_runtime_c__String from a size.
MICRO_ROS_UTILITIES_PUBLIC rosidl_runtime_c__String micro_ros_string_utilities_set(const rosidl_runtime_c__String str, const char * data)
Create a rosidl_runtime_c__String from a char pointer.
const MICRO_ROS_UTILITIES_PUBLIC char * micro_ros_string_utilities_get_c_str(const rosidl_runtime_c__String str)
Returns the char pointer to the rosidl_runtime_c__String data.
rosidl_runtime_c__String micro_ros_string_utilities_append(const rosidl_runtime_c__String str, const char * data)
Appends a char pointer to the end of a rosidl_runtime_c__String.
MICRO_ROS_UTILITIES_PUBLIC rosidl_runtime_c__String micro_ros_string_utilities_remove_tail_chars(const rosidl_runtime_c__String str, const size_t n)
Removes characters from the end of a string.
MICRO_ROS_UTILITIES_PUBLIC void micro_ros_string_utilities_destroy(rosidl_runtime_c__String *const str)
Destroys a rosidl_runtime_c__String.

Functions Documentation

function micro_ros_string_utilities_init

MICRO_ROS_UTILITIES_PUBLIC rosidl_runtime_c__String micro_ros_string_utilities_init(
    const char * data
)

Create a rosidl_runtime_c__String from a char pointer.

Parameters:

  • data char pointer

Return: rosidl_runtime_c__String string containing data


Attribute Adherence
Allocates Memory Yes
Thread-Safe No
Uses Atomics No
Lock-Free Yes

function micro_ros_string_utilities_init_with_size

MICRO_ROS_UTILITIES_PUBLIC rosidl_runtime_c__String micro_ros_string_utilities_init_with_size(
    const size_t size
)

Create a rosidl_runtime_c__String from a size.

Parameters:

  • size size of the required string

Return: rosidl_runtime_c__String string of size size


Attribute Adherence
Allocates Memory Yes
Thread-Safe No
Uses Atomics No
Lock-Free Yes

function micro_ros_string_utilities_set

MICRO_ROS_UTILITIES_PUBLIC rosidl_runtime_c__String micro_ros_string_utilities_set(
    const rosidl_runtime_c__String str,
    const char * data
)

Create a rosidl_runtime_c__String from a char pointer.

Parameters:

  • str rosidl_runtime_c__String to set
  • data char pointer

Return: rosidl_runtime_c__String string containing data


Attribute Adherence
Allocates Memory Yes
Thread-Safe No
Uses Atomics No
Lock-Free Yes

function micro_ros_string_utilities_get_c_str

const MICRO_ROS_UTILITIES_PUBLIC char * micro_ros_string_utilities_get_c_str(
    const rosidl_runtime_c__String str
)

Returns the char pointer to the rosidl_runtime_c__String data.

Parameters:

  • str a rosidl_runtime_c__String

Return: const char char pointer


Attribute Adherence
Allocates Memory Yes
Thread-Safe No
Uses Atomics No
Lock-Free Yes

function micro_ros_string_utilities_append

rosidl_runtime_c__String micro_ros_string_utilities_append(
    const rosidl_runtime_c__String str,
    const char * data
)

Appends a char pointer to the end of a rosidl_runtime_c__String.

Parameters:

  • str a rosidl_runtime_c__String
  • data characters to append

Return: rosidl_runtime_c__String new string


Attribute Adherence
Allocates Memory Yes
Thread-Safe No
Uses Atomics No
Lock-Free Yes

function micro_ros_string_utilities_remove_tail_chars

MICRO_ROS_UTILITIES_PUBLIC rosidl_runtime_c__String micro_ros_string_utilities_remove_tail_chars(
    const rosidl_runtime_c__String str,
    const size_t n
)

Removes characters from the end of a string.

Parameters:

  • str a rosidl_runtime_c__String
  • n number of characters to remove

Return: rosidl_runtime_c__String new string


Attribute Adherence
Allocates Memory Yes
Thread-Safe No
Uses Atomics No
Lock-Free Yes

function micro_ros_string_utilities_destroy

MICRO_ROS_UTILITIES_PUBLIC void micro_ros_string_utilities_destroy(
    rosidl_runtime_c__String *const str
)

Destroys a rosidl_runtime_c__String.

Parameters:

  • str a rosidl_runtime_c__String

Attribute Adherence
Allocates Memory Yes
Thread-Safe No
Uses Atomics No
Lock-Free Yes

micro_ros_utilities_memory_rule_t

Memory rule.

#include <type_utilities.h>

Public Attributes

  Name
const char * rule
Pattern matching the fully qualified name of a msg field.
size_t size
Maximum string or sequence capacity for fields matching rule.

Public Attributes Documentation

variable rule

const char * rule;

Pattern matching the fully qualified name of a msg field.

variable size

size_t size;

Maximum string or sequence capacity for fields matching rule.


micro_ros_utilities_memory_conf_t

Memory configuration string.

#include <type_utilities.h>

Public Attributes

  Name
size_t max_string_capacity
Maximum string capacity to use for msg fields in case they don’t have a custom rule assigned to them.
size_t max_ros2_type_sequence_capacity
Maximum capacity to use for sequence type msg fields (ie: unbounded arrays and lists) which contain ROS 2 msg types, in case they don’t have a custom rule assigned to them.
size_t max_basic_type_sequence_capacity
Maximum capacity to use for sequence type msg fields (ie: unbounded arrays and lists) which contain basic types (ie: primitive field types), in case they don’t have a custom rule assigned to them.
const micro_ros_utilities_memory_rule_t * rules
All rules defined in this configuration.
size_t n_rules
Total number of rules defined in this configuration.
const rcutils_allocator_t * allocator
The allocator to use when applying this configuration.

Public Attributes Documentation

variable max_string_capacity

size_t max_string_capacity;

Maximum string capacity to use for msg fields in case they don’t have a custom rule assigned to them.

variable max_ros2_type_sequence_capacity

size_t max_ros2_type_sequence_capacity;

Maximum capacity to use for sequence type msg fields (ie: unbounded arrays and lists) which contain ROS 2 msg types, in case they don’t have a custom rule assigned to them.

variable max_basic_type_sequence_capacity

size_t max_basic_type_sequence_capacity;

Maximum capacity to use for sequence type msg fields (ie: unbounded arrays and lists) which contain basic types (ie: primitive field types), in case they don’t have a custom rule assigned to them.

variable rules

const micro_ros_utilities_memory_rule_t * rules;

All rules defined in this configuration.

variable n_rules

size_t n_rules;

Total number of rules defined in this configuration.

variable allocator

const rcutils_allocator_t * allocator;

The allocator to use when applying this configuration.