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 12, 2021
1 parent 4d4e831 commit e9ef664
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 46 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
30 changes: 18 additions & 12 deletions rmw/include/rmw/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ extern "C"
// implementation. It may need to be increased in the future.
#define RMW_GID_STORAGE_SIZE 24u

#ifndef _WIN32
# define RMW_DECLARE_DEPRECATED(name, msg) name __attribute__((deprecated(msg)))
#else
# define RMW_DECLARE_DEPRECATED(name, msg) name __pragma(deprecated(name))
#endif

/// Structure which encapsulates an rmw node
typedef struct RMW_PUBLIC_TYPE rmw_node_t
{
Expand Down Expand Up @@ -326,7 +332,12 @@ typedef struct RMW_PUBLIC_TYPE rmw_time_t

/// Nanoseconds component of this time point
uint64_t nsec;
} rmw_time_t;
} RMW_DECLARE_DEPRECATED (rmw_time_t,
"rmw_time_t has been deprecated in G-Turtle in favor of rmw_duration_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 @@ -389,11 +400,6 @@ enum RMW_PUBLIC_TYPE rmw_qos_durability_policy_t
"RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_NODE is deprecated. " \
"Use RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC if manually asserted liveliness is needed."

#ifndef _WIN32
# define RMW_DECLARE_DEPRECATED(name, msg) name __attribute__((deprecated(msg)))
#else
# define RMW_DECLARE_DEPRECATED(name, msg) name __pragma(deprecated(name))
#endif

/// QoS liveliness enumerations that describe a publisher's reporting policy for its alive status.
/// For a subscriber, these are its requirements for its topic's publishers.
Expand Down Expand Up @@ -425,13 +431,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}
#define RMW_QOS_DEADLINE_DEFAULT 0

/// QoS Lifespan default, 0s indicate lifespan policies are not tracked or enforced
#define RMW_QOS_LIFESPAN_DEFAULT {0, 0}
#define 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}
#define 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 +450,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 e9ef664

Please sign in to comment.