Skip to content

Commit

Permalink
Remove MANUAL_BY_NODE liveliness API (#227)
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
  • Loading branch information
ivanpauno authored May 12, 2020
1 parent 10bb863 commit 36b415a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 29 deletions.
3 changes: 3 additions & 0 deletions rmw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ ament_export_targets(${PROJECT_NAME})
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
# pass extra include dirs to cppcheck explicitly
list(APPEND AMENT_LINT_AUTO_EXCLUDE ament_cmake_cppcheck)
ament_cppcheck(INCLUDE_DIRS ${rcutils_INCLUDE_DIRS})

add_subdirectory(test)
endif()
Expand Down
25 changes: 5 additions & 20 deletions rmw/include/rmw/rmw.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ extern "C"
#include <stddef.h>
#include <stdint.h>

#include "rcutils/macros.h"
#include "rcutils/types.h"

#include "rosidl_runtime_c/message_type_support_struct.h"
Expand Down Expand Up @@ -198,27 +199,11 @@ RMW_WARN_UNUSED
rmw_ret_t
rmw_destroy_node(rmw_node_t * node);

/// Manually assert that this node is alive (for RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_NODE)
/**
* If the rmw Liveliness policy is set to RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_NODE, the creator of
* this node may manually call `assert_liveliness` at some point in time to signal to the rest
* of the system that this Node is still alive.
*
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | No
* Thread-Safe | Yes
* Uses Atomics | No
* Lock-Free | Yes
*
* \param[in] node handle to the node that needs liveliness to be asserted
* \return `RMW_RET_OK` if the liveliness assertion was completed successfully, or
* \return `RMW_RET_ERROR` if an unspecified error occurs, or
* \return `RMW_RET_UNSUPPORTED` if the rmw implementation does not support asserting liveliness.
*/

RMW_PUBLIC
RMW_WARN_UNUSED
RCUTILS_DEPRECATED_WITH_MSG(
"rmw_node_assert_liveliness implementation was removed."
" If manual liveliness assertion is needed, use MANUAL_BY_TOPIC.")
rmw_ret_t
rmw_node_assert_liveliness(const rmw_node_t * node);

Expand Down
27 changes: 21 additions & 6 deletions rmw/include/rmw/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,26 +384,41 @@ enum RMW_PUBLIC_TYPE rmw_qos_durability_policy_t
RMW_QOS_POLICY_DURABILITY_UNKNOWN
};

#define RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_NODE_DEPRECATED_MSG \
"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.
enum RMW_PUBLIC_TYPE rmw_qos_liveliness_policy_t
{
/// Implementation specific default
RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT,
RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT = 0,

/// The signal that establishes a Topic is alive comes from the ROS rmw layer.
RMW_QOS_POLICY_LIVELINESS_AUTOMATIC,
RMW_QOS_POLICY_LIVELINESS_AUTOMATIC = 1,

/// The signal that establishes a Topic is alive is manually reported by the node
RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_NODE,
/// Explicitly asserting node liveliness is required in this case.
/// This option is deprecated, use RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC if your application
/// requires to assert liveliness manually.
RMW_DECLARE_DEPRECATED(
RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_NODE,
RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_NODE_DEPRECATED_MSG) = 2,

/// The signal that establishes a Topic is alive is at the Topic level. Only publishing a message
/// on the Topic or an explicit signal from the application to assert liveliness on the Topic
/// will mark the Topic as being alive.
RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC,
// Using `3` for backwards compatibility.
RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC = 3,

/// Liveliness policy has not yet been set
RMW_QOS_POLICY_LIVELINESS_UNKNOWN
RMW_QOS_POLICY_LIVELINESS_UNKNOWN = 4
};

/// QoS Deadline default, 0s indicates deadline policies are not tracked or enforced
Expand Down
6 changes: 3 additions & 3 deletions rmw/test/test_topic_endpoint_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ TEST(test_topic_endpoint_info, set_qos_profile) {
qos_profile.durability = RMW_QOS_POLICY_DURABILITY_VOLATILE;
qos_profile.deadline = {1, 0};
qos_profile.lifespan = {2, 0};
qos_profile.liveliness = RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_NODE;
qos_profile.liveliness = RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC;
qos_profile.liveliness_lease_duration = {3, 0};
qos_profile.avoid_ros_namespace_conventions = false;

Expand Down Expand Up @@ -179,7 +179,7 @@ TEST(test_topic_endpoint_info, set_qos_profile) {
EXPECT_EQ(topic_endpoint_info.qos_profile.lifespan.nsec, 0u) << "Unequal lifespan nsec";
EXPECT_EQ(
topic_endpoint_info.qos_profile.liveliness,
RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_NODE) << "Unequal 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";
Expand Down Expand Up @@ -231,7 +231,7 @@ TEST(test_topic_endpoint_info, fini) {
qos_profile.durability = RMW_QOS_POLICY_DURABILITY_VOLATILE;
qos_profile.deadline = {1, 0};
qos_profile.lifespan = {2, 0};
qos_profile.liveliness = RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_NODE;
qos_profile.liveliness = RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC;
qos_profile.liveliness_lease_duration = {3, 0};
qos_profile.avoid_ros_namespace_conventions = false;
rmw_ret_t ret = rmw_topic_endpoint_info_set_qos_profile(&topic_endpoint_info, &qos_profile);
Expand Down

0 comments on commit 36b415a

Please sign in to comment.