From 7670c01cc77429fbbba99fc484ddb84afcba43f2 Mon Sep 17 00:00:00 2001 From: Miaofei Date: Tue, 26 Feb 2019 18:00:15 -0800 Subject: [PATCH 01/28] initial qos interface changes Signed-off-by: Devin Bonnie Signed-off-by: Burek --- rmw/include/rmw/qos_profiles.h | 18 +++++++++++++++ rmw/include/rmw/rmw.h | 1 + rmw/include/rmw/types.h | 41 ++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) diff --git a/rmw/include/rmw/qos_profiles.h b/rmw/include/rmw/qos_profiles.h index 4749cbaf..2be5cd3f 100644 --- a/rmw/include/rmw/qos_profiles.h +++ b/rmw/include/rmw/qos_profiles.h @@ -28,6 +28,9 @@ static const rmw_qos_profile_t rmw_qos_profile_sensor_data = 5, RMW_QOS_POLICY_RELIABILITY_BEST_EFFORT, RMW_QOS_POLICY_DURABILITY_VOLATILE, + RMW_QOS_POLICY_DEADLINE_SYSTEM_DEFAULT, + RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT, + RMW_QOS_POLICY_LIFESPAN_SYSTEM_DEFAULT, false }; @@ -37,6 +40,9 @@ static const rmw_qos_profile_t rmw_qos_profile_parameters = 1000, RMW_QOS_POLICY_RELIABILITY_RELIABLE, RMW_QOS_POLICY_DURABILITY_VOLATILE, + RMW_QOS_POLICY_DEADLINE_SYSTEM_DEFAULT, + RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT, + RMW_QOS_POLICY_LIFESPAN_SYSTEM_DEFAULT, false }; @@ -46,6 +52,9 @@ static const rmw_qos_profile_t rmw_qos_profile_default = 10, RMW_QOS_POLICY_RELIABILITY_RELIABLE, RMW_QOS_POLICY_DURABILITY_VOLATILE, + RMW_QOS_POLICY_DEADLINE_SYSTEM_DEFAULT, + RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT, + RMW_QOS_POLICY_LIFESPAN_SYSTEM_DEFAULT, false }; @@ -55,6 +64,9 @@ static const rmw_qos_profile_t rmw_qos_profile_services_default = 10, RMW_QOS_POLICY_RELIABILITY_RELIABLE, RMW_QOS_POLICY_DURABILITY_VOLATILE, + RMW_QOS_POLICY_DEADLINE_SYSTEM_DEFAULT, + RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT, + RMW_QOS_POLICY_LIFESPAN_SYSTEM_DEFAULT, false }; @@ -64,6 +76,9 @@ static const rmw_qos_profile_t rmw_qos_profile_parameter_events = 1000, RMW_QOS_POLICY_RELIABILITY_RELIABLE, RMW_QOS_POLICY_DURABILITY_VOLATILE, + RMW_QOS_POLICY_DEADLINE_SYSTEM_DEFAULT, + RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT, + RMW_QOS_POLICY_LIFESPAN_SYSTEM_DEFAULT, false }; @@ -73,6 +88,9 @@ static const rmw_qos_profile_t rmw_qos_profile_system_default = RMW_QOS_POLICY_DEPTH_SYSTEM_DEFAULT, RMW_QOS_POLICY_RELIABILITY_SYSTEM_DEFAULT, RMW_QOS_POLICY_DURABILITY_SYSTEM_DEFAULT, + RMW_QOS_POLICY_DEADLINE_SYSTEM_DEFAULT, + RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT, + RMW_QOS_POLICY_LIFESPAN_SYSTEM_DEFAULT, false }; diff --git a/rmw/include/rmw/rmw.h b/rmw/include/rmw/rmw.h index 63d86b05..fe5b7c5b 100644 --- a/rmw/include/rmw/rmw.h +++ b/rmw/include/rmw/rmw.h @@ -615,6 +615,7 @@ rmw_wait( rmw_guard_conditions_t * guard_conditions, rmw_services_t * services, rmw_clients_t * clients, + rmw_events_t * events, rmw_wait_set_t * wait_set, const rmw_time_t * wait_timeout); diff --git a/rmw/include/rmw/types.h b/rmw/include/rmw/types.h index b3ea4fba..ae3f0f3a 100644 --- a/rmw/include/rmw/types.h +++ b/rmw/include/rmw/types.h @@ -73,6 +73,12 @@ typedef struct RMW_PUBLIC_TYPE rmw_client_t const char * service_name; } rmw_client_t; +typedef struct RMW_PUBLIC_TYPE rmw_event_t +{ + const char * implementation_identifier; + void * data; +} rmw_event_t; + typedef struct RMW_PUBLIC_TYPE rmw_guard_condition_t { const char * implementation_identifier; @@ -125,6 +131,15 @@ typedef struct RMW_PUBLIC_TYPE rmw_clients_t void ** clients; } rmw_clients_t; + +typedef struct RMW_PUBLIC_TYPE rmw_events_t +{ + /// The number of clients represented by the array. + size_t event_count; + /// Pointer to an array of void * pointers of clients. + void ** events; +} rmw_events_t; + /// Array of guard condition handles. /** * An array of void * pointers representing type-erased middleware-specific guard conditions. @@ -195,14 +210,40 @@ enum RMW_PUBLIC_TYPE rmw_qos_durability_policy_t RMW_QOS_POLICY_DURABILITY_UNKNOWN }; +enum RMW_PUBLIC_TYPE rmw_qos_deadline_policy_t +{ + RMW_QOS_POLICY_DEADLINE_SYSTEM_DEFAULT, + RMW_QOS_POLICY_DEADLINE_TRANSIENT_LOCAL, + RMW_QOS_POLICY_DEADLINE_VOLATILE +}; + +enum RMW_PUBLIC_TYPE rmw_qos_liveliness_policy_t +{ + RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT, + RMW_QOS_POLICY_LIVELINESS_TRANSIENT_LOCAL, + RMW_QOS_POLICY_LIVELINESS_VOLATILE +}; + +enum RMW_PUBLIC_TYPE rmw_qos_lifespan_policy_t +{ + RMW_QOS_POLICY_LIFESPAN_SYSTEM_DEFAULT, + RMW_QOS_POLICY_LIFESPAN_TRANSIENT_LOCAL, + RMW_QOS_POLICY_LIFESPAN_VOLATILE +}; + /// ROS MiddleWare quality of service profile. typedef struct RMW_PUBLIC_TYPE rmw_qos_profile_t { enum rmw_qos_history_policy_t history; /// Size of the message queue. size_t depth; + enum rmw_qos_reliability_policy_t reliability; enum rmw_qos_durability_policy_t durability; + enum rmw_qos_deadline_policy_t deadline; + enum rmw_qos_liveliness_policy_t liveliness; + enum rmw_qos_lifespan_policy_t lifespan; + /// If true, any ROS specific namespacing conventions will be circumvented. /** * In the case of DDS and topics, for example, this means the typical From e80a7b83933b223fa81cc47cfa8098b5228262db Mon Sep 17 00:00:00 2001 From: Miaofei Date: Thu, 28 Feb 2019 00:55:29 -0800 Subject: [PATCH 02/28] add creation of event waitable type Signed-off-by: Devin Bonnie Signed-off-by: Burek --- rmw/include/rmw/allocators.h | 8 ++++++++ rmw/include/rmw/rmw.h | 27 +++++++++++++++++++++++++++ rmw/include/rmw/types.h | 4 ++-- rmw/src/allocators.c | 14 ++++++++++++++ 4 files changed, 51 insertions(+), 2 deletions(-) diff --git a/rmw/include/rmw/allocators.h b/rmw/include/rmw/allocators.h index 3eec025d..f802115d 100644 --- a/rmw/include/rmw/allocators.h +++ b/rmw/include/rmw/allocators.h @@ -79,6 +79,14 @@ RMW_PUBLIC void rmw_service_free(rmw_service_t * service); +RMW_PUBLIC +rmw_event_t * +rmw_event_allocate(void); + +RMW_PUBLIC +void +rmw_event_free(rmw_event_t * event); + RMW_PUBLIC rmw_wait_set_t * rmw_wait_set_allocate(void); diff --git a/rmw/include/rmw/rmw.h b/rmw/include/rmw/rmw.h index fe5b7c5b..f7794482 100644 --- a/rmw/include/rmw/rmw.h +++ b/rmw/include/rmw/rmw.h @@ -223,6 +223,11 @@ rmw_create_publisher( const char * topic_name, const rmw_qos_profile_t * qos_policies); +RMW_PUBLIC +RMW_WARN_UNUSED +rmw_event_t * +rmw_create_publisher_event(const rmw_publisher_t * publisher); + RMW_PUBLIC RMW_WARN_UNUSED rmw_ret_t @@ -351,6 +356,11 @@ rmw_create_subscription( const rmw_qos_profile_t * qos_policies, bool ignore_local_publications); +RMW_PUBLIC +RMW_WARN_UNUSED +rmw_event_t * +rmw_create_subscription_event(const rmw_subscription_t * subscription); + RMW_PUBLIC RMW_WARN_UNUSED rmw_ret_t @@ -443,6 +453,11 @@ rmw_create_client( const char * service_name, const rmw_qos_profile_t * qos_policies); +RMW_PUBLIC +RMW_WARN_UNUSED +rmw_event_t * +rmw_create_client_event(const rmw_client_t * client); + RMW_PUBLIC RMW_WARN_UNUSED rmw_ret_t @@ -474,6 +489,11 @@ rmw_create_service( const char * service_name, const rmw_qos_profile_t * qos_policies); +RMW_PUBLIC +RMW_WARN_UNUSED +rmw_event_t * +rmw_create_service_event(const rmw_service_t * service); + RMW_PUBLIC RMW_WARN_UNUSED rmw_ret_t @@ -496,6 +516,13 @@ rmw_send_response( rmw_request_id_t * request_header, void * ros_response); + +RMW_PUBLIC +RMW_WARN_UNUSED +rmw_ret_t +rmw_destroy_event(rmw_event_t * event); + + // TODO(wjwwood): refactor this API to return a return code when updated to use an allocator /// Create a guard condition and return a handle to that guard condition. /** diff --git a/rmw/include/rmw/types.h b/rmw/include/rmw/types.h index ae3f0f3a..a2190398 100644 --- a/rmw/include/rmw/types.h +++ b/rmw/include/rmw/types.h @@ -134,9 +134,9 @@ typedef struct RMW_PUBLIC_TYPE rmw_clients_t typedef struct RMW_PUBLIC_TYPE rmw_events_t { - /// The number of clients represented by the array. + /// The number of events represented by the array. size_t event_count; - /// Pointer to an array of void * pointers of clients. + /// Pointer to an array of void * pointers of events. void ** events; } rmw_events_t; diff --git a/rmw/src/allocators.c b/rmw/src/allocators.c index 55ba070f..ad590717 100644 --- a/rmw/src/allocators.c +++ b/rmw/src/allocators.c @@ -126,6 +126,20 @@ rmw_service_free(rmw_service_t * service) rmw_free(service); } +rmw_event_t * +rmw_event_allocate() +{ + // Could be overridden with custom (maybe static) event struct allocator + return (rmw_event_t *)rmw_allocate(sizeof(rmw_event_t)); +} + +void +rmw_event_free(rmw_event_t * event) +{ + // Should have matching overide with rmw_event_allocate + rmw_free(event); +} + rmw_wait_set_t * rmw_wait_set_allocate() { From d2b076d19b879fec6e24de8547f5cc8d8412e1f0 Mon Sep 17 00:00:00 2001 From: Ross Desmond Date: Mon, 4 Mar 2019 22:54:17 +0000 Subject: [PATCH 03/28] Add rmw take_event interface Signed-off-by: Devin Bonnie Signed-off-by: Burek --- rmw/include/rmw/rmw.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/rmw/include/rmw/rmw.h b/rmw/include/rmw/rmw.h index f7794482..77039bee 100644 --- a/rmw/include/rmw/rmw.h +++ b/rmw/include/rmw/rmw.h @@ -444,6 +444,23 @@ rmw_take_serialized_message_with_info( bool * taken, rmw_message_info_t * message_info); +/* + * Take an event from the event handle. + * + * \param event subscription object to take from + * \param taken boolean flag indicating if an event was taken or not + * \return `RMW_RET_OK` if successful, or + * \return `RMW_RET_BAD_ALLOC` if memory allocation failed, or + * \return `RMW_RET_ERROR` if an unexpected error occurs. + */ +RMW_PUBLIC +RMW_WARN_UNUSED +rmw_ret_t +rmw_take_event( + const rmw_event_t * event_handle, + void * event, + bool * taken); + RMW_PUBLIC RMW_WARN_UNUSED rmw_client_t * From 8402cfefb1df7002e599633a21f63a1262a7bf68 Mon Sep 17 00:00:00 2001 From: Miaofei Date: Mon, 11 Mar 2019 13:56:20 -0700 Subject: [PATCH 04/28] add rmw event type enum Signed-off-by: Devin Bonnie Signed-off-by: Burek --- rmw/include/rmw/rmw.h | 4 ++-- rmw/include/rmw/types.h | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/rmw/include/rmw/rmw.h b/rmw/include/rmw/rmw.h index 77039bee..9d9f8100 100644 --- a/rmw/include/rmw/rmw.h +++ b/rmw/include/rmw/rmw.h @@ -226,7 +226,7 @@ rmw_create_publisher( RMW_PUBLIC RMW_WARN_UNUSED rmw_event_t * -rmw_create_publisher_event(const rmw_publisher_t * publisher); +rmw_create_publisher_event(const rmw_publisher_t * publisher, const rmw_event_type_t event_type); RMW_PUBLIC RMW_WARN_UNUSED @@ -359,7 +359,7 @@ rmw_create_subscription( RMW_PUBLIC RMW_WARN_UNUSED rmw_event_t * -rmw_create_subscription_event(const rmw_subscription_t * subscription); +rmw_create_subscription_event(const rmw_subscription_t * subscription, const rmw_event_type_t event_type); RMW_PUBLIC RMW_WARN_UNUSED diff --git a/rmw/include/rmw/types.h b/rmw/include/rmw/types.h index a2190398..7a0b6100 100644 --- a/rmw/include/rmw/types.h +++ b/rmw/include/rmw/types.h @@ -36,6 +36,24 @@ extern "C" // implementation. It may need to be increased in the future. #define RMW_GID_STORAGE_SIZE 24 + +typedef enum rmw_event_type_t +{ + RMW_EVENT_SAMPLE_REJECTED, + RMW_EVENT_LIVELINESS_CHANGED, + RMW_EVENT_REQUESTED_DEADLINE_MISSED, + RMW_EVENT_REQUESTED_INCOMPATIBLE_QOS, + RMW_EVENT_DATA_AVAILABLE, + RMW_EVENT_SAMPLE_LOST, + RMW_EVENT_SUBSCRIPTION_MATCHED, + + RMW_EVENT_LIVELINESS_LOST, + RMW_EVENT_OFFERED_DEADLINE_MISSED, + RMW_EVENT_OFFERED_INCOMPATIBLE_QOS, + RMW_EVENT_PUBLICATION_MATCHED +} rmw_event_type_t; + + typedef struct RMW_PUBLIC_TYPE rmw_node_t { const char * implementation_identifier; @@ -77,6 +95,7 @@ typedef struct RMW_PUBLIC_TYPE rmw_event_t { const char * implementation_identifier; void * data; + rmw_event_type_t event_type; } rmw_event_t; typedef struct RMW_PUBLIC_TYPE rmw_guard_condition_t From 67880eb907e091381ad2763a561c0e9cade40074 Mon Sep 17 00:00:00 2001 From: Ross Desmond Date: Tue, 12 Mar 2019 15:30:23 -0700 Subject: [PATCH 05/28] Modify events type from void** to rmw_event_t** Signed-off-by: Devin Bonnie Signed-off-by: Burek --- rmw/include/rmw/types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rmw/include/rmw/types.h b/rmw/include/rmw/types.h index 7a0b6100..1139974d 100644 --- a/rmw/include/rmw/types.h +++ b/rmw/include/rmw/types.h @@ -156,7 +156,7 @@ typedef struct RMW_PUBLIC_TYPE rmw_events_t /// The number of events represented by the array. size_t event_count; /// Pointer to an array of void * pointers of events. - void ** events; + rmw_event_t ** events; } rmw_events_t; /// Array of guard condition handles. From 6dbe51bdfda6a24bc306dde8506caca3a861ae88 Mon Sep 17 00:00:00 2001 From: Miaofei Date: Fri, 15 Mar 2019 03:10:42 -0700 Subject: [PATCH 06/28] fix lint errors Signed-off-by: Devin Bonnie Signed-off-by: Burek --- rmw/include/rmw/rmw.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rmw/include/rmw/rmw.h b/rmw/include/rmw/rmw.h index 9d9f8100..db9cc252 100644 --- a/rmw/include/rmw/rmw.h +++ b/rmw/include/rmw/rmw.h @@ -359,7 +359,9 @@ rmw_create_subscription( RMW_PUBLIC RMW_WARN_UNUSED rmw_event_t * -rmw_create_subscription_event(const rmw_subscription_t * subscription, const rmw_event_type_t event_type); +rmw_create_subscription_event( + const rmw_subscription_t * subscription, + const rmw_event_type_t event_type); RMW_PUBLIC RMW_WARN_UNUSED From 3c848363b7ed994ebf70b2ae83d8e7e6cccd211d Mon Sep 17 00:00:00 2001 From: Devin Bonnie Date: Fri, 15 Mar 2019 16:39:52 +0000 Subject: [PATCH 07/28] Added RMW QoS Event Definitions Signed-off-by: Devin Bonnie Signed-off-by: Burek --- rmw/include/rmw/types.h | 189 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 189 insertions(+) diff --git a/rmw/include/rmw/types.h b/rmw/include/rmw/types.h index 1139974d..f398eeb5 100644 --- a/rmw/include/rmw/types.h +++ b/rmw/include/rmw/types.h @@ -302,6 +302,195 @@ typedef enum RMW_PUBLIC_TYPE RMW_LOG_SEVERITY_FATAL = RCUTILS_LOG_SEVERITY_FATAL } rmw_log_severity_t; + +typedef struct RMW_STATUS +{ + rmw_event_type_t rmw_event_type; +} rmw_status_t; + +//Defined in the DDS SSpec 15-04-10 page 116 +typedef struct RMW_SAMPLE_LOST_STATUS +{ + //Total cumulative count of all samples lost across of instances of data published under the Topic. + int32_t total_count; + //The incremental number of samples lost since the last time the listener was called or the status was read. + int32_t total_count_change; + +} rmw_sample_lost_status_t; + +//Defined in the DDS SSpec 15-04-10 page 116 +typedef struct RMW_SAMPLE_REJECTED_STATUS +{ + //Total cumulative count of samples rejected by the DataReader. + int32_t total_count; + //The incremental number of samples rejected since the last time the listener was called or the status was read. + int32_t total_count_change; + /** + * Reason for rejecting the last sample rejected. If no samples have been rejected, the reason is the special value + * NOT_REJECTED. + */ + void * last_reason; + //Handle to the instance being updated by the last sample that was rejected. + void * last_instance_handle; + +} rmw_sample_rejected_status_t; + +//Defined in the DDS SSpec 15-04-10 page 116 +typedef struct RMW_LIVELINESS_CHANGED_STATUS +{ + /** + * The total number of currently active DataWriters that write the Topic read by the DataReader. This count + * increases when a newly matched DataWriter asserts its liveliness for the first time or when a DataWriter + * previously considered to be not alive reasserts its liveliness. The count decreases when a DataWriter considered + * alive fails to assert its liveliness and becomes not alive, whether because it was deleted normally or for some + * other reason. + */ + int32_t alive_count; + /** + * The total count of currently DataWriters that write the Topic read by the DataReader that are no longer asserting + * their liveliness. This count increases when a DataWriter considered alive fails to assert its liveliness and + * becomes not alive for some reason other than the normal deletion of that DataWriter. It decreases when a + * previously not alive DataWriter either reasserts its liveliness or is deleted normally. + */ + int32_t not_alive_count; + //The change in the alive_count since the last time the listener was called or the status was read. + int32_t alive_count_change; + //The change in the not_alive_count since the last time the listener was called or the status was read. + int32_t not_alive_count_change; + //Handle to the last DataWriter whose change in liveliness caused this status to change. + void * last_publication_handle; + +} rmw_liveliness_changed_status_t; + +//Defined in the DDS SSpec 15-04-10 page 116-117 +typedef struct RMW_REQUESTED_DEADLINE_MISSED_STATUS +{ + /** + * Total cumulative number of missed deadlines detected for any instance read by the DataReader. Missed deadlines + * accumulate; that is, each deadline period the total_count will be incremented by one for each instance for which + * data was not received. + */ + int32_t total_count; + //The incremental number of deadlines detected since the last time the listener was called or the status was read. + int32_t total_count_change; + //Handle to the last instance in the DataReader for which a deadline was detected. + void * last_instance_handle; + +} rmw_requested_deadline_missed_status_t; + +//Defined in the DDS SSpec 15-04-10 page 117 +typedef struct RMW_REQUESTED_INCOMPATIBLE_QOS_STATUS +{ + /** + * Total cumulative number of times the concerned DataReader discovered a DataWriter for the same Topic with an + * offered QoS that was incompatible with that requested by the DataReader. + */ + int32_t total_count; + //The change in total_count since the last time the listener was called or the status was read. + int32_t total_count_change; + /** + * A list containing for each policy the total number of times that the concerned DataReader discovered a + * DataWriter for the same Topic with an offered QoS that is incompatible with that requested by the DataReader. + */ + void * policies; + /** + * The QosPolicyId_t of one of the policies that was found to be incompatible the last time an incompatibility + * was detected. + */ + void * last_policy_id; + +} rmw_requested_incompatible_qos_status_t; + +//Defined in the DDS SSpec 15-04-10 page 118 +typedef struct RMW_SUBSCRIPTION_MATCHED_STATUS +{ + /** + * Total cumulative count the concerned DataReader discovered a “match” with a DataWriter. That is, it found a + * DataWriter for the same Topic with a requested QoS that is compatible with that offered by the DataReader. + */ + int32_t total_count; + //The change in total_count since the last time the listener was called or the status was read. + int32_t total_count_change; + //Handle to the last DataWriter that matched the DataReader causing the status to change. + int32_t current_count; + //The number of DataWriters currently matched to the concerned DataReader. + int32_t current_count_change; + //The change in current_count since the last time the listener was called or the status was read. + void * last_publication_handle; + +} rmw_subscription_matched_status_t; + +////Defined in the DDS SSpec 15-04-10 page 117 +typedef struct RMW_LIVELINESS_LOST +{ + /** + * Total cumulative number of times that a previously-alive DataWriter became not alive due to a failure to + * actively signal its liveliness within its offered liveliness period. This count does not change when an + * already not alive DataWriter simply remains not alive for another liveliness period. + */ + u_int32_t total_count; + //The change in total_count since the last time the listener was called or the status was read. + u_int32_t total_count_change; + +} rmw_liveliness_lost_t; + +//Defined in the DDS SSpec 15-04-10 page 117 +typedef struct RMW_OFFERED_DEADLINE_MISSED +{ + /** + * Total cumulative number of offered deadline periods elapsed during which a DataWriter failed to provide data. + * Missed deadlines accumulate; that is, each deadline period the total_count will be incremented by one. + */ + u_int32_t total_count; + //The change in total_count since the last time the listener was called or the status was read. + u_int32_t total_count_change; + //Handle to the last instance in the DataWriter for which an offered deadline was missed. + void * last_instance_handle; + +} rmw_offered_deadline_missed_t; + +//Defined in the DDS SSpec 15-04-10 page 117-118 +typedef struct RMW_OFFERED_INCOMPATIBLE_QOS +{ + /** + * Total cumulative number of times the concerned DataWriter discovered a DataReader for the same Topic with a + * requested QoS that is incompatible with that offered by the DataWriter. + */ + u_int32_t total_count; + //The change in total_count since the last time the listener was called or the status was read. + u_int32_t total_count_change; + /** + * The PolicyId_t of one of the policies that was found to be incompatible the last time an incompatibility + * was detected. + */ + void * last_policy_id; + /** + * A list containing for each policy the total number of times that the concerned DataWriter discovered a DataReader + * for the same Topic with a requested QoS that is incompatible with that offered by the DataWriter. + */ + void * policies; + +} rmw_offered_incompatible_qos_t; + +//Defined in the DDS SSpec 15-04-10 page 118 +typedef struct RMW_PUBLICATION_MATCHED +{ + /** + * Total cumulative count the concerned DataWriter discovered a “match” with a DataReader. That is, it found a + * DataReader for the same Topic with a requested QoS that is compatible with that offered by the DataWriter. + */ + u_int32_t total_count; + //The change in total_count since the last time the listener was called or the status was read. + u_int32_t total_count_change; + //The number of DataReaders currently matched to the concerned DataWriter. + u_int32_t current_count; + //The change in current_count since the last time the listener was called or the status was read. + u_int32_t current_count_change; + //Handle to the last DataReader that matched the DataWriter causing the status to change. + void * last_subscription_handle; + +} rmw_publication_matched_t; + #ifdef __cplusplus } #endif From 92c30253c279e679d22e64ccadb1570f864de0e6 Mon Sep 17 00:00:00 2001 From: Devin Bonnie Date: Fri, 15 Mar 2019 16:39:52 +0000 Subject: [PATCH 08/28] Added RMW QoS Event Definitions Signed-off-by: Devin Bonnie Signed-off-by: Burek --- rmw/include/rmw/ret_types.h | 1 + rmw/include/rmw/types.h | 83 +++++++++---------------------------- 2 files changed, 21 insertions(+), 63 deletions(-) diff --git a/rmw/include/rmw/ret_types.h b/rmw/include/rmw/ret_types.h index 32179c78..cb373d9f 100644 --- a/rmw/include/rmw/ret_types.h +++ b/rmw/include/rmw/ret_types.h @@ -26,6 +26,7 @@ typedef int32_t rmw_ret_t; #define RMW_RET_OK 0 #define RMW_RET_ERROR 1 #define RMW_RET_TIMEOUT 2 +#define RMW_RET_EVENT_UNSUPPORTED 3 /// Failed to allocate memory return code. #define RMW_RET_BAD_ALLOC 10 diff --git a/rmw/include/rmw/types.h b/rmw/include/rmw/types.h index f398eeb5..fc152a61 100644 --- a/rmw/include/rmw/types.h +++ b/rmw/include/rmw/types.h @@ -302,13 +302,7 @@ typedef enum RMW_PUBLIC_TYPE RMW_LOG_SEVERITY_FATAL = RCUTILS_LOG_SEVERITY_FATAL } rmw_log_severity_t; - -typedef struct RMW_STATUS -{ - rmw_event_type_t rmw_event_type; -} rmw_status_t; - -//Defined in the DDS SSpec 15-04-10 page 116 +//Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status typedef struct RMW_SAMPLE_LOST_STATUS { //Total cumulative count of all samples lost across of instances of data published under the Topic. @@ -318,24 +312,17 @@ typedef struct RMW_SAMPLE_LOST_STATUS } rmw_sample_lost_status_t; -//Defined in the DDS SSpec 15-04-10 page 116 +//Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status typedef struct RMW_SAMPLE_REJECTED_STATUS { //Total cumulative count of samples rejected by the DataReader. int32_t total_count; //The incremental number of samples rejected since the last time the listener was called or the status was read. int32_t total_count_change; - /** - * Reason for rejecting the last sample rejected. If no samples have been rejected, the reason is the special value - * NOT_REJECTED. - */ - void * last_reason; - //Handle to the instance being updated by the last sample that was rejected. - void * last_instance_handle; } rmw_sample_rejected_status_t; -//Defined in the DDS SSpec 15-04-10 page 116 +//Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status typedef struct RMW_LIVELINESS_CHANGED_STATUS { /** @@ -357,12 +344,10 @@ typedef struct RMW_LIVELINESS_CHANGED_STATUS int32_t alive_count_change; //The change in the not_alive_count since the last time the listener was called or the status was read. int32_t not_alive_count_change; - //Handle to the last DataWriter whose change in liveliness caused this status to change. - void * last_publication_handle; } rmw_liveliness_changed_status_t; -//Defined in the DDS SSpec 15-04-10 page 116-117 +//Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status typedef struct RMW_REQUESTED_DEADLINE_MISSED_STATUS { /** @@ -373,12 +358,10 @@ typedef struct RMW_REQUESTED_DEADLINE_MISSED_STATUS int32_t total_count; //The incremental number of deadlines detected since the last time the listener was called or the status was read. int32_t total_count_change; - //Handle to the last instance in the DataReader for which a deadline was detected. - void * last_instance_handle; } rmw_requested_deadline_missed_status_t; -//Defined in the DDS SSpec 15-04-10 page 117 +//Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status typedef struct RMW_REQUESTED_INCOMPATIBLE_QOS_STATUS { /** @@ -388,20 +371,10 @@ typedef struct RMW_REQUESTED_INCOMPATIBLE_QOS_STATUS int32_t total_count; //The change in total_count since the last time the listener was called or the status was read. int32_t total_count_change; - /** - * A list containing for each policy the total number of times that the concerned DataReader discovered a - * DataWriter for the same Topic with an offered QoS that is incompatible with that requested by the DataReader. - */ - void * policies; - /** - * The QosPolicyId_t of one of the policies that was found to be incompatible the last time an incompatibility - * was detected. - */ - void * last_policy_id; } rmw_requested_incompatible_qos_status_t; -//Defined in the DDS SSpec 15-04-10 page 118 +//Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status typedef struct RMW_SUBSCRIPTION_MATCHED_STATUS { /** @@ -415,12 +388,10 @@ typedef struct RMW_SUBSCRIPTION_MATCHED_STATUS int32_t current_count; //The number of DataWriters currently matched to the concerned DataReader. int32_t current_count_change; - //The change in current_count since the last time the listener was called or the status was read. - void * last_publication_handle; } rmw_subscription_matched_status_t; -////Defined in the DDS SSpec 15-04-10 page 117 +////Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status typedef struct RMW_LIVELINESS_LOST { /** @@ -428,66 +399,52 @@ typedef struct RMW_LIVELINESS_LOST * actively signal its liveliness within its offered liveliness period. This count does not change when an * already not alive DataWriter simply remains not alive for another liveliness period. */ - u_int32_t total_count; + int32_t total_count; //The change in total_count since the last time the listener was called or the status was read. - u_int32_t total_count_change; + int32_t total_count_change; } rmw_liveliness_lost_t; -//Defined in the DDS SSpec 15-04-10 page 117 +//Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status typedef struct RMW_OFFERED_DEADLINE_MISSED { /** * Total cumulative number of offered deadline periods elapsed during which a DataWriter failed to provide data. * Missed deadlines accumulate; that is, each deadline period the total_count will be incremented by one. */ - u_int32_t total_count; + int32_t total_count; //The change in total_count since the last time the listener was called or the status was read. - u_int32_t total_count_change; - //Handle to the last instance in the DataWriter for which an offered deadline was missed. - void * last_instance_handle; + int32_t total_count_change; } rmw_offered_deadline_missed_t; -//Defined in the DDS SSpec 15-04-10 page 117-118 +//Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status typedef struct RMW_OFFERED_INCOMPATIBLE_QOS { /** * Total cumulative number of times the concerned DataWriter discovered a DataReader for the same Topic with a * requested QoS that is incompatible with that offered by the DataWriter. */ - u_int32_t total_count; + int32_t total_count; //The change in total_count since the last time the listener was called or the status was read. - u_int32_t total_count_change; - /** - * The PolicyId_t of one of the policies that was found to be incompatible the last time an incompatibility - * was detected. - */ - void * last_policy_id; - /** - * A list containing for each policy the total number of times that the concerned DataWriter discovered a DataReader - * for the same Topic with a requested QoS that is incompatible with that offered by the DataWriter. - */ - void * policies; + int32_t total_count_change; } rmw_offered_incompatible_qos_t; -//Defined in the DDS SSpec 15-04-10 page 118 +//Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status typedef struct RMW_PUBLICATION_MATCHED { /** * Total cumulative count the concerned DataWriter discovered a “match” with a DataReader. That is, it found a * DataReader for the same Topic with a requested QoS that is compatible with that offered by the DataWriter. */ - u_int32_t total_count; + int32_t total_count; //The change in total_count since the last time the listener was called or the status was read. - u_int32_t total_count_change; + int32_t total_count_change; //The number of DataReaders currently matched to the concerned DataWriter. - u_int32_t current_count; + int32_t current_count; //The change in current_count since the last time the listener was called or the status was read. - u_int32_t current_count_change; - //Handle to the last DataReader that matched the DataWriter causing the status to change. - void * last_subscription_handle; + int32_t current_count_change; } rmw_publication_matched_t; From 3fe8f64f3a65b2bdbd196db0db39d1fd50e58e3e Mon Sep 17 00:00:00 2001 From: Devin Bonnie Date: Wed, 20 Mar 2019 16:25:11 +0000 Subject: [PATCH 09/28] Code formatting fixes Signed-off-by: Devin Bonnie Signed-off-by: Burek --- rmw/include/rmw/ret_types.h | 7 ++ rmw/include/rmw/types.h | 140 ++++++++++++++++++------------------ 2 files changed, 78 insertions(+), 69 deletions(-) diff --git a/rmw/include/rmw/ret_types.h b/rmw/include/rmw/ret_types.h index cb373d9f..1dc295ca 100644 --- a/rmw/include/rmw/ret_types.h +++ b/rmw/include/rmw/ret_types.h @@ -26,7 +26,14 @@ typedef int32_t rmw_ret_t; #define RMW_RET_OK 0 #define RMW_RET_ERROR 1 #define RMW_RET_TIMEOUT 2 +/// The event is not supported by the implementation #define RMW_RET_EVENT_UNSUPPORTED 3 +#define RMW_RETCODE_PRECONDITION_NOT_MET 4 +#define RMW_RET_OUT_OF_RESOURCES 5 +#define RMW_RET_NOT_ENABLED 6 +#define RMW_RET_IMMUTABLE_POLICY 7 +#define RMW_RET_INCONSISTENT_POLICY 8 +#define RMW_RET_NO_DATA 9 /// Failed to allocate memory return code. #define RMW_RET_BAD_ALLOC 10 diff --git a/rmw/include/rmw/types.h b/rmw/include/rmw/types.h index fc152a61..4311ae68 100644 --- a/rmw/include/rmw/types.h +++ b/rmw/include/rmw/types.h @@ -302,150 +302,152 @@ typedef enum RMW_PUBLIC_TYPE RMW_LOG_SEVERITY_FATAL = RCUTILS_LOG_SEVERITY_FATAL } rmw_log_severity_t; -//Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status +/// Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status typedef struct RMW_SAMPLE_LOST_STATUS { - //Total cumulative count of all samples lost across of instances of data published under the Topic. - int32_t total_count; - //The incremental number of samples lost since the last time the listener was called or the status was read. - int32_t total_count_change; - + /// Total cumulative count of all samples lost across of instances of data published under the + /// Topic. + int32_t total_count; + /// The incremental number of samples lost since the last time the listener was called or the + /// status was read. + int32_t total_count_change; } rmw_sample_lost_status_t; -//Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status +/// Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status typedef struct RMW_SAMPLE_REJECTED_STATUS { - //Total cumulative count of samples rejected by the DataReader. - int32_t total_count; - //The incremental number of samples rejected since the last time the listener was called or the status was read. - int32_t total_count_change; - + /// Total cumulative count of samples rejected by the DataReader. + int32_t total_count; + /// The incremental number of samples rejected since the last time the listener was called or + /// the status was read. + int32_t total_count_change; } rmw_sample_rejected_status_t; -//Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status +/// Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status typedef struct RMW_LIVELINESS_CHANGED_STATUS { /** - * The total number of currently active DataWriters that write the Topic read by the DataReader. This count - * increases when a newly matched DataWriter asserts its liveliness for the first time or when a DataWriter - * previously considered to be not alive reasserts its liveliness. The count decreases when a DataWriter considered - * alive fails to assert its liveliness and becomes not alive, whether because it was deleted normally or for some - * other reason. + * The total number of currently active DataWriters that write the Topic read by the DataReader. + * This count increases when a newly matched DataWriter asserts its liveliness for the first + * time or when a DataWriter previously considered to be not alive reasserts its liveliness. + * The count decreases when a DataWriter considered alive fails to assert its liveliness and + * becomes not alive, whether because it was deleted normally or for some other reason. */ int32_t alive_count; /** - * The total count of currently DataWriters that write the Topic read by the DataReader that are no longer asserting - * their liveliness. This count increases when a DataWriter considered alive fails to assert its liveliness and - * becomes not alive for some reason other than the normal deletion of that DataWriter. It decreases when a - * previously not alive DataWriter either reasserts its liveliness or is deleted normally. + * The total count of currently DataWriters that write the Topic read by the DataReader that are + * no longer asserting their liveliness. This count increases when a DataWriter considered alive + * fails to assert its liveliness and becomes not alive for some reason other than the normal + * deletion of that DataWriter. It decreases when a previously not alive DataWriter either + * reasserts its liveliness or is deleted normally. */ int32_t not_alive_count; - //The change in the alive_count since the last time the listener was called or the status was read. + /// The change in the alive_count since the last time the listener was called or the status was + /// read. int32_t alive_count_change; - //The change in the not_alive_count since the last time the listener was called or the status was read. + /// The change in the not_alive_count since the last time the listener was called or the status + /// was read. int32_t not_alive_count_change; - } rmw_liveliness_changed_status_t; -//Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status +/// Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status typedef struct RMW_REQUESTED_DEADLINE_MISSED_STATUS { /** - * Total cumulative number of missed deadlines detected for any instance read by the DataReader. Missed deadlines - * accumulate; that is, each deadline period the total_count will be incremented by one for each instance for which + * Total cumulative number of missed deadlines detected for any instance read by the DataReader. + * Missed deadlines accumulate; that is, each deadline period the total_count will be incremented + * by one for each instance for which * data was not received. */ int32_t total_count; - //The incremental number of deadlines detected since the last time the listener was called or the status was read. + /// The incremental number of deadlines detected since the last time the listener was called or + /// the status was read. int32_t total_count_change; - } rmw_requested_deadline_missed_status_t; -//Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status +/// Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status typedef struct RMW_REQUESTED_INCOMPATIBLE_QOS_STATUS { - /** - * Total cumulative number of times the concerned DataReader discovered a DataWriter for the same Topic with an - * offered QoS that was incompatible with that requested by the DataReader. - */ - int32_t total_count; - //The change in total_count since the last time the listener was called or the status was read. - int32_t total_count_change; - + /** + * Total cumulative number of times the concerned DataReader discovered a DataWriter for the + * same Topic with an offered QoS that was incompatible with that requested by the DataReader. + */ + int32_t total_count; + /// The change in total_count since the last time the listener was called or the status was read. + int32_t total_count_change; } rmw_requested_incompatible_qos_status_t; -//Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status +/// Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status typedef struct RMW_SUBSCRIPTION_MATCHED_STATUS { /** - * Total cumulative count the concerned DataReader discovered a “match” with a DataWriter. That is, it found a - * DataWriter for the same Topic with a requested QoS that is compatible with that offered by the DataReader. + * Total cumulative count the concerned DataReader discovered a “match” with a DataWriter. + * That is, it found a DataWriter for the same Topic with a requested QoS that is compatible + * with that offered by the DataReader. */ int32_t total_count; - //The change in total_count since the last time the listener was called or the status was read. + /// The change in total_count since the last time the listener was called or the status was read. int32_t total_count_change; - //Handle to the last DataWriter that matched the DataReader causing the status to change. + /// Handle to the last DataWriter that matched the DataReader causing the status to change. int32_t current_count; - //The number of DataWriters currently matched to the concerned DataReader. + /// The number of DataWriters currently matched to the concerned DataReader. int32_t current_count_change; - } rmw_subscription_matched_status_t; -////Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status +/// Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status typedef struct RMW_LIVELINESS_LOST { /** - * Total cumulative number of times that a previously-alive DataWriter became not alive due to a failure to - * actively signal its liveliness within its offered liveliness period. This count does not change when an - * already not alive DataWriter simply remains not alive for another liveliness period. + * Total cumulative number of times that a previously-alive DataWriter became not alive due to + * a failure to actively signal its liveliness within its offered liveliness period. This count + * does not change when an already not alive DataWriter simply remains not alive for another + * liveliness period. */ int32_t total_count; - //The change in total_count since the last time the listener was called or the status was read. + /// The change in total_count since the last time the listener was called or the status was read. int32_t total_count_change; - } rmw_liveliness_lost_t; -//Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status +/// Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status typedef struct RMW_OFFERED_DEADLINE_MISSED { /** - * Total cumulative number of offered deadline periods elapsed during which a DataWriter failed to provide data. - * Missed deadlines accumulate; that is, each deadline period the total_count will be incremented by one. + * Total cumulative number of offered deadline periods elapsed during which a DataWriter failed + * to provide data. Missed deadlines accumulate; that is, each deadline period the total_count + * will be incremented by one. */ int32_t total_count; - //The change in total_count since the last time the listener was called or the status was read. + // The change in total_count since the last time the listener was called or the status was read. int32_t total_count_change; - } rmw_offered_deadline_missed_t; -//Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status +// Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status typedef struct RMW_OFFERED_INCOMPATIBLE_QOS { /** - * Total cumulative number of times the concerned DataWriter discovered a DataReader for the same Topic with a - * requested QoS that is incompatible with that offered by the DataWriter. + * Total cumulative number of times the concerned DataWriter discovered a DataReader for the + * same Topic with a requested QoS that is incompatible with that offered by the DataWriter. */ int32_t total_count; - //The change in total_count since the last time the listener was called or the status was read. + // The change in total_count since the last time the listener was called or the status was read. int32_t total_count_change; - } rmw_offered_incompatible_qos_t; -//Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status +// Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status typedef struct RMW_PUBLICATION_MATCHED { /** - * Total cumulative count the concerned DataWriter discovered a “match” with a DataReader. That is, it found a - * DataReader for the same Topic with a requested QoS that is compatible with that offered by the DataWriter. + * Total cumulative count the concerned DataWriter discovered a “match” with a DataReader. + * That is, it found a DataReader for the same Topic with a requested QoS that is compatible + * with that offered by the DataWriter. */ int32_t total_count; - //The change in total_count since the last time the listener was called or the status was read. + // The change in total_count since the last time the listener was called or the status was read. int32_t total_count_change; - //The number of DataReaders currently matched to the concerned DataWriter. + // The number of DataReaders currently matched to the concerned DataWriter. int32_t current_count; - //The change in current_count since the last time the listener was called or the status was read. + // The change in current_count since the last time the listener was called or the status was read. int32_t current_count_change; - } rmw_publication_matched_t; #ifdef __cplusplus From 5c7a0114704591f83291065f6d5138007ee7560e Mon Sep 17 00:00:00 2001 From: Emerson Knapp Date: Thu, 21 Mar 2019 15:38:57 -0700 Subject: [PATCH 10/28] Change liveliness policy types to reflect actual settings Signed-off-by: Emerson Knapp Signed-off-by: Devin Bonnie Signed-off-by: Burek --- rmw/include/rmw/qos_profiles.h | 34 ++++++++++++++++++++++------------ rmw/include/rmw/types.h | 29 +++++++++-------------------- 2 files changed, 31 insertions(+), 32 deletions(-) diff --git a/rmw/include/rmw/qos_profiles.h b/rmw/include/rmw/qos_profiles.h index 2be5cd3f..98ab1c5c 100644 --- a/rmw/include/rmw/qos_profiles.h +++ b/rmw/include/rmw/qos_profiles.h @@ -22,15 +22,20 @@ extern "C" #include "rmw/types.h" +#define rmw_qos_deadline_default {0, 0} +#define rmw_qos_lifespan_default {0, 0} +#define rmw_qos_liveliness_lease_duration_default {0, 0} + static const rmw_qos_profile_t rmw_qos_profile_sensor_data = { RMW_QOS_POLICY_HISTORY_KEEP_LAST, 5, RMW_QOS_POLICY_RELIABILITY_BEST_EFFORT, RMW_QOS_POLICY_DURABILITY_VOLATILE, - RMW_QOS_POLICY_DEADLINE_SYSTEM_DEFAULT, + rmw_qos_deadline_default, + rmw_qos_lifespan_default, RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT, - RMW_QOS_POLICY_LIFESPAN_SYSTEM_DEFAULT, + rmw_qos_liveliness_lease_duration_default, false }; @@ -40,9 +45,10 @@ static const rmw_qos_profile_t rmw_qos_profile_parameters = 1000, RMW_QOS_POLICY_RELIABILITY_RELIABLE, RMW_QOS_POLICY_DURABILITY_VOLATILE, - RMW_QOS_POLICY_DEADLINE_SYSTEM_DEFAULT, + rmw_qos_deadline_default, + rmw_qos_lifespan_default, RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT, - RMW_QOS_POLICY_LIFESPAN_SYSTEM_DEFAULT, + rmw_qos_liveliness_lease_duration_default, false }; @@ -52,9 +58,10 @@ static const rmw_qos_profile_t rmw_qos_profile_default = 10, RMW_QOS_POLICY_RELIABILITY_RELIABLE, RMW_QOS_POLICY_DURABILITY_VOLATILE, - RMW_QOS_POLICY_DEADLINE_SYSTEM_DEFAULT, + rmw_qos_deadline_default, + rmw_qos_lifespan_default, RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT, - RMW_QOS_POLICY_LIFESPAN_SYSTEM_DEFAULT, + rmw_qos_liveliness_lease_duration_default, false }; @@ -64,9 +71,10 @@ static const rmw_qos_profile_t rmw_qos_profile_services_default = 10, RMW_QOS_POLICY_RELIABILITY_RELIABLE, RMW_QOS_POLICY_DURABILITY_VOLATILE, - RMW_QOS_POLICY_DEADLINE_SYSTEM_DEFAULT, + rmw_qos_deadline_default, + rmw_qos_lifespan_default, RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT, - RMW_QOS_POLICY_LIFESPAN_SYSTEM_DEFAULT, + rmw_qos_liveliness_lease_duration_default, false }; @@ -76,9 +84,10 @@ static const rmw_qos_profile_t rmw_qos_profile_parameter_events = 1000, RMW_QOS_POLICY_RELIABILITY_RELIABLE, RMW_QOS_POLICY_DURABILITY_VOLATILE, - RMW_QOS_POLICY_DEADLINE_SYSTEM_DEFAULT, + rmw_qos_deadline_default, + rmw_qos_lifespan_default, RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT, - RMW_QOS_POLICY_LIFESPAN_SYSTEM_DEFAULT, + rmw_qos_liveliness_lease_duration_default, false }; @@ -88,9 +97,10 @@ static const rmw_qos_profile_t rmw_qos_profile_system_default = RMW_QOS_POLICY_DEPTH_SYSTEM_DEFAULT, RMW_QOS_POLICY_RELIABILITY_SYSTEM_DEFAULT, RMW_QOS_POLICY_DURABILITY_SYSTEM_DEFAULT, - RMW_QOS_POLICY_DEADLINE_SYSTEM_DEFAULT, + rmw_qos_deadline_default, + rmw_qos_lifespan_default, RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT, - RMW_QOS_POLICY_LIFESPAN_SYSTEM_DEFAULT, + rmw_qos_liveliness_lease_duration_default, false }; diff --git a/rmw/include/rmw/types.h b/rmw/include/rmw/types.h index 4311ae68..e81d9d92 100644 --- a/rmw/include/rmw/types.h +++ b/rmw/include/rmw/types.h @@ -229,25 +229,12 @@ enum RMW_PUBLIC_TYPE rmw_qos_durability_policy_t RMW_QOS_POLICY_DURABILITY_UNKNOWN }; -enum RMW_PUBLIC_TYPE rmw_qos_deadline_policy_t -{ - RMW_QOS_POLICY_DEADLINE_SYSTEM_DEFAULT, - RMW_QOS_POLICY_DEADLINE_TRANSIENT_LOCAL, - RMW_QOS_POLICY_DEADLINE_VOLATILE -}; - -enum RMW_PUBLIC_TYPE rmw_qos_liveliness_policy_t +enum RMW_PUBLIC_TYPE rmw_qos_liveliness_policy_kind_t { RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT, - RMW_QOS_POLICY_LIVELINESS_TRANSIENT_LOCAL, - RMW_QOS_POLICY_LIVELINESS_VOLATILE -}; - -enum RMW_PUBLIC_TYPE rmw_qos_lifespan_policy_t -{ - RMW_QOS_POLICY_LIFESPAN_SYSTEM_DEFAULT, - RMW_QOS_POLICY_LIFESPAN_TRANSIENT_LOCAL, - RMW_QOS_POLICY_LIFESPAN_VOLATILE + RMW_QOS_POLICY_LIVELINESS_AUTOMATIC, + RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_PARTICIPANT, + RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC }; /// ROS MiddleWare quality of service profile. @@ -259,9 +246,11 @@ typedef struct RMW_PUBLIC_TYPE rmw_qos_profile_t enum rmw_qos_reliability_policy_t reliability; enum rmw_qos_durability_policy_t durability; - enum rmw_qos_deadline_policy_t deadline; - enum rmw_qos_liveliness_policy_t liveliness; - enum rmw_qos_lifespan_policy_t lifespan; + struct rmw_time_t deadline; + struct rmw_time_t lifespan; + + enum rmw_qos_liveliness_policy_kind_t liveliness; + struct rmw_time_t liveliness_lease_duration; /// If true, any ROS specific namespacing conventions will be circumvented. /** From 4a732efd140a1c7e92bb164ebc5e8aa751a689e1 Mon Sep 17 00:00:00 2001 From: Emerson Knapp Date: Mon, 25 Mar 2019 19:46:14 -0700 Subject: [PATCH 11/28] Comment out types of liveliness that will not be supported in this iteration of the feature Signed-off-by: Emerson Knapp Signed-off-by: Devin Bonnie Signed-off-by: Burek --- rmw/include/rmw/types.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rmw/include/rmw/types.h b/rmw/include/rmw/types.h index e81d9d92..9dc68d96 100644 --- a/rmw/include/rmw/types.h +++ b/rmw/include/rmw/types.h @@ -233,8 +233,9 @@ enum RMW_PUBLIC_TYPE rmw_qos_liveliness_policy_kind_t { RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT, RMW_QOS_POLICY_LIVELINESS_AUTOMATIC, - RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_PARTICIPANT, - RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC + // TODO(eknapp) - re-enable these once these types of liveliness are supported + // RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_PARTICIPANT, + // RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC }; /// ROS MiddleWare quality of service profile. From 41dac483da259ceb3d1bf9a1c13bdfa53de86b1d Mon Sep 17 00:00:00 2001 From: Emerson Knapp Date: Tue, 26 Mar 2019 12:44:24 -0700 Subject: [PATCH 12/28] Re-enable manual liveliness, name to by_node Signed-off-by: Devin Bonnie Signed-off-by: Burek --- rmw/include/rmw/types.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/rmw/include/rmw/types.h b/rmw/include/rmw/types.h index 9dc68d96..20539bf6 100644 --- a/rmw/include/rmw/types.h +++ b/rmw/include/rmw/types.h @@ -233,9 +233,8 @@ enum RMW_PUBLIC_TYPE rmw_qos_liveliness_policy_kind_t { RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT, RMW_QOS_POLICY_LIVELINESS_AUTOMATIC, - // TODO(eknapp) - re-enable these once these types of liveliness are supported - // RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_PARTICIPANT, - // RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC + RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_NODE, + RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC }; /// ROS MiddleWare quality of service profile. From 25db919aa5cec14ab3a4f08592ee9cd823d67efa Mon Sep 17 00:00:00 2001 From: Devin Bonnie Date: Wed, 27 Mar 2019 12:25:41 -0700 Subject: [PATCH 13/28] Fixed style issues Removed unsupported QoS types Signed-off-by: Devin Bonnie Signed-off-by: Burek --- rmw/include/rmw/qos_profiles.h | 42 ++++++------ rmw/include/rmw/ret_types.h | 10 +-- rmw/include/rmw/rmw.h | 14 ++-- rmw/include/rmw/types.h | 116 +++++++-------------------------- 4 files changed, 49 insertions(+), 133 deletions(-) diff --git a/rmw/include/rmw/qos_profiles.h b/rmw/include/rmw/qos_profiles.h index 98ab1c5c..22c352ee 100644 --- a/rmw/include/rmw/qos_profiles.h +++ b/rmw/include/rmw/qos_profiles.h @@ -22,9 +22,9 @@ extern "C" #include "rmw/types.h" -#define rmw_qos_deadline_default {0, 0} -#define rmw_qos_lifespan_default {0, 0} -#define rmw_qos_liveliness_lease_duration_default {0, 0} +#define RMW_QOS_DEADLINE_DEFAULT {0, 0} +#define RMW_QOS_LIFESPAN_DEFAULT {0, 0} +#define RMW_QOS_LIVELINESS_LEASE_DURATION_DEFAULT {0, 0} static const rmw_qos_profile_t rmw_qos_profile_sensor_data = { @@ -32,10 +32,10 @@ static const rmw_qos_profile_t rmw_qos_profile_sensor_data = 5, RMW_QOS_POLICY_RELIABILITY_BEST_EFFORT, RMW_QOS_POLICY_DURABILITY_VOLATILE, - rmw_qos_deadline_default, - rmw_qos_lifespan_default, + RMW_QOS_DEADLINE_DEFAULT, + RMW_QOS_LIFESPAN_DEFAULT, RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT, - rmw_qos_liveliness_lease_duration_default, + RMW_QOS_LIVELINESS_LEASE_DURATION_DEFAULT, false }; @@ -45,10 +45,10 @@ static const rmw_qos_profile_t rmw_qos_profile_parameters = 1000, RMW_QOS_POLICY_RELIABILITY_RELIABLE, RMW_QOS_POLICY_DURABILITY_VOLATILE, - rmw_qos_deadline_default, - rmw_qos_lifespan_default, + RMW_QOS_DEADLINE_DEFAULT, + RMW_QOS_LIFESPAN_DEFAULT, RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT, - rmw_qos_liveliness_lease_duration_default, + RMW_QOS_LIVELINESS_LEASE_DURATION_DEFAULT, false }; @@ -58,10 +58,10 @@ static const rmw_qos_profile_t rmw_qos_profile_default = 10, RMW_QOS_POLICY_RELIABILITY_RELIABLE, RMW_QOS_POLICY_DURABILITY_VOLATILE, - rmw_qos_deadline_default, - rmw_qos_lifespan_default, + RMW_QOS_DEADLINE_DEFAULT, + RMW_QOS_LIFESPAN_DEFAULT, RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT, - rmw_qos_liveliness_lease_duration_default, + RMW_QOS_LIVELINESS_LEASE_DURATION_DEFAULT, false }; @@ -71,10 +71,10 @@ static const rmw_qos_profile_t rmw_qos_profile_services_default = 10, RMW_QOS_POLICY_RELIABILITY_RELIABLE, RMW_QOS_POLICY_DURABILITY_VOLATILE, - rmw_qos_deadline_default, - rmw_qos_lifespan_default, + RMW_QOS_DEADLINE_DEFAULT, + RMW_QOS_LIFESPAN_DEFAULT, RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT, - rmw_qos_liveliness_lease_duration_default, + RMW_QOS_LIVELINESS_LEASE_DURATION_DEFAULT, false }; @@ -84,10 +84,10 @@ static const rmw_qos_profile_t rmw_qos_profile_parameter_events = 1000, RMW_QOS_POLICY_RELIABILITY_RELIABLE, RMW_QOS_POLICY_DURABILITY_VOLATILE, - rmw_qos_deadline_default, - rmw_qos_lifespan_default, + RMW_QOS_DEADLINE_DEFAULT, + RMW_QOS_LIFESPAN_DEFAULT, RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT, - rmw_qos_liveliness_lease_duration_default, + RMW_QOS_LIVELINESS_LEASE_DURATION_DEFAULT, false }; @@ -97,10 +97,10 @@ static const rmw_qos_profile_t rmw_qos_profile_system_default = RMW_QOS_POLICY_DEPTH_SYSTEM_DEFAULT, RMW_QOS_POLICY_RELIABILITY_SYSTEM_DEFAULT, RMW_QOS_POLICY_DURABILITY_SYSTEM_DEFAULT, - rmw_qos_deadline_default, - rmw_qos_lifespan_default, + RMW_QOS_DEADLINE_DEFAULT, + RMW_QOS_LIFESPAN_DEFAULT, RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT, - rmw_qos_liveliness_lease_duration_default, + RMW_QOS_LIVELINESS_LEASE_DURATION_DEFAULT, false }; diff --git a/rmw/include/rmw/ret_types.h b/rmw/include/rmw/ret_types.h index 1dc295ca..d6925503 100644 --- a/rmw/include/rmw/ret_types.h +++ b/rmw/include/rmw/ret_types.h @@ -26,15 +26,7 @@ typedef int32_t rmw_ret_t; #define RMW_RET_OK 0 #define RMW_RET_ERROR 1 #define RMW_RET_TIMEOUT 2 -/// The event is not supported by the implementation -#define RMW_RET_EVENT_UNSUPPORTED 3 -#define RMW_RETCODE_PRECONDITION_NOT_MET 4 -#define RMW_RET_OUT_OF_RESOURCES 5 -#define RMW_RET_NOT_ENABLED 6 -#define RMW_RET_IMMUTABLE_POLICY 7 -#define RMW_RET_INCONSISTENT_POLICY 8 -#define RMW_RET_NO_DATA 9 - +#define RMW_RET_UNSUPPORTED 3 /// Failed to allocate memory return code. #define RMW_RET_BAD_ALLOC 10 /// Invalid argument return code. diff --git a/rmw/include/rmw/rmw.h b/rmw/include/rmw/rmw.h index db9cc252..aceeee55 100644 --- a/rmw/include/rmw/rmw.h +++ b/rmw/include/rmw/rmw.h @@ -223,6 +223,9 @@ rmw_create_publisher( const char * topic_name, const rmw_qos_profile_t * qos_policies); +/** + * + */ RMW_PUBLIC RMW_WARN_UNUSED rmw_event_t * @@ -356,6 +359,7 @@ rmw_create_subscription( const rmw_qos_profile_t * qos_policies, bool ignore_local_publications); +// todo needs documentation RMW_PUBLIC RMW_WARN_UNUSED rmw_event_t * @@ -472,11 +476,6 @@ rmw_create_client( const char * service_name, const rmw_qos_profile_t * qos_policies); -RMW_PUBLIC -RMW_WARN_UNUSED -rmw_event_t * -rmw_create_client_event(const rmw_client_t * client); - RMW_PUBLIC RMW_WARN_UNUSED rmw_ret_t @@ -508,11 +507,6 @@ rmw_create_service( const char * service_name, const rmw_qos_profile_t * qos_policies); -RMW_PUBLIC -RMW_WARN_UNUSED -rmw_event_t * -rmw_create_service_event(const rmw_service_t * service); - RMW_PUBLIC RMW_WARN_UNUSED rmw_ret_t diff --git a/rmw/include/rmw/types.h b/rmw/include/rmw/types.h index 20539bf6..ef88195a 100644 --- a/rmw/include/rmw/types.h +++ b/rmw/include/rmw/types.h @@ -36,21 +36,15 @@ extern "C" // implementation. It may need to be increased in the future. #define RMW_GID_STORAGE_SIZE 24 - +/// Define QoS policy events typedef enum rmw_event_type_t { - RMW_EVENT_SAMPLE_REJECTED, RMW_EVENT_LIVELINESS_CHANGED, RMW_EVENT_REQUESTED_DEADLINE_MISSED, - RMW_EVENT_REQUESTED_INCOMPATIBLE_QOS, - RMW_EVENT_DATA_AVAILABLE, - RMW_EVENT_SAMPLE_LOST, RMW_EVENT_SUBSCRIPTION_MATCHED, - RMW_EVENT_LIVELINESS_LOST, RMW_EVENT_OFFERED_DEADLINE_MISSED, RMW_EVENT_OFFERED_INCOMPATIBLE_QOS, - RMW_EVENT_PUBLICATION_MATCHED } rmw_event_type_t; @@ -291,29 +285,11 @@ typedef enum RMW_PUBLIC_TYPE RMW_LOG_SEVERITY_FATAL = RCUTILS_LOG_SEVERITY_FATAL } rmw_log_severity_t; -/// Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status -typedef struct RMW_SAMPLE_LOST_STATUS -{ - /// Total cumulative count of all samples lost across of instances of data published under the - /// Topic. - int32_t total_count; - /// The incremental number of samples lost since the last time the listener was called or the - /// status was read. - int32_t total_count_change; -} rmw_sample_lost_status_t; - -/// Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status -typedef struct RMW_SAMPLE_REJECTED_STATUS -{ - /// Total cumulative count of samples rejected by the DataReader. - int32_t total_count; - /// The incremental number of samples rejected since the last time the listener was called or - /// the status was read. - int32_t total_count_change; -} rmw_sample_rejected_status_t; - -/// Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status -typedef struct RMW_LIVELINESS_CHANGED_STATUS +/** + * QoS Liveliness Changed information provided by a subscriber. Defined in the DDS SSpec 15-04-10 + * section 2.2.4.1 Communication Status +*/ +typedef struct RmwLivelinessChangedStatus { /** * The total number of currently active DataWriters that write the Topic read by the DataReader. @@ -339,8 +315,11 @@ typedef struct RMW_LIVELINESS_CHANGED_STATUS int32_t not_alive_count_change; } rmw_liveliness_changed_status_t; -/// Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status -typedef struct RMW_REQUESTED_DEADLINE_MISSED_STATUS +/** + * QoS Requested Deadline Missed information provided by a subscriber. Defined in the DDS SSpec + * 15-04-10 section 2.2.4.1 Communication Status +*/ +typedef struct RmwRequestedDeadlineMissedStatus { /** * Total cumulative number of missed deadlines detected for any instance read by the DataReader. @@ -355,36 +334,12 @@ typedef struct RMW_REQUESTED_DEADLINE_MISSED_STATUS } rmw_requested_deadline_missed_status_t; /// Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status -typedef struct RMW_REQUESTED_INCOMPATIBLE_QOS_STATUS -{ - /** - * Total cumulative number of times the concerned DataReader discovered a DataWriter for the - * same Topic with an offered QoS that was incompatible with that requested by the DataReader. - */ - int32_t total_count; - /// The change in total_count since the last time the listener was called or the status was read. - int32_t total_count_change; -} rmw_requested_incompatible_qos_status_t; -/// Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status -typedef struct RMW_SUBSCRIPTION_MATCHED_STATUS -{ - /** - * Total cumulative count the concerned DataReader discovered a “match” with a DataWriter. - * That is, it found a DataWriter for the same Topic with a requested QoS that is compatible - * with that offered by the DataReader. - */ - int32_t total_count; - /// The change in total_count since the last time the listener was called or the status was read. - int32_t total_count_change; - /// Handle to the last DataWriter that matched the DataReader causing the status to change. - int32_t current_count; - /// The number of DataWriters currently matched to the concerned DataReader. - int32_t current_count_change; -} rmw_subscription_matched_status_t; - -/// Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status -typedef struct RMW_LIVELINESS_LOST +/** + * QoS Liveliness Lost information provided by a publisher. Defined in the DDS SSpec 15-04-10 + * section 2.2.4.1 Communication Status +*/ +typedef struct RmwLivelinessLostStatus { /** * Total cumulative number of times that a previously-alive DataWriter became not alive due to @@ -395,10 +350,13 @@ typedef struct RMW_LIVELINESS_LOST int32_t total_count; /// The change in total_count since the last time the listener was called or the status was read. int32_t total_count_change; -} rmw_liveliness_lost_t; +} rmw_liveliness_lost_status_t; -/// Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status -typedef struct RMW_OFFERED_DEADLINE_MISSED +/** + * QoS Deadline Missed information provided by a publisher. Defined in the DDS SSpec 15-04-10 + * section 2.2.4.1 Communication Status + */ +typedef struct RmwOfferedDeadlineMissedStatus { /** * Total cumulative number of offered deadline periods elapsed during which a DataWriter failed @@ -408,36 +366,8 @@ typedef struct RMW_OFFERED_DEADLINE_MISSED int32_t total_count; // The change in total_count since the last time the listener was called or the status was read. int32_t total_count_change; -} rmw_offered_deadline_missed_t; - -// Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status -typedef struct RMW_OFFERED_INCOMPATIBLE_QOS -{ - /** - * Total cumulative number of times the concerned DataWriter discovered a DataReader for the - * same Topic with a requested QoS that is incompatible with that offered by the DataWriter. - */ - int32_t total_count; - // The change in total_count since the last time the listener was called or the status was read. - int32_t total_count_change; -} rmw_offered_incompatible_qos_t; +} rmw_offered_deadline_missed_status_t; -// Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status -typedef struct RMW_PUBLICATION_MATCHED -{ - /** - * Total cumulative count the concerned DataWriter discovered a “match” with a DataReader. - * That is, it found a DataReader for the same Topic with a requested QoS that is compatible - * with that offered by the DataWriter. - */ - int32_t total_count; - // The change in total_count since the last time the listener was called or the status was read. - int32_t total_count_change; - // The number of DataReaders currently matched to the concerned DataWriter. - int32_t current_count; - // The change in current_count since the last time the listener was called or the status was read. - int32_t current_count_change; -} rmw_publication_matched_t; #ifdef __cplusplus } From d764efab1806dcdd17ee444f70e5a044531d9087 Mon Sep 17 00:00:00 2001 From: Devin Bonnie Date: Wed, 27 Mar 2019 13:59:20 -0700 Subject: [PATCH 14/28] Removed extra QoS types Signed-off-by: Devin Bonnie Signed-off-by: Burek --- rmw/include/rmw/types.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/rmw/include/rmw/types.h b/rmw/include/rmw/types.h index ef88195a..f2920c25 100644 --- a/rmw/include/rmw/types.h +++ b/rmw/include/rmw/types.h @@ -41,10 +41,8 @@ typedef enum rmw_event_type_t { RMW_EVENT_LIVELINESS_CHANGED, RMW_EVENT_REQUESTED_DEADLINE_MISSED, - RMW_EVENT_SUBSCRIPTION_MATCHED, RMW_EVENT_LIVELINESS_LOST, RMW_EVENT_OFFERED_DEADLINE_MISSED, - RMW_EVENT_OFFERED_INCOMPATIBLE_QOS, } rmw_event_type_t; From 5957a92f31974cf66a9f645e0c69dac0648b3834 Mon Sep 17 00:00:00 2001 From: Miaofei Date: Wed, 27 Mar 2019 18:27:39 -0700 Subject: [PATCH 15/28] add an invalid enum in rmw_event_type_t for variables to default to Signed-off-by: Devin Bonnie Signed-off-by: Burek --- rmw/include/rmw/types.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rmw/include/rmw/types.h b/rmw/include/rmw/types.h index f2920c25..02136c84 100644 --- a/rmw/include/rmw/types.h +++ b/rmw/include/rmw/types.h @@ -39,10 +39,16 @@ extern "C" /// Define QoS policy events typedef enum rmw_event_type_t { + // subscription events RMW_EVENT_LIVELINESS_CHANGED, RMW_EVENT_REQUESTED_DEADLINE_MISSED, + + // publisher events RMW_EVENT_LIVELINESS_LOST, RMW_EVENT_OFFERED_DEADLINE_MISSED, + + // sentinel value + RMW_EVENT_INVALID } rmw_event_type_t; From a0966fe6ea594f1984eff1cdb486868b04e76b89 Mon Sep 17 00:00:00 2001 From: Miaofei Date: Thu, 28 Mar 2019 02:55:59 -0700 Subject: [PATCH 16/28] change rmw_event_t APIs from create()/destroy() to init()/fini() pattern Signed-off-by: Devin Bonnie Signed-off-by: Burek --- rmw/CMakeLists.txt | 1 + rmw/include/rmw/allocators.h | 8 --- rmw/include/rmw/event.h | 107 +++++++++++++++++++++++++++++++++++ rmw/include/rmw/rmw.h | 39 ------------- rmw/include/rmw/types.h | 29 +--------- rmw/src/allocators.c | 14 ----- rmw/src/event.c | 35 ++++++++++++ 7 files changed, 146 insertions(+), 87 deletions(-) create mode 100644 rmw/include/rmw/event.h create mode 100644 rmw/src/event.c diff --git a/rmw/CMakeLists.txt b/rmw/CMakeLists.txt index cf643706..501f1c11 100644 --- a/rmw/CMakeLists.txt +++ b/rmw/CMakeLists.txt @@ -30,6 +30,7 @@ set(rmw_sources "src/init.c" "src/init_options.c" "src/names_and_types.c" + "src/event.c" "src/sanity_checks.c" "src/node_security_options.c" "src/validate_full_topic_name.c" diff --git a/rmw/include/rmw/allocators.h b/rmw/include/rmw/allocators.h index f802115d..3eec025d 100644 --- a/rmw/include/rmw/allocators.h +++ b/rmw/include/rmw/allocators.h @@ -79,14 +79,6 @@ RMW_PUBLIC void rmw_service_free(rmw_service_t * service); -RMW_PUBLIC -rmw_event_t * -rmw_event_allocate(void); - -RMW_PUBLIC -void -rmw_event_free(rmw_event_t * event); - RMW_PUBLIC rmw_wait_set_t * rmw_wait_set_allocate(void); diff --git a/rmw/include/rmw/event.h b/rmw/include/rmw/event.h new file mode 100644 index 00000000..0b5df163 --- /dev/null +++ b/rmw/include/rmw/event.h @@ -0,0 +1,107 @@ +// Copyright 2019 Open Source Robotics Foundation, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef RMW__EVENT_H_ +#define RMW__EVENT_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +#include "rcutils/allocator.h" + +#include "rmw/macros.h" +#include "rmw/types.h" +#include "rmw/ret_types.h" +#include "rmw/visibility_control.h" + +/// Define QoS policy events +typedef enum rmw_event_type_t +{ + // subscription events + RMW_EVENT_LIVELINESS_CHANGED, + RMW_EVENT_REQUESTED_DEADLINE_MISSED, + + // publisher events + RMW_EVENT_LIVELINESS_LOST, + RMW_EVENT_OFFERED_DEADLINE_MISSED, + + // sentinel value + RMW_EVENT_INVALID +} rmw_event_type_t; + +typedef struct RMW_PUBLIC_TYPE rmw_event_t +{ + const char * implementation_identifier; + void * data; + rmw_event_type_t event_type; +} rmw_event_t; + + +/// Return a zero initialized event structure. +RMW_PUBLIC +RMW_WARN_UNUSED +rmw_event_t +rmw_get_zero_initialized_event(void); + +// TODO: needs documentation +RMW_PUBLIC +RMW_WARN_UNUSED +rmw_ret_t +rmw_publisher_event_init( + rmw_event_t * event, + const rmw_publisher_t * publisher, + const rmw_event_type_t event_type); + +// TODO: needs documentation +RMW_PUBLIC +RMW_WARN_UNUSED +rmw_ret_t +rmw_subscription_event_init( + rmw_event_t * event, + const rmw_subscription_t * subscription, + const rmw_event_type_t event_type); + +/* + * Take an event from the event handle. + * + * \param event_handle event object to take from + * \param event_info event info object to write taken data into + * \param taken boolean flag indicating if an event was taken or not + * \return `RMW_RET_OK` if successful, or + * \return `RMW_RET_BAD_ALLOC` if memory allocation failed, or + * \return `RMW_RET_ERROR` if an unexpected error occurs. + */ +RMW_PUBLIC +RMW_WARN_UNUSED +rmw_ret_t +rmw_take_event( + const rmw_event_t * event_handle, + void * event_info, + bool * taken); + +// TODO: needs documentation +RMW_PUBLIC +RMW_WARN_UNUSED +rmw_ret_t +rmw_event_fini(rmw_event_t * event); + +#ifdef __cplusplus +} +#endif + +#endif // RMW__EVENT_H_ diff --git a/rmw/include/rmw/rmw.h b/rmw/include/rmw/rmw.h index aceeee55..e6733336 100644 --- a/rmw/include/rmw/rmw.h +++ b/rmw/include/rmw/rmw.h @@ -223,14 +223,6 @@ rmw_create_publisher( const char * topic_name, const rmw_qos_profile_t * qos_policies); -/** - * - */ -RMW_PUBLIC -RMW_WARN_UNUSED -rmw_event_t * -rmw_create_publisher_event(const rmw_publisher_t * publisher, const rmw_event_type_t event_type); - RMW_PUBLIC RMW_WARN_UNUSED rmw_ret_t @@ -359,14 +351,6 @@ rmw_create_subscription( const rmw_qos_profile_t * qos_policies, bool ignore_local_publications); -// todo needs documentation -RMW_PUBLIC -RMW_WARN_UNUSED -rmw_event_t * -rmw_create_subscription_event( - const rmw_subscription_t * subscription, - const rmw_event_type_t event_type); - RMW_PUBLIC RMW_WARN_UNUSED rmw_ret_t @@ -450,23 +434,6 @@ rmw_take_serialized_message_with_info( bool * taken, rmw_message_info_t * message_info); -/* - * Take an event from the event handle. - * - * \param event subscription object to take from - * \param taken boolean flag indicating if an event was taken or not - * \return `RMW_RET_OK` if successful, or - * \return `RMW_RET_BAD_ALLOC` if memory allocation failed, or - * \return `RMW_RET_ERROR` if an unexpected error occurs. - */ -RMW_PUBLIC -RMW_WARN_UNUSED -rmw_ret_t -rmw_take_event( - const rmw_event_t * event_handle, - void * event, - bool * taken); - RMW_PUBLIC RMW_WARN_UNUSED rmw_client_t * @@ -530,12 +497,6 @@ rmw_send_response( void * ros_response); -RMW_PUBLIC -RMW_WARN_UNUSED -rmw_ret_t -rmw_destroy_event(rmw_event_t * event); - - // TODO(wjwwood): refactor this API to return a return code when updated to use an allocator /// Create a guard condition and return a handle to that guard condition. /** diff --git a/rmw/include/rmw/types.h b/rmw/include/rmw/types.h index 02136c84..db3f999f 100644 --- a/rmw/include/rmw/types.h +++ b/rmw/include/rmw/types.h @@ -36,22 +36,6 @@ extern "C" // implementation. It may need to be increased in the future. #define RMW_GID_STORAGE_SIZE 24 -/// Define QoS policy events -typedef enum rmw_event_type_t -{ - // subscription events - RMW_EVENT_LIVELINESS_CHANGED, - RMW_EVENT_REQUESTED_DEADLINE_MISSED, - - // publisher events - RMW_EVENT_LIVELINESS_LOST, - RMW_EVENT_OFFERED_DEADLINE_MISSED, - - // sentinel value - RMW_EVENT_INVALID -} rmw_event_type_t; - - typedef struct RMW_PUBLIC_TYPE rmw_node_t { const char * implementation_identifier; @@ -89,13 +73,6 @@ typedef struct RMW_PUBLIC_TYPE rmw_client_t const char * service_name; } rmw_client_t; -typedef struct RMW_PUBLIC_TYPE rmw_event_t -{ - const char * implementation_identifier; - void * data; - rmw_event_type_t event_type; -} rmw_event_t; - typedef struct RMW_PUBLIC_TYPE rmw_guard_condition_t { const char * implementation_identifier; @@ -154,7 +131,7 @@ typedef struct RMW_PUBLIC_TYPE rmw_events_t /// The number of events represented by the array. size_t event_count; /// Pointer to an array of void * pointers of events. - rmw_event_t ** events; + void ** events; } rmw_events_t; /// Array of guard condition handles. @@ -227,7 +204,7 @@ enum RMW_PUBLIC_TYPE rmw_qos_durability_policy_t RMW_QOS_POLICY_DURABILITY_UNKNOWN }; -enum RMW_PUBLIC_TYPE rmw_qos_liveliness_policy_kind_t +enum RMW_PUBLIC_TYPE rmw_qos_liveliness_policy_t { RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT, RMW_QOS_POLICY_LIVELINESS_AUTOMATIC, @@ -247,7 +224,7 @@ typedef struct RMW_PUBLIC_TYPE rmw_qos_profile_t struct rmw_time_t deadline; struct rmw_time_t lifespan; - enum rmw_qos_liveliness_policy_kind_t liveliness; + enum rmw_qos_liveliness_policy_t liveliness; struct rmw_time_t liveliness_lease_duration; /// If true, any ROS specific namespacing conventions will be circumvented. diff --git a/rmw/src/allocators.c b/rmw/src/allocators.c index ad590717..55ba070f 100644 --- a/rmw/src/allocators.c +++ b/rmw/src/allocators.c @@ -126,20 +126,6 @@ rmw_service_free(rmw_service_t * service) rmw_free(service); } -rmw_event_t * -rmw_event_allocate() -{ - // Could be overridden with custom (maybe static) event struct allocator - return (rmw_event_t *)rmw_allocate(sizeof(rmw_event_t)); -} - -void -rmw_event_free(rmw_event_t * event) -{ - // Should have matching overide with rmw_event_allocate - rmw_free(event); -} - rmw_wait_set_t * rmw_wait_set_allocate() { diff --git a/rmw/src/event.c b/rmw/src/event.c new file mode 100644 index 00000000..d5668339 --- /dev/null +++ b/rmw/src/event.c @@ -0,0 +1,35 @@ +// Copyright 2019 Open Source Robotics Foundation, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +#include "rmw/event.h" + +#ifdef __cplusplus +extern "C" { +#endif + +rmw_event_t +rmw_get_zero_initialized_event(void) +{ + return (const rmw_event_t) { + .implementation_identifier = NULL, + .data = NULL, + .event_type = RMW_EVENT_INVALID + }; // NOLINT(readability/braces): false positive +} + +#ifdef __cplusplus +} +#endif From 4cfb7a7fe7273eb8db56afb43616d65aac287a10 Mon Sep 17 00:00:00 2001 From: Ross Desmond Date: Thu, 28 Mar 2019 15:30:08 -0700 Subject: [PATCH 17/28] Move rmw_*_event_init implementation to rmw **Summary** Event initialization should require no modifications from the underlying rmw layer and therefore can be initialized in the rmw layer. Signed-off-by: Devin Bonnie Signed-off-by: Burek --- rmw/CMakeLists.txt | 2 +- rmw/include/rmw/event.h | 30 +++++++++++++++---- rmw/include/rmw/rmw.h | 4 +++ rmw/src/event.c | 64 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+), 6 deletions(-) diff --git a/rmw/CMakeLists.txt b/rmw/CMakeLists.txt index 501f1c11..265b137f 100644 --- a/rmw/CMakeLists.txt +++ b/rmw/CMakeLists.txt @@ -27,10 +27,10 @@ include_directories(include) set(rmw_sources "src/allocators.c" "src/convert_rcutils_ret_to_rmw_ret.c" + "src/event.c" "src/init.c" "src/init_options.c" "src/names_and_types.c" - "src/event.c" "src/sanity_checks.c" "src/node_security_options.c" "src/validate_full_topic_name.c" diff --git a/rmw/include/rmw/event.h b/rmw/include/rmw/event.h index 0b5df163..29a9c089 100644 --- a/rmw/include/rmw/event.h +++ b/rmw/include/rmw/event.h @@ -58,21 +58,37 @@ RMW_WARN_UNUSED rmw_event_t rmw_get_zero_initialized_event(void); -// TODO: needs documentation +/** + * Initialize a rmw publisher event. + * + * \param rmw_event [in|out] to initialize + * \param publisher to initialize with + * \param event_type for the event to handle + * \return `RMW_RET_OK` if successful, or + * \return `RMW_RET_INVALID_ARGUMENT` if invalid argument + */ RMW_PUBLIC RMW_WARN_UNUSED rmw_ret_t rmw_publisher_event_init( - rmw_event_t * event, + rmw_event_t * rmw_event, const rmw_publisher_t * publisher, const rmw_event_type_t event_type); -// TODO: needs documentation +/** + * Initialize a rmw subscription event. + * + * \param rmw_event [in|out] to initialize + * \param subscription to initialize with + * \param event_type for the event to handle + * \return `RMW_RET_OK` if successful, or + * \return `RMW_RET_INVALID_ARGUMENT` if invalid argument + */ RMW_PUBLIC RMW_WARN_UNUSED rmw_ret_t rmw_subscription_event_init( - rmw_event_t * event, + rmw_event_t * rmw_event, const rmw_subscription_t * subscription, const rmw_event_type_t event_type); @@ -94,7 +110,11 @@ rmw_take_event( void * event_info, bool * taken); -// TODO: needs documentation +/** + * Finalize an rmw_event_t. + * + * \param event to delete + */ RMW_PUBLIC RMW_WARN_UNUSED rmw_ret_t diff --git a/rmw/include/rmw/rmw.h b/rmw/include/rmw/rmw.h index e6733336..964499b3 100644 --- a/rmw/include/rmw/rmw.h +++ b/rmw/include/rmw/rmw.h @@ -496,6 +496,10 @@ rmw_send_response( rmw_request_id_t * request_header, void * ros_response); +RMW_PUBLIC +RMW_WARN_UNUSED +rmw_ret_t +rmw_destroy_event(rmw_event_t * event); // TODO(wjwwood): refactor this API to return a return code when updated to use an allocator /// Create a guard condition and return a handle to that guard condition. diff --git a/rmw/src/event.c b/rmw/src/event.c index d5668339..0bb219cd 100644 --- a/rmw/src/event.c +++ b/rmw/src/event.c @@ -14,6 +14,7 @@ #include +#include "rmw/error_handling.h" #include "rmw/event.h" #ifdef __cplusplus @@ -30,6 +31,69 @@ rmw_get_zero_initialized_event(void) }; // NOLINT(readability/braces): false positive } +/** + * Initialize an rmw_event with the appropriate data. + * + * \param rmw_event [in|out] to initialize + * \param implementation_identifier to rmw_event + * \param data to pass to rmw_event + * \param event_type for the event to handle + * \return `RMW_RET_OK` if successful, or + * \return `RMW_RET_INVALID_ARGUMENT` if invalid argument + */ +rmw_ret_t +__rmw_init_event( + rmw_event_t * rmw_event, + const char * implementation_identifier, + void * data, + const rmw_event_type_t event_type) + +{ + RMW_CHECK_ARGUMENT_FOR_NULL(implementation_identifier, RMW_RET_INVALID_ARGUMENT); + RMW_CHECK_ARGUMENT_FOR_NULL(data, RMW_RET_INVALID_ARGUMENT); + RMW_CHECK_ARGUMENT_FOR_NULL(rmw_event, RMW_RET_INVALID_ARGUMENT); + if (NULL != rmw_event->implementation_identifier) { + RMW_SET_ERROR_MSG("expected zero-initialized rmw_event"); + return RMW_RET_INVALID_ARGUMENT; + } + rmw_event->implementation_identifier = implementation_identifier; + rmw_event->data = data; + rmw_event->event_type = event_type; + return RMW_RET_OK; +} + +rmw_ret_t +rmw_publisher_event_init( + rmw_event_t * rmw_event, + const rmw_publisher_t * publisher, + const rmw_event_type_t event_type) +{ + return __rmw_init_event(rmw_event, + publisher->implementation_identifier, + publisher->data, + event_type); +} + +rmw_ret_t +rmw_subscription_event_init( + rmw_event_t * rmw_event, + const rmw_subscription_t * subscription, + const rmw_event_type_t event_type) +{ + return __rmw_init_event(rmw_event, + subscription->implementation_identifier, + subscription->data, + event_type); +} + +rmw_ret_t +rmw_event_fini(rmw_event_t * rmw_event) +{ + RMW_CHECK_ARGUMENT_FOR_NULL(rmw_event, RMW_RET_INVALID_ARGUMENT); + *rmw_event = rmw_get_zero_initialized_event(); + return RMW_RET_OK; +} + #ifdef __cplusplus } #endif From f43f029bffca00a02df8428410e9366d9f3e9f19 Mon Sep 17 00:00:00 2001 From: Ross Desmond Date: Fri, 29 Mar 2019 01:50:39 +0000 Subject: [PATCH 18/28] Fix uncrustify divergence in event.c Signed-off-by: Devin Bonnie Signed-off-by: Burek --- rmw/src/event.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/rmw/src/event.c b/rmw/src/event.c index 0bb219cd..f82c0bfa 100644 --- a/rmw/src/event.c +++ b/rmw/src/event.c @@ -25,15 +25,15 @@ rmw_event_t rmw_get_zero_initialized_event(void) { return (const rmw_event_t) { - .implementation_identifier = NULL, - .data = NULL, - .event_type = RMW_EVENT_INVALID + .implementation_identifier = NULL, + .data = NULL, + .event_type = RMW_EVENT_INVALID }; // NOLINT(readability/braces): false positive } /** * Initialize an rmw_event with the appropriate data. - * + * * \param rmw_event [in|out] to initialize * \param implementation_identifier to rmw_event * \param data to pass to rmw_event @@ -47,7 +47,6 @@ __rmw_init_event( const char * implementation_identifier, void * data, const rmw_event_type_t event_type) - { RMW_CHECK_ARGUMENT_FOR_NULL(implementation_identifier, RMW_RET_INVALID_ARGUMENT); RMW_CHECK_ARGUMENT_FOR_NULL(data, RMW_RET_INVALID_ARGUMENT); @@ -69,9 +68,9 @@ rmw_publisher_event_init( const rmw_event_type_t event_type) { return __rmw_init_event(rmw_event, - publisher->implementation_identifier, - publisher->data, - event_type); + publisher->implementation_identifier, + publisher->data, + event_type); } rmw_ret_t @@ -80,10 +79,10 @@ rmw_subscription_event_init( const rmw_subscription_t * subscription, const rmw_event_type_t event_type) { - return __rmw_init_event(rmw_event, - subscription->implementation_identifier, - subscription->data, - event_type); + return __rmw_init_event(rmw_event, + subscription->implementation_identifier, + subscription->data, + event_type); } rmw_ret_t From 89872269a847f67bb076c67fe544608115e118ce Mon Sep 17 00:00:00 2001 From: Ross Desmond Date: Thu, 28 Mar 2019 18:57:54 -0700 Subject: [PATCH 19/28] Remove erroneous rmw_delete_event Signed-off-by: Devin Bonnie Signed-off-by: Burek --- rmw/include/rmw/rmw.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/rmw/include/rmw/rmw.h b/rmw/include/rmw/rmw.h index 964499b3..fe5b7c5b 100644 --- a/rmw/include/rmw/rmw.h +++ b/rmw/include/rmw/rmw.h @@ -496,11 +496,6 @@ rmw_send_response( rmw_request_id_t * request_header, void * ros_response); -RMW_PUBLIC -RMW_WARN_UNUSED -rmw_ret_t -rmw_destroy_event(rmw_event_t * event); - // TODO(wjwwood): refactor this API to return a return code when updated to use an allocator /// Create a guard condition and return a handle to that guard condition. /** From 502f1b70972ce0ed1840e8b0cc43f13f8a55144b Mon Sep 17 00:00:00 2001 From: Devin Bonnie Date: Fri, 29 Mar 2019 11:58:57 -0700 Subject: [PATCH 20/28] Added missing documentation Signed-off-by: Devin Bonnie Signed-off-by: Burek --- rmw/include/rmw/event.h | 5 +++++ rmw/include/rmw/ret_types.h | 1 + 2 files changed, 6 insertions(+) diff --git a/rmw/include/rmw/event.h b/rmw/include/rmw/event.h index 29a9c089..84c84ec0 100644 --- a/rmw/include/rmw/event.h +++ b/rmw/include/rmw/event.h @@ -44,10 +44,15 @@ typedef enum rmw_event_type_t RMW_EVENT_INVALID } rmw_event_type_t; + +/// Encapsulate the RMW event implementation, data, and type. typedef struct RMW_PUBLIC_TYPE rmw_event_t { + /// Implementation identifier, used to ensure two different implementations are not being mixed. const char * implementation_identifier; + /// Data specific to this event type from either the publisher or subscriber. void * data; + /// The event type that occurred. rmw_event_type_t event_type; } rmw_event_t; diff --git a/rmw/include/rmw/ret_types.h b/rmw/include/rmw/ret_types.h index d6925503..7994da02 100644 --- a/rmw/include/rmw/ret_types.h +++ b/rmw/include/rmw/ret_types.h @@ -26,6 +26,7 @@ typedef int32_t rmw_ret_t; #define RMW_RET_OK 0 #define RMW_RET_ERROR 1 #define RMW_RET_TIMEOUT 2 +/// The operation or event handling is not supported. #define RMW_RET_UNSUPPORTED 3 /// Failed to allocate memory return code. #define RMW_RET_BAD_ALLOC 10 From 77bd82a9e7fd3b1a605d8235f1ac893925f08f1b Mon Sep 17 00:00:00 2001 From: Ross Desmond <44277324+ross-desmond@users.noreply.github.com> Date: Fri, 29 Mar 2019 10:27:04 -0700 Subject: [PATCH 21/28] Implement QoS: liveliness, deadline, lifespan **Summary** Provide init/fini and take functions for events. Modify wait_set to include event handles for notification of status changes. Details: * ADD initial qos interface changes * ADD rmw take_event interface * ADD rmw event type enum * MODIFY events type from void** to rmw_event_t** * ADD RMW QoS Event Definitions * ADD section about DCO to CONTRIBUTING.md * EDIT liveliness policy types to reflect actual settings * ADD an invalid enum in rmw_event_type_t for variables to default to * MOVE rmw_*_event_init implementation to rmw ** Event initialization should require no modifications from the underlying rmw layer and therefore can be initialized in the rmw layer. Signed-off-by: Ross Desmond <44277324+ross-desmond@users.noreply.github.com> Signed-off-by: Devin Bonnie Signed-off-by: Burek --- rmw/include/rmw/event.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/rmw/include/rmw/event.h b/rmw/include/rmw/event.h index 84c84ec0..17e4b44b 100644 --- a/rmw/include/rmw/event.h +++ b/rmw/include/rmw/event.h @@ -44,7 +44,6 @@ typedef enum rmw_event_type_t RMW_EVENT_INVALID } rmw_event_type_t; - /// Encapsulate the RMW event implementation, data, and type. typedef struct RMW_PUBLIC_TYPE rmw_event_t { @@ -56,7 +55,6 @@ typedef struct RMW_PUBLIC_TYPE rmw_event_t rmw_event_type_t event_type; } rmw_event_t; - /// Return a zero initialized event structure. RMW_PUBLIC RMW_WARN_UNUSED From 87c25fe509ef4fc457a64f0d3f8958c8b049858e Mon Sep 17 00:00:00 2001 From: Devin Bonnie Date: Mon, 1 Apr 2019 15:46:05 -0700 Subject: [PATCH 22/28] Edited added struct names for consistency Edited method signatures to follow const correctness Addressed style / linting review comments Updated documentation style Signed-off-by: Devin Bonnie Signed-off-by: Burek --- rmw/include/rmw/event.h | 24 ++++++++----------- rmw/include/rmw/ret_types.h | 1 + rmw/include/rmw/types.h | 47 ++++++++++++++++--------------------- rmw/src/event.c | 41 ++++++++++++++------------------ 4 files changed, 48 insertions(+), 65 deletions(-) diff --git a/rmw/include/rmw/event.h b/rmw/include/rmw/event.h index 17e4b44b..84accc0d 100644 --- a/rmw/include/rmw/event.h +++ b/rmw/include/rmw/event.h @@ -61,10 +61,9 @@ RMW_WARN_UNUSED rmw_event_t rmw_get_zero_initialized_event(void); +/// Initialize a rmw publisher event. /** - * Initialize a rmw publisher event. - * - * \param rmw_event [in|out] to initialize + * \param[in|out] rmw_event to initialize * \param publisher to initialize with * \param event_type for the event to handle * \return `RMW_RET_OK` if successful, or @@ -76,12 +75,11 @@ rmw_ret_t rmw_publisher_event_init( rmw_event_t * rmw_event, const rmw_publisher_t * publisher, - const rmw_event_type_t event_type); + rmw_event_type_t event_type); +/// Initialize a rmw subscription event. /** - * Initialize a rmw subscription event. - * - * \param rmw_event [in|out] to initialize + * \param[in|out] rmw_event to initialize * \param subscription to initialize with * \param event_type for the event to handle * \return `RMW_RET_OK` if successful, or @@ -93,11 +91,10 @@ rmw_ret_t rmw_subscription_event_init( rmw_event_t * rmw_event, const rmw_subscription_t * subscription, - const rmw_event_type_t event_type); + rmw_event_type_t event_type); -/* - * Take an event from the event handle. - * +/// Take an event from the event handle. +/** * \param event_handle event object to take from * \param event_info event info object to write taken data into * \param taken boolean flag indicating if an event was taken or not @@ -113,10 +110,9 @@ rmw_take_event( void * event_info, bool * taken); +/// Finalize an rmw_event_t. /** - * Finalize an rmw_event_t. - * - * \param event to delete + * \param event to finalize */ RMW_PUBLIC RMW_WARN_UNUSED diff --git a/rmw/include/rmw/ret_types.h b/rmw/include/rmw/ret_types.h index 7994da02..26b8708b 100644 --- a/rmw/include/rmw/ret_types.h +++ b/rmw/include/rmw/ret_types.h @@ -26,6 +26,7 @@ typedef int32_t rmw_ret_t; #define RMW_RET_OK 0 #define RMW_RET_ERROR 1 #define RMW_RET_TIMEOUT 2 + /// The operation or event handling is not supported. #define RMW_RET_UNSUPPORTED 3 /// Failed to allocate memory return code. diff --git a/rmw/include/rmw/types.h b/rmw/include/rmw/types.h index db3f999f..8bbb51b0 100644 --- a/rmw/include/rmw/types.h +++ b/rmw/include/rmw/types.h @@ -125,7 +125,6 @@ typedef struct RMW_PUBLIC_TYPE rmw_clients_t void ** clients; } rmw_clients_t; - typedef struct RMW_PUBLIC_TYPE rmw_events_t { /// The number of events represented by the array. @@ -267,21 +266,20 @@ typedef enum RMW_PUBLIC_TYPE } rmw_log_severity_t; /** - * QoS Liveliness Changed information provided by a subscriber. Defined in the DDS SSpec 15-04-10 - * section 2.2.4.1 Communication Status -*/ -typedef struct RmwLivelinessChangedStatus + * QoS Liveliness Changed information provided by a subscriber. + */ +typedef struct RMW_PUBLIC_TYPE rmw_liveliness_changed_status_t { /** - * The total number of currently active DataWriters that write the Topic read by the DataReader. - * This count increases when a newly matched DataWriter asserts its liveliness for the first - * time or when a DataWriter previously considered to be not alive reasserts its liveliness. - * The count decreases when a DataWriter considered alive fails to assert its liveliness and + * The total number of currently active Publishers that write the Topic read by the Subscriber. + * This count increases when a newly matched Publishers asserts its liveliness for the first + * time or when a Publishers previously considered to be not alive reasserts its liveliness. + * The count decreases when a Publisher considered alive fails to assert its liveliness and * becomes not alive, whether because it was deleted normally or for some other reason. */ int32_t alive_count; /** - * The total count of currently DataWriters that write the Topic read by the DataReader that are + * The total count of currently Publishers that write the Topic read by the Subscriber that are * no longer asserting their liveliness. This count increases when a DataWriter considered alive * fails to assert its liveliness and becomes not alive for some reason other than the normal * deletion of that DataWriter. It decreases when a previously not alive DataWriter either @@ -297,13 +295,12 @@ typedef struct RmwLivelinessChangedStatus } rmw_liveliness_changed_status_t; /** - * QoS Requested Deadline Missed information provided by a subscriber. Defined in the DDS SSpec - * 15-04-10 section 2.2.4.1 Communication Status -*/ -typedef struct RmwRequestedDeadlineMissedStatus + * QoS Requested Deadline Missed information provided by a subscriber. + */ +typedef struct RMW_PUBLIC_TYPE rmw_requested_deadline_missed_status_t { /** - * Total cumulative number of missed deadlines detected for any instance read by the DataReader. + * Total cumulative number of missed deadlines detected for any instance read by the Subscriber. * Missed deadlines accumulate; that is, each deadline period the total_count will be incremented * by one for each instance for which * data was not received. @@ -314,18 +311,15 @@ typedef struct RmwRequestedDeadlineMissedStatus int32_t total_count_change; } rmw_requested_deadline_missed_status_t; -/// Defined in the DDS SSpec 15-04-10 section 2.2.4.1 Communication Status - /** - * QoS Liveliness Lost information provided by a publisher. Defined in the DDS SSpec 15-04-10 - * section 2.2.4.1 Communication Status -*/ -typedef struct RmwLivelinessLostStatus + * QoS Liveliness Lost information provided by a publisher. + */ +typedef struct RMW_PUBLIC_TYPE rmw_liveliness_lost_status_t { /** - * Total cumulative number of times that a previously-alive DataWriter became not alive due to + * Total cumulative number of times that a previously-alive Publisher became not alive due to * a failure to actively signal its liveliness within its offered liveliness period. This count - * does not change when an already not alive DataWriter simply remains not alive for another + * does not change when an already not alive Publisher simply remains not alive for another * liveliness period. */ int32_t total_count; @@ -334,13 +328,12 @@ typedef struct RmwLivelinessLostStatus } rmw_liveliness_lost_status_t; /** - * QoS Deadline Missed information provided by a publisher. Defined in the DDS SSpec 15-04-10 - * section 2.2.4.1 Communication Status + * QoS Deadline Missed information provided by a publisher. */ -typedef struct RmwOfferedDeadlineMissedStatus +typedef struct RMW_PUBLIC_TYPE rmw_offered_deadline_missed_status_t { /** - * Total cumulative number of offered deadline periods elapsed during which a DataWriter failed + * Total cumulative number of offered deadline periods elapsed during which a Publisher failed * to provide data. Missed deadlines accumulate; that is, each deadline period the total_count * will be incremented by one. */ diff --git a/rmw/src/event.c b/rmw/src/event.c index f82c0bfa..c4b3dc0a 100644 --- a/rmw/src/event.c +++ b/rmw/src/event.c @@ -24,23 +24,14 @@ extern "C" { rmw_event_t rmw_get_zero_initialized_event(void) { - return (const rmw_event_t) { - .implementation_identifier = NULL, - .data = NULL, - .event_type = RMW_EVENT_INVALID + const rmw_event_t event = { + .implementation_identifier = NULL, + .data = NULL, + .event_type = RMW_EVENT_INVALID }; // NOLINT(readability/braces): false positive + return event; } -/** - * Initialize an rmw_event with the appropriate data. - * - * \param rmw_event [in|out] to initialize - * \param implementation_identifier to rmw_event - * \param data to pass to rmw_event - * \param event_type for the event to handle - * \return `RMW_RET_OK` if successful, or - * \return `RMW_RET_INVALID_ARGUMENT` if invalid argument - */ rmw_ret_t __rmw_init_event( rmw_event_t * rmw_event, @@ -65,24 +56,26 @@ rmw_ret_t rmw_publisher_event_init( rmw_event_t * rmw_event, const rmw_publisher_t * publisher, - const rmw_event_type_t event_type) + rmw_event_type_t event_type) { - return __rmw_init_event(rmw_event, - publisher->implementation_identifier, - publisher->data, - event_type); + return __rmw_init_event( + rmw_event, + publisher->implementation_identifier, + publisher->data, + event_type); } rmw_ret_t rmw_subscription_event_init( rmw_event_t * rmw_event, const rmw_subscription_t * subscription, - const rmw_event_type_t event_type) + rmw_event_type_t event_type) { - return __rmw_init_event(rmw_event, - subscription->implementation_identifier, - subscription->data, - event_type); + return __rmw_init_event( + rmw_event, + subscription->implementation_identifier, + subscription->data, + event_type); } rmw_ret_t From c6cb6ea8e1ae9ec07ef320a84639b9c92fcefefc Mon Sep 17 00:00:00 2001 From: Miaofei Date: Mon, 1 Apr 2019 20:24:46 -0700 Subject: [PATCH 23/28] add assert_liveliness() APIs Signed-off-by: Devin Bonnie Signed-off-by: Burek --- rmw/include/rmw/rmw.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/rmw/include/rmw/rmw.h b/rmw/include/rmw/rmw.h index fe5b7c5b..649a45c9 100644 --- a/rmw/include/rmw/rmw.h +++ b/rmw/include/rmw/rmw.h @@ -182,6 +182,11 @@ RMW_WARN_UNUSED rmw_ret_t rmw_destroy_node(rmw_node_t * node); +RMW_PUBLIC +RMW_WARN_UNUSED +rmw_ret_t +rmw_node_assert_liveliness(const rmw_node_t * node); + /// Return a guard condition which is triggered when the ROS graph changes. /** * The handle returned is a pointer to an internally held rmw guard condition. @@ -296,6 +301,11 @@ rmw_ret_t rmw_publish_serialized_message( const rmw_publisher_t * publisher, const rmw_serialized_message_t * serialized_message); +RMW_PUBLIC +RMW_WARN_UNUSED +rmw_ret_t +rmw_publisher_assert_liveliness(const rmw_publisher_t * publisher); + /// Serialize a ROS message into a rmw_serialized_message_t. /** * The ROS message is serialized into a byte stream contained within the From abf625c7ac9254af31a79f5cdba0e95db28f78b8 Mon Sep 17 00:00:00 2001 From: Miaofei Date: Tue, 2 Apr 2019 10:58:10 -0700 Subject: [PATCH 24/28] address comments in PR (github.com/aws-robotics/rmw/pull/4) Signed-off-by: Devin Bonnie Signed-off-by: Burek --- rmw/include/rmw/rmw.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/rmw/include/rmw/rmw.h b/rmw/include/rmw/rmw.h index 649a45c9..7752d1ea 100644 --- a/rmw/include/rmw/rmw.h +++ b/rmw/include/rmw/rmw.h @@ -182,6 +182,26 @@ RMW_WARN_UNUSED rmw_ret_t rmw_destroy_node(rmw_node_t * node); +/// Manually assert that this node is alive (for RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_NODE) +/** + * If the rmw Liveliness policy is set to RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_NODE, the creator of + * this node must manually call `assert_liveliness` on a regular basis to signal to the rest of the + * system that this Node is still alive. + * This function must be called at least as often as the qos_profile's liveliness_lease_duration + * + *
+ * Attribute | Adherence + * ------------------ | ------------- + * Allocates Memory | No + * Thread-Safe | Yes + * Uses Atomics | No + * Lock-Free | Yes + * + * \param[in] node handle to the node that needs liveliness to be asserted + * \return `RMW_RET_OK` if the liveliness assertion was completed successfully, or + * \return `RMW_RET_ERROR` if an unspecified error occurs, or + * \return `RMW_RET_UNSUPPORTED` if the rmw implementation does not support asserting liveliness. + */ RMW_PUBLIC RMW_WARN_UNUSED rmw_ret_t @@ -301,6 +321,26 @@ rmw_ret_t rmw_publish_serialized_message( const rmw_publisher_t * publisher, const rmw_serialized_message_t * serialized_message); +/// Manually assert that this Publisher is alive (for RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC) +/** + * If the rmw Liveliness policy is set to RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC, the creator of + * this publisher must manually call `assert_liveliness` on a regular basis to signal to the rest + * of the system that this Node is still alive. + * This function must be called at least as often as the qos_profile's liveliness_lease_duration + * + *
+ * Attribute | Adherence + * ------------------ | ------------- + * Allocates Memory | No + * Thread-Safe | Yes + * Uses Atomics | No + * Lock-Free | Yes + * + * \param[in] publisher handle to the publisher that needs liveliness to be asserted + * \return `RMW_RET_OK` if the liveliness assertion was completed successfully, or + * \return `RMW_RET_ERROR` if an unspecified error occurs, or + * \return `RMW_RET_UNSUPPORTED` if the rmw implementation does not support asserting liveliness. + */ RMW_PUBLIC RMW_WARN_UNUSED rmw_ret_t From c227f0b9f4fc25842efe700ad1217bae8923db70 Mon Sep 17 00:00:00 2001 From: Devin Bonnie Date: Tue, 2 Apr 2019 11:17:59 -0700 Subject: [PATCH 25/28] Edited documentation to account for unexpected errors Signed-off-by: Devin Bonnie Signed-off-by: Burek --- rmw/include/rmw/event.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rmw/include/rmw/event.h b/rmw/include/rmw/event.h index 84accc0d..e24cd5df 100644 --- a/rmw/include/rmw/event.h +++ b/rmw/include/rmw/event.h @@ -68,6 +68,7 @@ rmw_get_zero_initialized_event(void); * \param event_type for the event to handle * \return `RMW_RET_OK` if successful, or * \return `RMW_RET_INVALID_ARGUMENT` if invalid argument + * \return `RMW_RET_ERROR` if an unexpected error occurs. */ RMW_PUBLIC RMW_WARN_UNUSED @@ -84,6 +85,7 @@ rmw_publisher_event_init( * \param event_type for the event to handle * \return `RMW_RET_OK` if successful, or * \return `RMW_RET_INVALID_ARGUMENT` if invalid argument + * \return `RMW_RET_ERROR` if an unexpected error occurs. */ RMW_PUBLIC RMW_WARN_UNUSED From a3475f17e2a489fbb14c362435596c08b0a7848e Mon Sep 17 00:00:00 2001 From: Miaofei Date: Tue, 2 Apr 2019 11:41:20 -0700 Subject: [PATCH 26/28] modify doc string regarding the requirement of asserting liveliness Signed-off-by: Devin Bonnie Signed-off-by: Burek --- rmw/include/rmw/rmw.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/rmw/include/rmw/rmw.h b/rmw/include/rmw/rmw.h index 7752d1ea..a2d4e0c4 100644 --- a/rmw/include/rmw/rmw.h +++ b/rmw/include/rmw/rmw.h @@ -185,9 +185,8 @@ rmw_destroy_node(rmw_node_t * node); /// Manually assert that this node is alive (for RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_NODE) /** * If the rmw Liveliness policy is set to RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_NODE, the creator of - * this node must manually call `assert_liveliness` on a regular basis to signal to the rest of the - * system that this Node is still alive. - * This function must be called at least as often as the qos_profile's liveliness_lease_duration + * this node may manually call `assert_liveliness` at some point in time to signal to the rest + * of the system that this Node is still alive. * *
* Attribute | Adherence @@ -324,9 +323,8 @@ rmw_publish_serialized_message( /// Manually assert that this Publisher is alive (for RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC) /** * If the rmw Liveliness policy is set to RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC, the creator of - * this publisher must manually call `assert_liveliness` on a regular basis to signal to the rest + * this publisher may manually call `assert_liveliness` at some point in time to signal to the rest * of the system that this Node is still alive. - * This function must be called at least as often as the qos_profile's liveliness_lease_duration * *
* Attribute | Adherence From 182bf2d8f39c62ddd2cb07d1468fedb9b12f1bc2 Mon Sep 17 00:00:00 2001 From: Devin Bonnie Date: Tue, 2 Apr 2019 14:45:06 -0700 Subject: [PATCH 27/28] Edit documentation block to fix linting errors Signed-off-by: Devin Bonnie Signed-off-by: Burek --- rmw/include/rmw/rmw.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rmw/include/rmw/rmw.h b/rmw/include/rmw/rmw.h index a2d4e0c4..dcd85877 100644 --- a/rmw/include/rmw/rmw.h +++ b/rmw/include/rmw/rmw.h @@ -184,7 +184,7 @@ rmw_destroy_node(rmw_node_t * node); /// Manually assert that this node is alive (for RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_NODE) /** - * If the rmw Liveliness policy is set to RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_NODE, the creator of + * If the rmw Liveliness policy is set to RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_NODE, the creator of * this node may manually call `assert_liveliness` at some point in time to signal to the rest * of the system that this Node is still alive. * From 57f926e9f437476d6d2d0d900ebc944d9708377b Mon Sep 17 00:00:00 2001 From: Devin Bonnie Date: Tue, 9 Apr 2019 19:17:53 -0700 Subject: [PATCH 28/28] Addressed documentation issues found in review Signed-off-by: Devin Bonnie --- rmw/include/rmw/ret_types.h | 2 +- rmw/include/rmw/types.h | 47 +++++++++++++++++-------------------- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/rmw/include/rmw/ret_types.h b/rmw/include/rmw/ret_types.h index 26b8708b..5b23a216 100644 --- a/rmw/include/rmw/ret_types.h +++ b/rmw/include/rmw/ret_types.h @@ -26,9 +26,9 @@ typedef int32_t rmw_ret_t; #define RMW_RET_OK 0 #define RMW_RET_ERROR 1 #define RMW_RET_TIMEOUT 2 - /// The operation or event handling is not supported. #define RMW_RET_UNSUPPORTED 3 + /// Failed to allocate memory return code. #define RMW_RET_BAD_ALLOC 10 /// Invalid argument return code. diff --git a/rmw/include/rmw/types.h b/rmw/include/rmw/types.h index 8bbb51b0..eec2c9c0 100644 --- a/rmw/include/rmw/types.h +++ b/rmw/include/rmw/types.h @@ -266,48 +266,45 @@ typedef enum RMW_PUBLIC_TYPE } rmw_log_severity_t; /** - * QoS Liveliness Changed information provided by a subscriber. + * QoS Liveliness Changed information provided by a subscription. */ typedef struct RMW_PUBLIC_TYPE rmw_liveliness_changed_status_t { /** - * The total number of currently active Publishers that write the Topic read by the Subscriber. - * This count increases when a newly matched Publishers asserts its liveliness for the first - * time or when a Publishers previously considered to be not alive reasserts its liveliness. - * The count decreases when a Publisher considered alive fails to assert its liveliness and - * becomes not alive, whether because it was deleted normally or for some other reason. + * The total number of currently active Publishers which publish to the topic associated with + * the Subscription. This count increases when a newly matched Publisher asserts its liveliness + * for the first time or when a Publisher previously considered to be not alive reasserts its + * liveliness. The count decreases when a Publisher considered alive fails to assert its + * liveliness and becomes not alive, whether because it was deleted normally or for some + * other reason. */ int32_t alive_count; /** - * The total count of currently Publishers that write the Topic read by the Subscriber that are - * no longer asserting their liveliness. This count increases when a DataWriter considered alive - * fails to assert its liveliness and becomes not alive for some reason other than the normal - * deletion of that DataWriter. It decreases when a previously not alive DataWriter either - * reasserts its liveliness or is deleted normally. + * The total count of current Publishers which publish to the topic associated with the + * Subscription that are no longer asserting their liveliness. This count increases when a + * Publisher considered alive fails to assert its liveliness and becomes not alive for some + * reason other than the normal deletion of that Publisher. It decreases when a previously not + * alive Publisher either reasserts its liveliness or is deleted normally. */ int32_t not_alive_count; - /// The change in the alive_count since the last time the listener was called or the status was - /// read. + /// The change in the alive_count since the status was read. int32_t alive_count_change; - /// The change in the not_alive_count since the last time the listener was called or the status - /// was read. + /// The change in the not_alive_count since the status was read. int32_t not_alive_count_change; } rmw_liveliness_changed_status_t; /** - * QoS Requested Deadline Missed information provided by a subscriber. + * QoS Requested Deadline Missed information provided by a subscription. */ typedef struct RMW_PUBLIC_TYPE rmw_requested_deadline_missed_status_t { /** - * Total cumulative number of missed deadlines detected for any instance read by the Subscriber. + * Lifetime cumulative number of missed deadlines detected for any instance read by the subscription. * Missed deadlines accumulate; that is, each deadline period the total_count will be incremented - * by one for each instance for which - * data was not received. + * by one for each instance for which data was not received. */ int32_t total_count; - /// The incremental number of deadlines detected since the last time the listener was called or - /// the status was read. + /// The incremental number of deadlines detected since the status was read. int32_t total_count_change; } rmw_requested_deadline_missed_status_t; @@ -317,13 +314,13 @@ typedef struct RMW_PUBLIC_TYPE rmw_requested_deadline_missed_status_t typedef struct RMW_PUBLIC_TYPE rmw_liveliness_lost_status_t { /** - * Total cumulative number of times that a previously-alive Publisher became not alive due to + * Lifetime cumulative number of times that a previously-alive Publisher became not alive due to * a failure to actively signal its liveliness within its offered liveliness period. This count * does not change when an already not alive Publisher simply remains not alive for another * liveliness period. */ int32_t total_count; - /// The change in total_count since the last time the listener was called or the status was read. + /// The change in total_count since the last time the status was read. int32_t total_count_change; } rmw_liveliness_lost_status_t; @@ -333,12 +330,12 @@ typedef struct RMW_PUBLIC_TYPE rmw_liveliness_lost_status_t typedef struct RMW_PUBLIC_TYPE rmw_offered_deadline_missed_status_t { /** - * Total cumulative number of offered deadline periods elapsed during which a Publisher failed + * Lifetime cumulative number of offered deadline periods elapsed during which a Publisher failed * to provide data. Missed deadlines accumulate; that is, each deadline period the total_count * will be incremented by one. */ int32_t total_count; - // The change in total_count since the last time the listener was called or the status was read. + /// The change in total_count since the last time the status was read. int32_t total_count_change; } rmw_offered_deadline_missed_status_t;