Skip to content

Commit

Permalink
Deprecate rmw_time_t
Browse files Browse the repository at this point in the history
Signed-off-by: Emerson Knapp <[email protected]>
  • Loading branch information
Emerson Knapp committed Feb 11, 2021
1 parent 4d4e831 commit 8b67c3f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 41 deletions.
4 changes: 2 additions & 2 deletions rmw/include/rmw/rmw.h
Original file line number Diff line number Diff line change
Expand Up @@ -2414,7 +2414,7 @@ rmw_destroy_wait_set(rmw_wait_set_t * wait_set);
* \param[inout] events Array of events to wait on.
* Can be `NULL` if there are no events to wait on.
* \param[in] wait_set Wait set to use for waiting.
* \param[in] wait_timeout If `NULL`, block indefinitely until an entity becomes ready.
* \param[in] wait_timeout If negative, block indefinitely until an entity becomes ready.
* If zero, do not block -- check only for immediately available entities.
* Else, this represents the maximum amount of time to wait for an entity to become ready.
* \return `RMW_RET_OK` if successful, or
Expand All @@ -2435,7 +2435,7 @@ rmw_wait(
rmw_clients_t * clients,
rmw_events_t * events,
rmw_wait_set_t * wait_set,
const rmw_time_t * wait_timeout);
rmw_duration_t wait_timeout);

