Skip to content

Commit

Permalink
Add client/service QoS getters (#196)
Browse files Browse the repository at this point in the history
Signed-off-by: Mauro Passerino <mpasserino@irobot.com>
  • Loading branch information
mauropasse authored Nov 19, 2021
1 parent e9cf665 commit 679b120
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 0 deletions.
28 changes: 28 additions & 0 deletions rmw_implementation/src/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,16 @@ RMW_INTERFACE_FN(
rmw_ret_t, RMW_RET_ERROR,
4, ARG_TYPES(const rmw_client_t *, rmw_service_info_t *, void *, bool *))

RMW_INTERFACE_FN(
rmw_client_request_publisher_get_actual_qos,
rmw_ret_t, RMW_RET_ERROR,
2, ARG_TYPES(const rmw_client_t *, rmw_qos_profile_t *))

RMW_INTERFACE_FN(
rmw_client_response_subscription_get_actual_qos,
rmw_ret_t, RMW_RET_ERROR,
2, ARG_TYPES(const rmw_client_t *, rmw_qos_profile_t *))

RMW_INTERFACE_FN(
rmw_create_service,
rmw_service_t *, nullptr,
Expand All @@ -511,6 +521,16 @@ RMW_INTERFACE_FN(
rmw_ret_t, RMW_RET_ERROR,
3, ARG_TYPES(const rmw_service_t *, rmw_request_id_t *, void *))

RMW_INTERFACE_FN(
rmw_service_response_publisher_get_actual_qos,
rmw_ret_t, RMW_RET_ERROR,
2, ARG_TYPES(const rmw_service_t *, rmw_qos_profile_t *))

RMW_INTERFACE_FN(
rmw_service_request_subscription_get_actual_qos,
rmw_ret_t, RMW_RET_ERROR,
2, ARG_TYPES(const rmw_service_t *, rmw_qos_profile_t *))

RMW_INTERFACE_FN(
rmw_take_event,
rmw_ret_t, RMW_RET_ERROR,
Expand Down Expand Up @@ -752,13 +772,17 @@ void prefetch_symbols(void)
GET_SYMBOL(rmw_count_subscribers)
GET_SYMBOL(rmw_get_gid_for_publisher)
GET_SYMBOL(rmw_compare_gids_equal)
GET_SYMBOL(rmw_service_response_publisher_get_actual_qos);
GET_SYMBOL(rmw_service_request_subscription_get_actual_qos);
GET_SYMBOL(rmw_service_server_is_available)
GET_SYMBOL(rmw_set_log_severity)
GET_SYMBOL(rmw_get_publishers_info_by_topic)
GET_SYMBOL(rmw_get_subscriptions_info_by_topic)
GET_SYMBOL(rmw_qos_profile_check_compatible)
GET_SYMBOL(rmw_publisher_get_network_flow_endpoints)
GET_SYMBOL(rmw_subscription_get_network_flow_endpoints)
GET_SYMBOL(rmw_client_request_publisher_get_actual_qos);
GET_SYMBOL(rmw_client_response_subscription_get_actual_qos);
}

void * symbol_rmw_init = nullptr;
Expand Down Expand Up @@ -830,10 +854,14 @@ unload_library()
symbol_rmw_return_loaned_message_from_subscription = nullptr;
symbol_rmw_create_client = nullptr;
symbol_rmw_destroy_client = nullptr;
symbol_rmw_client_request_publisher_get_actual_qos = nullptr;
symbol_rmw_client_response_subscription_get_actual_qos = nullptr;
symbol_rmw_send_request = nullptr;
symbol_rmw_take_response = nullptr;
symbol_rmw_create_service = nullptr;
symbol_rmw_destroy_service = nullptr;
symbol_rmw_service_response_publisher_get_actual_qos = nullptr;
symbol_rmw_service_request_subscription_get_actual_qos = nullptr;
symbol_rmw_take_request = nullptr;
symbol_rmw_send_response = nullptr;
symbol_rmw_take_event = nullptr;
Expand Down
49 changes: 49 additions & 0 deletions test_rmw_implementation/test/test_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,3 +408,52 @@ TEST_F(CLASSNAME(TestClientUse, RMW_IMPLEMENTATION), service_server_is_available
}
ASSERT_TRUE(is_available);
}

TEST_F(CLASSNAME(TestClient, RMW_IMPLEMENTATION), check_qos) {
constexpr char service_name[] = "/test";
const rosidl_service_type_support_t * ts =
ROSIDL_GET_SRV_TYPE_SUPPORT(test_msgs, srv, BasicTypes);

rmw_qos_profile_t qos_profile = rmw_qos_profile_services_default;
qos_profile.liveliness = RMW_QOS_POLICY_LIVELINESS_AUTOMATIC;
uint64_t duration = 1;
qos_profile.deadline = {duration, duration};
qos_profile.lifespan = {duration, duration};
qos_profile.liveliness_lease_duration = {duration, duration};

rmw_client_t * client =
rmw_create_client(node, ts, service_name, &qos_profile);

rmw_qos_profile_t actual_rp_qos;
rmw_ret_t ret = rmw_client_request_publisher_get_actual_qos(
client,
&actual_rp_qos);
EXPECT_EQ(RMW_RET_OK, ret) << rmw_get_error_string().str;
EXPECT_EQ(actual_rp_qos.reliability, qos_profile.reliability);
EXPECT_EQ(actual_rp_qos.durability, qos_profile.durability);
EXPECT_EQ(actual_rp_qos.liveliness, qos_profile.liveliness);
EXPECT_EQ(actual_rp_qos.history, qos_profile.history);
EXPECT_EQ(actual_rp_qos.depth, qos_profile.depth);
EXPECT_EQ(actual_rp_qos.deadline.sec, qos_profile.deadline.sec);
EXPECT_EQ(actual_rp_qos.deadline.nsec, qos_profile.deadline.nsec);
EXPECT_EQ(actual_rp_qos.lifespan.sec, qos_profile.lifespan.sec);
EXPECT_EQ(actual_rp_qos.lifespan.nsec, qos_profile.lifespan.nsec);
EXPECT_EQ(actual_rp_qos.liveliness_lease_duration.sec, qos_profile.liveliness_lease_duration.sec);
EXPECT_EQ(actual_rp_qos.liveliness_lease_duration.nsec, qos_profile.liveliness_lease_duration.nsec);

rmw_qos_profile_t actual_rs_qos;
ret = rmw_client_response_subscription_get_actual_qos(
client,
&actual_rs_qos);

EXPECT_EQ(RMW_RET_OK, ret) << rmw_get_error_string().str;
EXPECT_EQ(actual_rs_qos.reliability, qos_profile.reliability);
EXPECT_EQ(actual_rs_qos.durability, qos_profile.durability);
EXPECT_EQ(actual_rs_qos.liveliness, qos_profile.liveliness);
EXPECT_EQ(actual_rs_qos.history, qos_profile.history);
EXPECT_EQ(actual_rs_qos.depth, qos_profile.depth);
EXPECT_EQ(actual_rs_qos.deadline.sec, qos_profile.deadline.sec);
EXPECT_EQ(actual_rs_qos.deadline.nsec, qos_profile.deadline.nsec);
EXPECT_EQ(actual_rs_qos.liveliness_lease_duration.sec, qos_profile.liveliness_lease_duration.sec);
EXPECT_EQ(actual_rs_qos.liveliness_lease_duration.nsec, qos_profile.liveliness_lease_duration.nsec);
}
50 changes: 50 additions & 0 deletions test_rmw_implementation/test/test_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,3 +515,53 @@ TEST_F(CLASSNAME(TestService, RMW_IMPLEMENTATION), send_reponse_with_client_gone
ret = rmw_send_response(srv, &header.request_id, &service_response);
EXPECT_EQ(RMW_RET_OK, ret);
}

TEST_F(CLASSNAME(TestService, RMW_IMPLEMENTATION), check_qos) {
constexpr char service_name[] = "/test";
const rosidl_service_type_support_t * ts =
ROSIDL_GET_SRV_TYPE_SUPPORT(test_msgs, srv, BasicTypes);

rmw_qos_profile_t qos_profile = rmw_qos_profile_services_default;
qos_profile.liveliness = RMW_QOS_POLICY_LIVELINESS_AUTOMATIC;
uint64_t duration = 1;
qos_profile.deadline = {duration, duration};
qos_profile.lifespan = {duration, duration};
qos_profile.liveliness_lease_duration = {duration, duration};

rmw_service_t * srv =
rmw_create_service(node, ts, service_name, &qos_profile);

rmw_qos_profile_t actual_rp_qos;
rmw_ret_t ret = rmw_service_response_publisher_get_actual_qos(
srv,
&actual_rp_qos);

EXPECT_EQ(RMW_RET_OK, ret) << rmw_get_error_string().str;
EXPECT_EQ(actual_rp_qos.reliability, qos_profile.reliability);
EXPECT_EQ(actual_rp_qos.durability, qos_profile.durability);
EXPECT_EQ(actual_rp_qos.liveliness, qos_profile.liveliness);
EXPECT_EQ(actual_rp_qos.history, qos_profile.history);
EXPECT_EQ(actual_rp_qos.depth, qos_profile.depth);
EXPECT_EQ(actual_rp_qos.deadline.sec, qos_profile.deadline.sec);
EXPECT_EQ(actual_rp_qos.lifespan.sec, qos_profile.lifespan.sec);
EXPECT_EQ(actual_rp_qos.liveliness_lease_duration.sec, qos_profile.liveliness_lease_duration.sec);
EXPECT_EQ(actual_rp_qos.deadline.nsec, qos_profile.deadline.nsec);
EXPECT_EQ(actual_rp_qos.lifespan.nsec, qos_profile.lifespan.nsec);
EXPECT_EQ(actual_rp_qos.liveliness_lease_duration.nsec, qos_profile.liveliness_lease_duration.nsec);

rmw_qos_profile_t actual_rs_qos;
ret = rmw_service_request_subscription_get_actual_qos(
srv,
&actual_rs_qos);

EXPECT_EQ(RMW_RET_OK, ret) << rmw_get_error_string().str;
EXPECT_EQ(actual_rs_qos.reliability, qos_profile.reliability);
EXPECT_EQ(actual_rs_qos.durability, qos_profile.durability);
EXPECT_EQ(actual_rs_qos.liveliness, qos_profile.liveliness);
EXPECT_EQ(actual_rs_qos.history, qos_profile.history);
EXPECT_EQ(actual_rs_qos.depth, qos_profile.depth);
EXPECT_EQ(actual_rs_qos.deadline.sec, qos_profile.deadline.sec);
EXPECT_EQ(actual_rs_qos.deadline.nsec, qos_profile.deadline.nsec);
EXPECT_EQ(actual_rs_qos.liveliness_lease_duration.sec, qos_profile.liveliness_lease_duration.sec);
EXPECT_EQ(actual_rs_qos.liveliness_lease_duration.nsec, qos_profile.liveliness_lease_duration.nsec);
}

0 comments on commit 679b120

Please sign in to comment.