From 83a1e906e7969d811d30274bcd08ccccf2172a7a Mon Sep 17 00:00:00 2001 From: Miaofei Date: Fri, 12 Apr 2019 11:46:11 -0700 Subject: [PATCH] correct initialization of rmw_qos_profile_t struct instances Signed-off-by: Miaofei --- rcl/test/rcl/test_get_actual_qos.cpp | 60 ++++++++++++--------- rcl_action/include/rcl_action/default_qos.h | 4 ++ 2 files changed, 38 insertions(+), 26 deletions(-) diff --git a/rcl/test/rcl/test_get_actual_qos.cpp b/rcl/test/rcl/test_get_actual_qos.cpp index e15659dd31..d931529611 100644 --- a/rcl/test/rcl/test_get_actual_qos.cpp +++ b/rcl/test/rcl/test_get_actual_qos.cpp @@ -145,6 +145,35 @@ TEST_P_RMW(TestGetActualQoS, test_publisher_get_qos_settings) { rcl_reset_error(); } +static constexpr rmw_qos_profile_t non_default_qos_profile() +{ + rmw_qos_profile_t profile = rmw_qos_profile_default; + profile.history = RMW_QOS_POLICY_HISTORY_KEEP_ALL; + profile.depth = 1000; + profile.reliability = RMW_QOS_POLICY_RELIABILITY_BEST_EFFORT; + profile.durability = RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL; + profile.liveliness = RMW_QOS_POLICY_LIVELINESS_AUTOMATIC; + profile.avoid_ros_namespace_conventions = true; + return profile; +} + +static constexpr rmw_qos_profile_t expected_fastrtps_default_qos_profile() +{ + rmw_qos_profile_t profile = rmw_qos_profile_default; + profile.depth = 1; + profile.durability = RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL; + profile.liveliness = RMW_QOS_POLICY_LIVELINESS_AUTOMATIC; + return profile; +} + +static constexpr rmw_qos_profile_t expected_system_default_qos_profile() +{ + rmw_qos_profile_t profile = rmw_qos_profile_default; + profile.depth = 1; + profile.liveliness = RMW_QOS_POLICY_LIVELINESS_AUTOMATIC; + return profile; +} + std::vector get_parameters() { @@ -162,20 +191,8 @@ get_parameters() Test with non-default settings. */ { - { - RMW_QOS_POLICY_HISTORY_KEEP_ALL, - 1000, - RMW_QOS_POLICY_RELIABILITY_BEST_EFFORT, - RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL, - true - }, - { - RMW_QOS_POLICY_HISTORY_KEEP_ALL, - 1000, - RMW_QOS_POLICY_RELIABILITY_BEST_EFFORT, - RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL, - true - }, + non_default_qos_profile(), + non_default_qos_profile(), "publisher_non_default_qos" } }); @@ -185,12 +202,7 @@ get_parameters() if (!rmw_implementation_str.compare("rmw_fastrtps_cpp") || !rmw_implementation_str.compare("rmw_fastrtps_dynamic_cpp")) { - rmw_qos_profile_t expected_system_default_qos = { - RMW_QOS_POLICY_HISTORY_KEEP_LAST, - 1, - RMW_QOS_POLICY_RELIABILITY_RELIABLE, - RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL, - false}; + rmw_qos_profile_t expected_system_default_qos = expected_fastrtps_default_qos_profile(); parameters.push_back({ rmw_qos_profile_system_default, expected_system_default_qos, @@ -200,12 +212,7 @@ get_parameters() !rmw_implementation_str.compare("rmw_connext_cpp") || !rmw_implementation_str.compare("rmw_connext_dynamic_cpp")) { - rmw_qos_profile_t expected_system_default_qos = { - RMW_QOS_POLICY_HISTORY_KEEP_LAST, - 1, - RMW_QOS_POLICY_RELIABILITY_RELIABLE, - RMW_QOS_POLICY_DURABILITY_VOLATILE, - false}; + rmw_qos_profile_t expected_system_default_qos = expected_system_default_qos_profile(); parameters.push_back({ rmw_qos_profile_system_default, expected_system_default_qos, @@ -213,6 +220,7 @@ get_parameters() } } #endif + return parameters; } diff --git a/rcl_action/include/rcl_action/default_qos.h b/rcl_action/include/rcl_action/default_qos.h index 5504f388ba..c1952b708e 100644 --- a/rcl_action/include/rcl_action/default_qos.h +++ b/rcl_action/include/rcl_action/default_qos.h @@ -29,6 +29,10 @@ static const rmw_qos_profile_t rcl_action_qos_profile_status_default = 1, RMW_QOS_POLICY_RELIABILITY_RELIABLE, RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL, + RMW_QOS_DEADLINE_DEFAULT, + RMW_QOS_LIFESPAN_DEFAULT, + RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT, + RMW_QOS_LIVELINESS_LEASE_DURATION_DEFAULT, false };