/// Return the name and namespace of all nodes in the ROS graph.
/**
Expand Down
19 changes: 12 additions & 7 deletions rmw/include/rmw/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,12 @@ typedef struct RMW_PUBLIC_TYPE rmw_time_t

/// Nanoseconds component of this time point
uint64_t nsec;
} rmw_time_t;
} rmw_time_t RCUTILS_DEPRECATED_WITH_MSG (
"rmw_time_t has been deprecated in G-Turtle in favor of rmw_duration_t and rmw_time_point_t. "
"It will be removed in H-Turtle");

/// A duration of time, measured in nanoseconds.
typedef rcutils_duration_value_t rmw_duration_t;

typedef rcutils_time_point_value_t rmw_time_point_value_t;

Expand Down Expand Up @@ -425,13 +430,13 @@ enum RMW_PUBLIC_TYPE rmw_qos_liveliness_policy_t
};

/// QoS Deadline default, 0s indicates deadline policies are not tracked or enforced
#define RMW_QOS_DEADLINE_DEFAULT {0, 0}
static const rmw_duration_t RMW_QOS_DEADLINE_DEFAULT = 0;

/// QoS Lifespan default, 0s indicate lifespan policies are not tracked or enforced
#define RMW_QOS_LIFESPAN_DEFAULT {0, 0}
static const rmw_duration_t RMW_QOS_LIFESPAN_DEFAULT = 0;

/// QoS Liveliness lease duration default, 0s indicate lease durations are not tracked or enforced
#define RMW_QOS_LIVELINESS_LEASE_DURATION_DEFAULT {0, 0}
static const rmw_duration_t RMW_QOS_LIVELINESS_LEASE_DURATION_DEFAULT = 0;

/// ROS MiddleWare quality of service profile.
typedef struct RMW_PUBLIC_TYPE rmw_qos_profile_t
Expand All @@ -444,13 +449,13 @@ typedef struct RMW_PUBLIC_TYPE rmw_qos_profile_t
/// Durability QoS policy setting
enum rmw_qos_durability_policy_t durability;
/// The period at which messages are expected to be sent/received
struct rmw_time_t deadline;
rmw_duration_t deadline;
/// The age at which messages are considered expired and no longer valid
struct rmw_time_t lifespan;
rmw_duration_t lifespan;
/// Liveliness QoS policy setting
enum rmw_qos_liveliness_policy_t liveliness;
/// The time within which the RMW node or publisher must show that it is alive
struct rmw_time_t liveliness_lease_duration;
rmw_duration_t liveliness_lease_duration;

/// If true, any ROS specific namespacing conventions will be circumvented.
/**
Expand Down
50 changes: 18 additions & 32 deletions rmw/test/test_topic_endpoint_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ TEST(test_topic_endpoint_info, set_qos_profile) {
qos_profile.depth = 0;
qos_profile.reliability = RMW_QOS_POLICY_RELIABILITY_RELIABLE;
qos_profile.durability = RMW_QOS_POLICY_DURABILITY_VOLATILE;
qos_profile.deadline = {1, 0};
qos_profile.lifespan = {2, 0};
qos_profile.deadline = RCUTILS_S_TO_NS(1);
qos_profile.lifespan = RCUTILS_S_TO_NS(2);
qos_profile.liveliness = RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC;
qos_profile.liveliness_lease_duration = {3, 0};
qos_profile.liveliness_lease_duration = RCUTILS_S_TO_NS(3);
qos_profile.avoid_ros_namespace_conventions = false;

rmw_ret_t ret = rmw_topic_endpoint_info_set_qos_profile(nullptr, &qos_profile);
Expand All @@ -173,19 +173,14 @@ TEST(test_topic_endpoint_info, set_qos_profile) {
EXPECT_EQ(
topic_endpoint_info.qos_profile.durability,
RMW_QOS_POLICY_DURABILITY_VOLATILE) << "Unequal durability";
EXPECT_EQ(topic_endpoint_info.qos_profile.deadline.sec, 1u) << "Unequal deadline sec";
EXPECT_EQ(topic_endpoint_info.qos_profile.deadline.nsec, 0u) << "Unequal deadline nsec";
EXPECT_EQ(topic_endpoint_info.qos_profile.lifespan.sec, 2u) << "Unequal lifespan sec";
EXPECT_EQ(topic_endpoint_info.qos_profile.lifespan.nsec, 0u) << "Unequal lifespan nsec";
EXPECT_EQ(topic_endpoint_info.qos_profile.deadline, RCUTILS_S_TO_NS(1)) << "Unequal deadline";
EXPECT_EQ(topic_endpoint_info.qos_profile.lifespan, RCUTILS_S_TO_NS(2u)) << "Unequal lifespan";
EXPECT_EQ(
topic_endpoint_info.qos_profile.liveliness,
RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC) << "Unequal liveliness";
EXPECT_EQ(
topic_endpoint_info.qos_profile.liveliness_lease_duration.sec,
3u) << "Unequal liveliness lease duration sec";
EXPECT_EQ(
topic_endpoint_info.qos_profile.liveliness_lease_duration.nsec,
0u) << "Unequal liveliness lease duration nsec";
topic_endpoint_info.qos_profile.liveliness_lease_duration, RCUTILS_S_TO_NS(3u)
) << "Unequal liveliness lease duration";
EXPECT_EQ(
topic_endpoint_info.qos_profile.avoid_ros_namespace_conventions,
false) << "Unequal avoid namespace conventions";
Expand All @@ -205,17 +200,12 @@ TEST(test_topic_endpoint_info, zero_init) {
EXPECT_EQ(topic_endpoint_info.qos_profile.depth, 0u) << "Non-zero depth";
EXPECT_EQ(topic_endpoint_info.qos_profile.reliability, 0) << "Non-zero reliability";
EXPECT_EQ(topic_endpoint_info.qos_profile.durability, 0) << "Non-zero durability";
EXPECT_EQ(topic_endpoint_info.qos_profile.deadline.sec, 0u) << "Non-zero deadline sec";
EXPECT_EQ(topic_endpoint_info.qos_profile.deadline.nsec, 0u) << "Non-zero deadline nsec";
EXPECT_EQ(topic_endpoint_info.qos_profile.lifespan.sec, 0u) << "Non-zero lifespan sec";
EXPECT_EQ(topic_endpoint_info.qos_profile.lifespan.nsec, 0u) << "Non-zero lifespan nsec";
EXPECT_EQ(topic_endpoint_info.qos_profile.deadline, 0) << "Non-zero deadline";
EXPECT_EQ(topic_endpoint_info.qos_profile.lifespan, 0) << "Non-zero lifespan";
EXPECT_EQ(topic_endpoint_info.qos_profile.liveliness, 0) << "Non-zero liveliness";
EXPECT_EQ(
topic_endpoint_info.qos_profile.liveliness_lease_duration.sec,
0u) << "Non-zero liveliness lease duration sec";
EXPECT_EQ(
topic_endpoint_info.qos_profile.liveliness_lease_duration.nsec,
0u) << "Non-zero liveliness lease duration nsec";
topic_endpoint_info.qos_profile.liveliness_lease_duration,
0) << "Non-zero liveliness lease duration";
EXPECT_EQ(
topic_endpoint_info.qos_profile.avoid_ros_namespace_conventions,
false) << "Non-zero avoid namespace conventions";
Expand All @@ -229,10 +219,10 @@ TEST(test_topic_endpoint_info, fini) {
qos_profile.depth = 0;
qos_profile.reliability = RMW_QOS_POLICY_RELIABILITY_RELIABLE;
qos_profile.durability = RMW_QOS_POLICY_DURABILITY_VOLATILE;
qos_profile.deadline = {1, 0};
qos_profile.lifespan = {2, 0};
qos_profile.deadline = RCUTILS_S_TO_NS(1);
qos_profile.lifespan = RCUTILS_S_TO_NS(2);
qos_profile.liveliness = RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC;
qos_profile.liveliness_lease_duration = {3, 0};
qos_profile.liveliness_lease_duration = RCUTILS_S_TO_NS(3);
qos_profile.avoid_ros_namespace_conventions = false;
rmw_ret_t ret = rmw_topic_endpoint_info_set_qos_profile(&topic_endpoint_info, &qos_profile);
EXPECT_EQ(ret, RMW_RET_OK) << "Expected OK for valid arguments";
Expand Down Expand Up @@ -277,15 +267,11 @@ TEST(test_topic_endpoint_info, fini) {
EXPECT_EQ(topic_endpoint_info.qos_profile.depth, 0u) << "Non-zero depth";
EXPECT_EQ(topic_endpoint_info.qos_profile.reliability, 0) << "Non-zero reliability";
EXPECT_EQ(topic_endpoint_info.qos_profile.durability, 0) << "Non-zero durability";
EXPECT_EQ(topic_endpoint_info.qos_profile.deadline.sec, 0u) << "Non-zero deadline sec";
EXPECT_EQ(topic_endpoint_info.qos_profile.deadline.nsec, 0u) << "Non-zero deadline nsec";
EXPECT_EQ(topic_endpoint_info.qos_profile.lifespan.sec, 0u) << "Non-zero lifespan sec";
EXPECT_EQ(topic_endpoint_info.qos_profile.lifespan.nsec, 0u) << "Non-zero lifespan nsec";
EXPECT_EQ(topic_endpoint_info.qos_profile.deadline, 0u) << "Non-zero deadline";
EXPECT_EQ(topic_endpoint_info.qos_profile.lifespan, 0u) << "Non-zero lifespan";
EXPECT_EQ(topic_endpoint_info.qos_profile.liveliness, 0) << "Non-zero liveliness";
EXPECT_EQ(topic_endpoint_info.qos_profile.liveliness_lease_duration.sec, 0u) <<
"Non-zero liveliness lease duration sec";
EXPECT_EQ(topic_endpoint_info.qos_profile.liveliness_lease_duration.nsec, 0u) <<
"Non-zero liveliness lease duration nsec";
EXPECT_EQ(topic_endpoint_info.qos_profile.liveliness_lease_duration, 0u) <<
"Non-zero liveliness lease duration";
EXPECT_EQ(topic_endpoint_info.qos_profile.avoid_ros_namespace_conventions, false) <<
"Non-zero avoid namespace conventions";
}

0 comments on commit 8b67c3f

Please sign in to comment.