From 24ab126bb489984c2b66a72d2ce56e221dd707d1 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 27 Jun 2023 15:35:43 +0200 Subject: [PATCH] rclc_executor: improve enum type names (#379) (#382) --- rclc/include/rclc/executor.h | 29 ++++++++++++++++++++--------- rclc/src/rclc/executor.c | 6 +++--- rclc/test/rclc/test_executor.cpp | 2 +- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/rclc/include/rclc/executor.h b/rclc/include/rclc/executor.h index 39cb94e5..74f96910 100644 --- a/rclc/include/rclc/executor.h +++ b/rclc/include/rclc/executor.h @@ -40,22 +40,33 @@ extern "C" processed in a user-defined order. */ -/* defines the semantics of data communication - RCLCPP_EXECUTOR - same semantics as in the rclcpp Executor ROS2(Eloquent) - LET - logical execution time +/** Defines the semantics when data is taken from DDS + * SEMANTICS_RCLCPP_EXECUTOR - same semantics as in rclcpp Executor. Data of a subscription + * is taken from DDS just before the corresponding callback + * is called by the Executor. + * SEMANTICS_LOGICAL_EXECUTION_TIME - logical execution time semantics. At one sampling point t + * new data of all ready subscriptions are taken from DDS. + * During (sequential) processing of these callbacks the + * data is used as per sampling point t. If new data arrived + * between the sampling point t and the time point at which + * the callback is called, it would not be considered in this + * `rclc_executor_spin_some` iteration. */ typedef enum { - RCLCPP_EXECUTOR, - LET + RCLC_SEMANTICS_RCLCPP_EXECUTOR, + RCLC_SEMANTICS_LOGICAL_EXECUTION_TIME } rclc_executor_semantics_t; +/** + * Different types of Executors. +*/ typedef enum { - NONE, - SINGLE_THREADED, - MULTI_THREADED, - NON_POSIX, + RCLC_EXECUTOR_NOT_INITIALIZED, + RCLC_EXECUTOR_SINGLE_THREADED, + RCLC_EXECUTOR_MULTI_THREADED, + RCLC_EXECUTOR_NON_POSIX, } rclc_executor_type_t; /// Type definition for trigger function. With the parameters: diff --git a/rclc/src/rclc/executor.c b/rclc/src/rclc/executor.c index b91aa783..79ddcd31 100644 --- a/rclc/src/rclc/executor.c +++ b/rclc/src/rclc/executor.c @@ -141,7 +141,7 @@ rclc_executor_init( rclc_executor_set_trigger(executor, rclc_executor_trigger_any, NULL); // default semantics - rclc_executor_set_semantics(executor, RCLCPP_EXECUTOR); + rclc_executor_set_semantics(executor, RCLC_SEMANTICS_RCLCPP_EXECUTOR); return ret; } @@ -1956,10 +1956,10 @@ rclc_executor_spin_some(rclc_executor_t * executor, const uint64_t timeout_ns) // based on semantics process input data switch (executor->data_comm_semantics) { - case LET: + case RCLC_SEMANTICS_LOGICAL_EXECUTION_TIME: rc = _rclc_let_scheduling(executor); break; - case RCLCPP_EXECUTOR: + case RCLC_SEMANTICS_RCLCPP_EXECUTOR: rc = _rclc_default_scheduling(executor); break; default: diff --git a/rclc/test/rclc/test_executor.cpp b/rclc/test/rclc/test_executor.cpp index 86346f49..41201fc2 100644 --- a/rclc/test/rclc/test_executor.cpp +++ b/rclc/test/rclc/test_executor.cpp @@ -1903,7 +1903,7 @@ TEST_F(TestDefaultExecutor, semantics_RCLCPP) { _pub_int_ptr = &this->pub1; _pub_int_msg_ptr = &this->pub1_msg; // ------------------------- test case setup ------------------------ - rclc_executor_set_semantics(&executor, RCLCPP_EXECUTOR); + rclc_executor_set_semantics(&executor, RCLC_SEMANTICS_RCLCPP_EXECUTOR); this->pub1_msg.data = 1; _cb5_int_value = 0; // received value in subscription2 rc = rcl_publish(&this->pub1, &this->pub1_msg, nullptr);