Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rclc_executor: improve enum type names #379

Merged
merged 6 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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