Skip to content

Commit

Permalink
correct initialization of rmw_qos_profile_t struct instances (#416)
Browse files Browse the repository at this point in the history
Signed-off-by: Miaofei <miaofei@amazon.com>
  • Loading branch information
mm318 authored and wjwwood committed Apr 16, 2019
1 parent d94c958 commit edaa18a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 26 deletions.
60 changes: 34 additions & 26 deletions rcl/test/rcl/test_get_actual_qos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<TestParameters>
get_parameters()
{
Expand All @@ -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"
}
});
Expand All @@ -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,
Expand All @@ -200,19 +212,15 @@ 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,
"publisher_system_default_qos"});
}
}
#endif

return parameters;
}

Expand Down
4 changes: 4 additions & 0 deletions rcl_action/include/rcl_action/default_qos.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down

0 comments on commit edaa18a

Please sign in to comment.