Skip to content

Commit

Permalink
rename rcl_service_introspection_utils to rcl_service_event_publisher
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Chen <brian.chen@openrobotics.org>
  • Loading branch information
ihasdapie committed Aug 10, 2022
1 parent d1739d2 commit 7a2988d
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 29 deletions.
20 changes: 8 additions & 12 deletions rcl/include/rcl/introspection.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extern "C"
#define RCL_SERVICE_INTROSPECTION_PUBLISH_SERVICE_EVENT_CONTENT_PARAMETER "publish_service_content"


typedef struct rcl_service_introspection_utils_s {
typedef struct rcl_service_event_publisher_s {
/// Handle to clock for timestamping service events
rcl_clock_t * clock;
/// Handle to publisher for publishing service events
Expand All @@ -46,7 +46,7 @@ typedef struct rcl_service_introspection_utils_s {
bool _enabled;
// Enable/disable passing along service introspection content during runtime
bool _content_enabled;
} rcl_service_introspection_utils_t;
} rcl_service_event_publisher_t;

RCL_PUBLIC
RCL_WARN_UNUSED
Expand All @@ -59,14 +59,14 @@ rcl_service_typesupport_to_message_typesupport(

RCL_PUBLIC
RCL_WARN_UNUSED
rcl_service_introspection_utils_t
rcl_service_event_publisher_t
rcl_get_zero_initialized_introspection_utils();

RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_service_introspection_init(
rcl_service_introspection_utils_t * introspection_utils,
rcl_service_event_publisher_t * introspection_utils,
const rosidl_service_type_support_t * service_type_support,
const char * service_name,
const rcl_node_t * node,
Expand All @@ -77,25 +77,21 @@ RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_service_introspection_fini(
rcl_service_introspection_utils_t * introspection_utils,
rcl_service_event_publisher_t * introspection_utils,
rcl_allocator_t * allocator,
rcl_node_t * node);

RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_introspection_send_message(
const rcl_service_introspection_utils_t * introspection_utils,
const rcl_service_event_publisher_t * introspection_utils,
uint8_t event_type,
const void * ros_response_request,
int64_t sequence_number,
const uint8_t uuid[16], // uuid is uint8_t but the guid is int8_t
const rcl_allocator_t * allocator);





/* Enables service introspection by reconstructing the introspection clock and publisher
*
* Does nothing and returns RCL_RET_OK if already enabled
Expand All @@ -104,7 +100,7 @@ RCL_LOCAL
RCL_WARN_UNUSED
rcl_ret_t
rcl_service_introspection_enable(
rcl_service_introspection_utils_t * introspection_utils,
rcl_service_event_publisher_t * introspection_utils,
const rcl_node_t * node,
rcl_allocator_t * allocator);

Expand All @@ -120,7 +116,7 @@ RCL_LOCAL
RCL_WARN_UNUSED
rcl_ret_t
rcl_service_introspection_disable(
rcl_service_introspection_utils_t * introspection_utils,
rcl_service_event_publisher_t * introspection_utils,
rcl_node_t * node,
const rcl_allocator_t * allocator);

Expand Down
4 changes: 2 additions & 2 deletions rcl/src/rcl/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ rcl_client_init(

client->impl->introspection_utils = NULL;
if (options->enable_service_introspection) {
client->impl->introspection_utils = (rcl_service_introspection_utils_t *) allocator->allocate(
sizeof(rcl_service_introspection_utils_t), allocator->state);
client->impl->introspection_utils = (rcl_service_event_publisher_t *) allocator->allocate(
sizeof(rcl_service_event_publisher_t), allocator->state);
*client->impl->introspection_utils = rcl_get_zero_initialized_introspection_utils();
ret = rcl_service_introspection_init(
client->impl->introspection_utils, type_support, remapped_service_name, node,
Expand Down
2 changes: 1 addition & 1 deletion rcl/src/rcl/client_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct rcl_client_impl_s
rmw_qos_profile_t actual_response_subscription_qos;
rmw_client_t * rmw_handle;
atomic_int_least64_t sequence_number;
rcl_service_introspection_utils_t * introspection_utils;
rcl_service_event_publisher_t * introspection_utils;
};

#endif // RCL__CLIENT_IMPL_H_
21 changes: 10 additions & 11 deletions rcl/src/rcl/introspection.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ extern "C" {
#include "unique_identifier_msgs/msg/uuid.h"
#include "service_msgs/msg/service_event_info.h"

rcl_service_introspection_utils_t rcl_get_zero_initialized_introspection_utils()
rcl_service_event_publisher_t rcl_get_zero_initialized_introspection_utils()
{
static rcl_service_introspection_utils_t null_introspection_utils = {
static rcl_service_event_publisher_t null_introspection_utils = {
.service_type_support = NULL,
.publisher = NULL,
.clock = NULL,
Expand Down Expand Up @@ -110,7 +110,7 @@ rcl_ret_t rcl_service_typesupport_to_message_typesupport(
}

rcl_ret_t rcl_service_introspection_init(
rcl_service_introspection_utils_t * introspection_utils,
rcl_service_event_publisher_t * introspection_utils,
const rosidl_service_type_support_t * service_type_support,
const char * service_name,
const rcl_node_t * node,
Expand All @@ -124,6 +124,7 @@ rcl_ret_t rcl_service_introspection_init(
// Can do this because typesupports have static lifetimes
introspection_utils->service_type_support = service_type_support;


// Make a publisher
if (strlen(service_name) > 255 - strlen(RCL_SERVICE_INTROSPECTION_TOPIC_POSTFIX)) {
// topics have a maximum length of 255 characters
Expand Down Expand Up @@ -151,7 +152,7 @@ rcl_ret_t rcl_service_introspection_init(
}

rcl_ret_t rcl_service_introspection_fini(
rcl_service_introspection_utils_t * introspection_utils, rcl_allocator_t * allocator,
rcl_service_event_publisher_t * introspection_utils, rcl_allocator_t * allocator,
rcl_node_t * node)
{
rcl_ret_t ret;
Expand All @@ -166,16 +167,14 @@ rcl_ret_t rcl_service_introspection_fini(
if (NULL != introspection_utils->publisher) {
allocator->deallocate(introspection_utils->publisher, allocator->state);
}
allocator->deallocate(introspection_utils->service_event_topic_name, allocator->state);

introspection_utils->publisher = NULL;
introspection_utils->service_event_topic_name = NULL;

return RCL_RET_OK;
}

rcl_ret_t rcl_introspection_send_message(
const rcl_service_introspection_utils_t * introspection_utils, const uint8_t event_type,
const rcl_service_event_publisher_t * introspection_utils, const uint8_t event_type,
const void * ros_response_request, const int64_t sequence_number, const uint8_t uuid[16],
const rcl_allocator_t * allocator)
{
Expand Down Expand Up @@ -239,7 +238,7 @@ rcl_ret_t rcl_introspection_send_message(
}

rcl_ret_t rcl_service_introspection_enable(
rcl_service_introspection_utils_t * introspection_utils, const rcl_node_t * node,
rcl_service_event_publisher_t * introspection_utils, const rcl_node_t * node,
rcl_allocator_t * allocator)
{
rcl_ret_t ret;
Expand All @@ -262,7 +261,7 @@ rcl_ret_t rcl_service_introspection_enable(
}

rcl_ret_t rcl_service_introspection_disable(
rcl_service_introspection_utils_t * introspection_utils, rcl_node_t * node,
rcl_service_event_publisher_t * introspection_utils, rcl_node_t * node,
const rcl_allocator_t * allocator)
{
rcl_ret_t ret;
Expand All @@ -282,7 +281,7 @@ rcl_ret_t rcl_service_introspection_disable(
rcl_ret_t rcl_service_introspection_configure_service_events(
rcl_service_t * service, rcl_node_t * node, bool enable)
{
rcl_service_introspection_utils_t * introspection_utils = service->impl->introspection_utils;
rcl_service_event_publisher_t * introspection_utils = service->impl->introspection_utils;

if (enable == introspection_utils->_enabled) {
return RCL_RET_OK;
Expand All @@ -307,7 +306,7 @@ rcl_ret_t rcl_service_introspection_configure_service_events(
rcl_ret_t rcl_service_introspection_configure_client_events(
rcl_client_t * client, rcl_node_t * node, bool enable)
{
rcl_service_introspection_utils_t * introspection_utils = client->impl->introspection_utils;
rcl_service_event_publisher_t * introspection_utils = client->impl->introspection_utils;

if (enable == introspection_utils->_enabled) {
return RCL_RET_OK;
Expand Down
4 changes: 2 additions & 2 deletions rcl/src/rcl/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ rcl_service_init(

service->impl->introspection_utils = NULL;
if (options->enable_service_introspection) {
service->impl->introspection_utils = (rcl_service_introspection_utils_t *) allocator->allocate(
sizeof(rcl_service_introspection_utils_t), allocator->state);
service->impl->introspection_utils = (rcl_service_event_publisher_t *) allocator->allocate(
sizeof(rcl_service_event_publisher_t), allocator->state);
*service->impl->introspection_utils = rcl_get_zero_initialized_introspection_utils();
ret = rcl_service_introspection_init(
service->impl->introspection_utils, type_support, remapped_service_name, node,
Expand Down
2 changes: 1 addition & 1 deletion rcl/src/rcl/service_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct rcl_service_impl_s
rmw_qos_profile_t actual_request_subscription_qos;
rmw_qos_profile_t actual_response_publisher_qos;
rmw_service_t * rmw_handle;
rcl_service_introspection_utils_t * introspection_utils;
rcl_service_event_publisher_t * introspection_utils;
};

#endif // RCL__SERVICE_IMPL_H_

0 comments on commit 7a2988d

Please sign in to comment.