RMW

micro-ROS RMW API

Functions

  Name
void rmw_uros_set_continous_serialization_callbacks(rmw_publisher_t * publisher, rmw_uros_continous_serialization_size size_cb, rmw_uros_continous_serialization serialization_cb)
Sets the callback functions for continous serialization for a publisher.
rmw_ret_t rmw_uros_set_custom_transport(bool framing, void * args, open_custom_func open_cb, close_custom_func close_cb, write_custom_func write_cb, read_custom_func read_cb)
Check if micro-ROS Agent answers to micro-ROS client.
rmw_ret_t rmw_uros_discover_agent(rmw_init_options_t * rmw_options)
Fills rmw implementation-specific options with the autodicovered address of an micro-ROS Agent.
rmw_ret_t rmw_uros_init_options(int argc, const char *const argv[], rmw_init_options_t * rmw_options)
Parses command line args and fills rmw implementation-specific options.
rmw_ret_t rmw_uros_options_set_serial_device(const char * dev, rmw_init_options_t * rmw_options)
Fills rmw implementation-specific options with the given parameters.
rmw_ret_t rmw_uros_options_set_udp_address(const char * ip, const char * port, rmw_init_options_t * rmw_options)
Fills rmw implementation-specific options with the given parameters.
rmw_ret_t rmw_uros_options_set_client_key(uint32_t client_key, rmw_init_options_t * rmw_options)
Fills rmw implementation-specific options with the given parameters.
rmw_ret_t rmw_uros_ping_agent(const int timeout_ms, const uint8_t attempts)
Check if micro-ROS Agent is up and running.
bool rmw_uros_epoch_synchronized()
Returns the time synchronization state of the epoch time.
int64_t rmw_uros_epoch_millis()
Returns the epoch time in milliseconds taking into account the offset computed during the time synchronization.
int64_t rmw_uros_epoch_nanos()
Returns the epoch time in nanoseconds taking into account the offset computed during the time synchronization.
rmw_ret_t rmw_uros_sync_session(const int timeout_ms)
Synchronizes the session time using the NTP protocol.

Functions Documentation

function rmw_uros_set_continous_serialization_callbacks

void rmw_uros_set_continous_serialization_callbacks(
    rmw_publisher_t * publisher,
    rmw_uros_continous_serialization_size size_cb,
    rmw_uros_continous_serialization serialization_cb
)

Sets the callback functions for continous serialization for a publisher.

Parameters:

  • publisher publisher where continous serialization is being configured
  • size_cb callback that should modify the total serialization size
  • serialization_cb callback that should serialize the user part of the message

function rmw_uros_set_custom_transport

rmw_ret_t rmw_uros_set_custom_transport(
    bool framing,
    void * args,
    open_custom_func open_cb,
    close_custom_func close_cb,
    write_custom_func write_cb,
    read_custom_func read_cb
)

Check if micro-ROS Agent answers to micro-ROS client.

Parameters:

  • framing Enable XRCE framing.
  • args Arguments for open function.
  • open_cb Open transport callback.
  • close_cb Close transport callback.
  • write_cb Write transport callback.
  • read_cb Read transport callback.

Return:

  • RMW_RET_OK If correct.
  • RMW_RET_ERROR If invalid.

function rmw_uros_discover_agent

rmw_ret_t rmw_uros_discover_agent(
    rmw_init_options_t * rmw_options
)

Fills rmw implementation-specific options with the autodicovered address of an micro-ROS Agent.

Parameters:

  • rmw_options Updated options with rmw specifics.

Return:

  • RMW_RET_OK If arguments were valid and set in rmw_init_options.
  • RMW_RET_TIMEOUT If micro-ROS agent autodiscovery is timeout.
  • RMW_RET_INVALID_ARGUMENT If rmw_init_options is not valid or unexpected arguments.

function rmw_uros_init_options

rmw_ret_t rmw_uros_init_options(
    int argc,
    const char *const argv[],
    rmw_init_options_t * rmw_options
)

Parses command line args and fills rmw implementation-specific options.

Parameters:

  • argc Number of arguments.
  • argv Arguments.
  • rmw_options Updated options with rmw specifics.

Return:

  • RMW_RET_OK If arguments were valid and set in rmw_init_options.
  • RMW_RET_INVALID_ARGUMENT If rmw_init_options is not valid or unexpected arguments.

rmw_init_options allocator is used to allocate the specific rmw options.

function rmw_uros_options_set_serial_device

rmw_ret_t rmw_uros_options_set_serial_device(
    const char * dev,
    rmw_init_options_t * rmw_options
)

Fills rmw implementation-specific options with the given parameters.

Parameters:

  • dev Serial device.
  • rmw_options Updated options with rmw specifics.

Return:

  • RMW_RET_OK If arguments were valid and set in rmw_init_options.
  • RMW_RET_INVALID_ARGUMENT If rmw_init_options is not valid or unexpected arguments.

function rmw_uros_options_set_udp_address

rmw_ret_t rmw_uros_options_set_udp_address(
    const char * ip,
    const char * port,
    rmw_init_options_t * rmw_options
)

Fills rmw implementation-specific options with the given parameters.

Parameters:

  • ip Agent IP address.
  • port Agent UDP port.
  • rmw_options Updated options with rmw specifics.

Return:

  • RMW_RET_OK If arguments were valid and set in rmw_init_options.
  • RMW_RET_INVALID_ARGUMENT If rmw_init_options is not valid or unexpected arguments.

function rmw_uros_options_set_client_key

rmw_ret_t rmw_uros_options_set_client_key(
    uint32_t client_key,
    rmw_init_options_t * rmw_options
)

Fills rmw implementation-specific options with the given parameters.

Parameters:

  • client_key MicroXRCE-DDS client key.
  • rmw_options Updated options with rmw specifics.

Return:

  • RMW_RET_OK If arguments were valid and set in rmw_init_options.
  • RMW_RET_INVALID_ARGUMENT If rmw_init_options is not valid or unexpected arguments.

function rmw_uros_ping_agent

rmw_ret_t rmw_uros_ping_agent(
    const int timeout_ms,
    const uint8_t attempts
)

Check if micro-ROS Agent is up and running.

Parameters:

  • timeout_ms Timeout in ms (per attempt).
  • attempts Number of tries before considering the ping as failed.

Return:

  • RMW_RET_OK If micro-ROS Agent is available.
  • RMW_RET_ERROR If micro-ROS Agent is not available.

This function can be called even when the micro-ROS context has not yet been initialized by the application logics.

function rmw_uros_epoch_synchronized

bool rmw_uros_epoch_synchronized()

Returns the time synchronization state of the epoch time.

Return: true if last time synchronization succeded and false otherwise

function rmw_uros_epoch_millis

int64_t rmw_uros_epoch_millis()

Returns the epoch time in milliseconds taking into account the offset computed during the time synchronization.

Return:

  • epoch time in milliseconds.
  • 0 if session is not initialized.

function rmw_uros_epoch_nanos

int64_t rmw_uros_epoch_nanos()

Returns the epoch time in nanoseconds taking into account the offset computed during the time synchronization.

Return:

  • epoch time in nanoseconds.
  • 0 if session is not initialized.

function rmw_uros_sync_session

rmw_ret_t rmw_uros_sync_session(
    const int timeout_ms
)

Synchronizes the session time using the NTP protocol.

Parameters:

  • timeout_ms The waiting time in milliseconds.

Return:

  • RMW_RET_OK when success.
  • RMW_RET_ERROR If no session is running or the synchronization fails.