ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Ros2 Qos Deadline usage

asked 2020-05-16 04:12:20 -0500

pfedom gravatar image

I am trying to get a watchdog timer running to see if my joystick is continously publishing. In another Question i got the hint to use QoS Deadline. I found one example but I cant get it working the way i want it to work. All I want is to start the topic_callback function to set a variable if the duration is longer than xx milliseconds.

My Joy_node publishes: pub_ = create_publisher<sensor_msgs::msg::Joy>("joy", rclcpp::QoS(10)); and I am checking it like this:

 rclcpp::QoS qos_profile(10);
 qos_profile.deadline(deadline_duration);
 subscription_ = this->create_subscription<sensor_msgs::msg::Joy>(
   "joy", qos_profile, std::bind(&JoyToVel::topic_callback, this, _1));

Its not doing anything until i set the deadline_duration to 0. Than it starts the topic_callback function. Does anyone know if there is just a simple coding failure or am I using the deadline feature completely wrong?

Thanks in advance!

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2020-10-24 03:14:39 -0500

carlossvg gravatar image

You have to set a deadline QoS for both publisher and subscription. Based on your description what you want is to configure the joystick publisher with a deadline QoS. You don't create a new subscription or publisher but you simply configure them to use QoS and to bind it a callback to handle missing deadlines. In your case it could be as follows:

  // create publisher
  rclcpp::QoS qos_profile(10);
  rclcpp::PublisherOptions publisher_options;
  qos_profile.deadline(deadline_duration);
  publisher_options.event_callbacks.deadline_callback =
    [](rclcpp::QOSDeadlineOfferedInfo & event) -> void
    {
      // handle missing deadlines
    };
  publisher_ = this->create_publisher<sensor_msgs::msg::Joy>("joy", qos_profile,  publisher_options);

  // create subscription
  rclcpp::SubscriptionOptions subscription_options;
  subscription_options.event_callbacks.deadline_callback =
  [](rclcpp::QOSDeadlineRequestedInfo & event) -> void
  {
     // handle missing deadlines
  };
   subscription_ = this->create_subscription<sensor_msgs::msg::Joy>("joy", qos_profile, std::bind(&JoyToVel::topic_callback, this, _1), subscription_options);

It's important this QoS is configured on both sides, otherwise, you would get an incompatible QoS error. See:

When the DDS Service ‘matches’ a DataWriter and a DataReader it checks whether the settings are compatible (i.e., offered deadline period<= requested deadline period) if they are not, the two entities are informed (via the listener or condition mechanism) of the incompatibility of the QoS settings and communication will not occur.

Fore more information take a look to this document and this example.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2020-05-16 04:12:20 -0500

Seen: 1,086 times

Last updated: Oct 24 '20