Hi, I'm wondering whether you like the idea of adding more newbie-friendly APIs for creating pub/sub, service/client? My initial thought is to combine the steps of creating topics and pub/sub/service/client. E.g., for creating subs,
pub fn create_subscriber<D: DeserializeOwned + 'static>(
&mut self,
topic_type: impl ToString,
topic_name: impl ToString,
qos: Option<QosPolicies>,
) -> CreateResult<Subscription<D>> {
let qos = match qos {
Some(qos) => qos,
None => {
QosPolicyBuilder::new()
.durability(policy::Durability::Volatile)
.liveliness(policy::Liveliness::Automatic {
lease_duration: Duration::INFINITE,
})
.reliability(policy::Reliability::Reliable {
max_blocking_time: Duration::from_millis(100),
})
.history(policy::History::KeepLast { depth: 1 })
.build()
}
};
let topic = self.create_topic(&topic_name.to_string(), topic_type.to_string(), &qos)?;
self
.create_subscription::<D>(&topic, None)
}
Then we can create a subscriber by
let sub = node
.create_subscriber::<String>(
String::from("std_msgs::msg::dds_::String_"),
"/topic",
None,
)
.unwrap();
The rationals are:
- It will make the APIs more like the ones rclpy/rclcpp provides.
- It will make the example simpler as newcomers tend to not care so much about QoS configurations, while advanced users can still define their own QoS profiles.
- For real-world applications, a node may handle multiple subs and pubs. Using higher-level APIs to create pub/subs could reduce the line of code and make the code easier to understand.
How do you think about that?
Hi, I'm wondering whether you like the idea of adding more newbie-friendly APIs for creating pub/sub, service/client? My initial thought is to combine the steps of creating topics and pub/sub/service/client. E.g., for creating subs,
Then we can create a subscriber by
The rationals are:
How do you think about that?