Hi everyone,
First of all, I just learned about ROS2 so I am not so familiar with it. Also, I apologize for my bad English.
I am now working on how to implement QoS in my subscription. I have a little bit experience on eProsima FastRTPS and I did manage to run publisher and subscriber with QoS policies. Thus, I expected ROS2 works quite the same way. Here I want to have a deadline policy with a callback function. However, I were lost while trying to set up the callback because in FastRTPS, it has publisher/subscriber listener, which handles all the event callback functions. In ROS2, I do not know where and how to put or configure callback function. I had a look in SubscriptionEventCallbacks
class but it did not work (maybe I set it wrongly). After searching on internet, I have not had any clue yet.
Below is a part of my code trying to configure QoS (I am also not expert on C++ and I am learning it, so feel free to put any comment):
Listener(): Node("Listener_node") // Constructor
{
rclcpp::QoS qos_profile(10);
std::chrono::milliseconds deadline_time(1000);
qos_profile.deadline(deadline_time);
Subscription = this->create_subscription<std_msgs::msg::String>("topic",qos_profile,std::bind(&Listener::callback,this,std::placeholder::_1));
}
Any recommendation, comment or hint is welcomed!
Thanks
Originally posted by Sapodilla on ROS Answers with karma: 48 on 2020-02-25
Post score: 1
Original comments
Comment by stevemacenski on 2020-02-25:
Can you concisely state what your issue is? Your code sample below looks very reasonable.
Comment by Sapodilla on 2020-02-26:
Hi Steven, sorry for my late response. I already found the solution for my issue a few second before typing this comment :D. To make it a bit more clearly, I want to have a callback function whenever a deadline is missed. After spending some time to going through ROS2 doxygen, it finally works for me :). I will put the answer for those who come across this problem like me.