Function rmw_get_gid_for_publisher

Function Documentation

rmw_ret_t rmw_get_gid_for_publisher(const rmw_publisher_t *publisher, rmw_gid_t *gid)

Get the globally unique identifier (GID) of a publisher.

Attribute

Adherence

Allocates Memory

No

Thread-Safe

Yes

Uses Atomics

Maybe [1]

Lock-Free

Maybe [1]

[1] implementation defined, check implementation documentation.

This is expected to be globally unique within a ROS domain. The identifier should be the same when reported both locally (where the entity was created) and on remote hosts or processes.

Thread-safety

Publishers are thread-safe objects, and so are all operations on them except for finalization. Therefore, it is safe to get the unique identifier from the same publisher concurrently. However, access to the GID is not synchronized. It is not safe to read or write gid while rmw_get_gid_for_publisher() uses it.

Pre:

Given publisher must be a valid publisher, as returned by rmw_create_publisher().

Parameters:
  • publisher[in] Publisher to get a GID from.

  • gid[out] Publisher’s unique identifier, populated on success but left unchanged on failure.

Returns:

RMW_RET_OK if successful, or

Returns:

RMW_RET_INVALID_ARGUMENT if publisher is NULL, or

Returns:

RMW_RET_INVALID_ARGUMENT if gid is NULL, or

Returns:

RMW_RET_INCORRECT_RMW_IMPLEMENTATION if the publisher implementation identifier does not match this implementation, or

Returns:

RMW_RET_ERROR if an unspecified error occurs.