Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions rclpy/rclpy/qos.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ class ReliabilityPolicy(QoSPolicyEnum):
RELIABLE = 1
BEST_EFFORT = 2
UNKNOWN = 3
BEST_AVAILABLE = 4


# Alias with the old name, for retrocompatibility
Expand All @@ -386,6 +387,7 @@ class DurabilityPolicy(QoSPolicyEnum):
TRANSIENT_LOCAL = 1
VOLATILE = 2
UNKNOWN = 3
BEST_AVAILABLE = 4


# Alias with the old name, for retrocompatibility
Expand All @@ -409,11 +411,24 @@ class LivelinessPolicy(QoSPolicyEnum):
AUTOMATIC = 1
MANUAL_BY_TOPIC = 3
UNKNOWN = 4
BEST_AVAILABLE = 5


# Alias with the old name, for retrocompatibility
QoSLivelinessPolicy = LivelinessPolicy

# Deadline policy to match the majority of endpoints while being as strict as possible
# See `RMW_QOS_DEADLINE_BEST_AVAILABLE` in rmw/types.h for more info.
DeadlineBestAvailable = Duration(nanoseconds=_rclpy.RMW_QOS_DEADLINE_BEST_AVAILABLE)

# Liveliness lease duraiton policy to match the majority of endpoints while being as strict as
# possible
# See `RMW_QOS_LIVELINESS_LEASE_DURATION_BEST_AVAILABLE` in rmw/types.h for more info.
LivelinessLeaseDurationeBestAvailable = Duration(
nanoseconds=_rclpy.RMW_QOS_LIVELINESS_LEASE_DURATION_BEST_AVAILABLE
)


# The details of the following profiles can be found at
# 1. ROS QoS principles:
# https://design.ros2.org/articles/qos.html
Expand All @@ -440,6 +455,14 @@ class LivelinessPolicy(QoSPolicyEnum):
#: parameters.
qos_profile_parameter_events = QoSProfile(**_rclpy.rmw_qos_profile_t.predefined(
'qos_profile_parameter_events').to_dict())
#: Match majority of endpoints currently available while maintaining the highest level of service.
#: Policies are chosen at the time of creating a subscription or publisher.
#: The middleware is not expected to update policies after creating a subscription or
#: publisher, even if one or more policies are incompatible with newly discovered endpoints.
#: Therefore, this profile should be used with care since non-deterministic behavior
#: can occur due to races with discovery.
qos_profile_best_available = QoSProfile(**_rclpy.rmw_qos_profile_t.predefined(
'qos_profile_best_available').to_dict())

# Separate rcl_action profile defined at
# ros2/rcl : rcl/rcl_action/include/rcl_action/default_qos.h
Expand All @@ -457,6 +480,7 @@ class QoSPresetProfiles(Enum):
PARAMETERS = qos_profile_parameters
PARAMETER_EVENTS = qos_profile_parameter_events
ACTION_STATUS_DEFAULT = qos_profile_action_status_default
BEST_AVAILABLE = qos_profile_best_available

"""Noted that the following are duplicated from QoSPolicyEnum.

Expand Down
4 changes: 4 additions & 0 deletions rclpy/src/rclpy/_rclpy_pybind11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ PYBIND11_MODULE(_rclpy_pybind11, m) {

m.attr("RCL_DEFAULT_DOMAIN_ID") = py::int_(RCL_DEFAULT_DOMAIN_ID);
m.attr("RMW_DURATION_INFINITE") = py::int_(rmw_time_total_nsec(RMW_DURATION_INFINITE));
m.attr("RMW_QOS_DEADLINE_BEST_AVAILABLE") = py::int_(
rmw_time_total_nsec(RMW_QOS_DEADLINE_BEST_AVAILABLE));
m.attr("RMW_QOS_LIVELINESS_LEASE_DURATION_BEST_AVAILABLE") = py::int_(
rmw_time_total_nsec(RMW_QOS_LIVELINESS_LEASE_DURATION_BEST_AVAILABLE));

py::enum_<rcl_clock_change_t>(m, "ClockChange")
.value(
Expand Down
3 changes: 3 additions & 0 deletions rclpy/src/rclpy/qos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ predefined_qos_profile_from_name(const char * qos_profile_name)
if (0 == strcmp(qos_profile_name, "qos_profile_parameter_events")) {
return rmw_qos_profile_parameter_events;
}
if (0 == strcmp(qos_profile_name, "qos_profile_best_available")) {
return rmw_qos_profile_best_available;
}

std::string error_text = "Requested unknown rmw_qos_profile: ";
error_text += qos_profile_name;
Expand Down