Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A package with APIs to retrieve topic names and QoS settings #216

Open
Yadunund opened this issue Jun 23, 2022 · 0 comments
Open

A package with APIs to retrieve topic names and QoS settings #216

Yadunund opened this issue Jun 23, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@Yadunund
Copy link
Member

Yadunund commented Jun 23, 2022

Presently, the names for various internal ROS 2 topics are defined in StandardNames.hpp files in multiple packages such as rmf_fleet_adapter, rmf_traffic_ros2, rmf_task_ros2.

Downstream packages need to depend on these packages to include this header file to retrieve topic names even though they do not need any other artifacts. But even so, the correct DDS QoS settings for the topic is not apparent.

Proposal:
We define a separate package, rmf_internal_interfaces (or something relevant)

Then inside a single header file, say RMFInternalInterfaces.hpp:

For each internal interface, say FleetStates that is meant to provide information to publish and subscribe to a topic carrying rmf_fleet_msgs::msg::FleetState message, we have

namespace FleetStates {

  static std::string topic_name() { return "/fleet_states"; }
  static rclcpp::QoS qos_profile() { return rclcpp::QoS(10).reliable(); }
  
} // namespace FleetStates

such that downstream applications can

_fleet_states_pub = node->create_publisher(
  rmf_internal_interfaces::FleetStates::topic_name(),
  rmf_internal_interfaces::FleetStates::qos_profile()
);

Instead of namespaces we could also define structs.

For stricter API control, we could also have a pure abstract base class

class InterfaceBase
{
public:
  virtual std::string topic_name() const = 0;
  virtual rclcpp::QoS qos_profile() const = 0;
  virtual ~InterfaceBase() = default;
}

which can be implemented

class FleetStates : public InterfaceBase
{
public:
  std::string topic_name() const final { return "/fleet_states"; }
  rclcpp::QoS qos_profile() const final { return rclcpp::QoS(10).reliable(); }
} 

But the latter would require users to instantiate objects of these classes first.

@Yadunund Yadunund added the enhancement New feature or request label Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant