Skip to content

Commit

Permalink
rclc_executor: improve enum type names (#379) (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] committed Jun 27, 2023
1 parent 60fffda commit 24ab126
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
29 changes: 20 additions & 9 deletions rclc/include/rclc/executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions rclc/src/rclc/executor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion rclc/test/rclc/test_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 24ab126

Please sign in to comment.