Skip to content
Merged
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
63 changes: 63 additions & 0 deletions rclrs/src/qos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,13 @@ pub struct QoSProfile {
pub avoid_ros_namespace_conventions: bool,
}

/// Sets the `QoSProfile` to the RCL default.
impl Default for QoSProfile {
fn default() -> Self {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make a note here that this is setting the QOS profile to the RCL default? Just to avoid any confusion?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! 6ac6caa

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luca-della-vedova thanks 🙂

QOS_PROFILE_DEFAULT
}
}

impl From<QoSProfile> for rmw_qos_profile_t {
fn from(qos: QoSProfile) -> Self {
Self {
Expand All @@ -199,6 +206,62 @@ impl From<QoSProfile> for rmw_qos_profile_t {
}
}

impl QoSProfile {
/// Sets the QoS profile history to [QoSHistoryPolicy::KeepLast] with the specified depth.
pub fn keep_last(mut self, depth: u32) -> Self {
self.history = QoSHistoryPolicy::KeepLast { depth };
self
}

/// Sets the QoS profile history to [QoSHistoryPolicy::KeepAll].
pub fn keep_all(mut self) -> Self {
self.history = QoSHistoryPolicy::KeepAll;
self
}

/// Sets the QoS profile reliability to [QoSReliabilityPolicy::Reliable].
pub fn reliable(mut self) -> Self {
self.reliability = QoSReliabilityPolicy::Reliable;
self
}

/// Sets the QoS profile reliability to [QoSReliabilityPolicy::BestEffort].
pub fn best_effort(mut self) -> Self {
self.reliability = QoSReliabilityPolicy::BestEffort;
self
}

/// Sets the QoS profile durability to [QoSDurabilityPolicy::Volatile].
pub fn volatile(mut self) -> Self {
self.durability = QoSDurabilityPolicy::Volatile;
self
}

/// Sets the QoS profile durability to [QoSDurabilityPolicy::TransientLocal].
pub fn transient_local(mut self) -> Self {
self.durability = QoSDurabilityPolicy::TransientLocal;
self
}

/// Sets the QoS profile deadline to the specified `Duration`.
pub fn deadline(mut self, deadline: Duration) -> Self {
self.deadline = QoSDuration::Custom(deadline);
self
}

/// Sets the QoS profile liveliness lease duration to the specified `Duration`.
pub fn liveliness_lease_duration(mut self, lease_duration: Duration) -> Self {
self.liveliness_lease_duration = QoSDuration::Custom(lease_duration);
self
}

/// Sets the QoS profile lifespan to the specified `Duration`.
pub fn lifespan(mut self, lifespan: Duration) -> Self {
self.lifespan = QoSDuration::Custom(lifespan);
self
}
}

impl From<QoSHistoryPolicy> for rmw_qos_history_policy_t {
fn from(policy: QoSHistoryPolicy) -> Self {
match policy {
Expand Down