message_filters cache complaining about different time sources
I am trying to use message_filters::Cache
and I am getting a runtime exception saying can't compare times with different time sources
. Here is a simplified snippet of how I use it,
TestNodeNode::TestNodeNode(const rclcpp::NodeOptions & options)
: Node("test_node", options),
m_pt1_sub(this, "pt1", rclcpp::QoS(10).get_rmw_qos_profile()),
m_pt2_sub(this, "pt2", rclcpp::QoS(10).get_rmw_qos_profile()),
m_header_cache(m_pt2_sub, 10U),
verbose(true)
{
m_pt1_sub.registerCallback(
[this](geometry_msgs::msg::PointStamped::ConstSharedPtr msg) {
process(msg);
});
print_hello();
}
void TestNodeNode::process(geometry_msgs::msg::PointStamped::ConstSharedPtr msg)
{
RCLCPP_INFO(get_logger(), "Got pt1 msg. looking for pt2 msg");
const auto matched_msgs = m_header_cache.getInterval(msg->header.stamp, msg->header.stamp);
if (matched_msgs.empty()) {
RCLCPP_INFO(get_logger(), "Did not get any match");
} else {
RCLCPP_INFO(get_logger(), "Got match");
}
}
I published on these topics using the following python snippet,
class MinimalPublisher(Node):
def __init__(self):
super().__init__("minimal_publisher")
self.pub1 = self.create_publisher(PointStamped, 'pt1', 10)
self.pub2 = self.create_publisher(PointStamped, 'pt2', 10)
node = MinimalPublisher()
msg1 = PointStamped()
msg1.header.stamp = node.get_clock().now().to_msg()
msg2 = msg1
node.pub1.publish(msg1)
node.pub2.publish(msg2)
node.pub1.publish(msg1)
As soon as I publish a msg on the pt1
topic I get the runtime exception. Here is the output that I get,
[INFO] [1626989927.745215359] [test_node]: Got pt1 msg. looking for pt2 msg
[INFO] [1626989927.745443141] [test_node]: Did not get any match
[INFO] [1626989942.674142699] [test_node]: Got pt1 msg. looking for pt2 msg
terminate called after throwing an instance of 'std::runtime_error'
what(): can't compare times with different time sources
Aborted
Edit: I am using foxy
Edit 2: Adding the backtrace as per the comment,
[INFO] [1627079032.313712337] [test_node]: Got pt1 msg. looking for pt2 msg
terminate called after throwing an instance of 'std::runtime_error'
what(): can't compare times with different time sources
Thread 1 "test_node_node_" received signal SIGABRT, Aborted.
0x00007fd600f7618b in raise () from /usr/lib/x86_64-linux-gnu/libc.so.6
(gdb) bt
#0 0x00007fd600f7618b in raise () from /usr/lib/x86_64-linux-gnu/libc.so.6
#1 0x00007fd600f55859 in abort () from /usr/lib/x86_64-linux-gnu/libc.so.6
#2 0x00007fd6011db911 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3 0x00007fd6011e738c in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4 0x00007fd6011e73f7 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5 0x00007fd6011e76a9 in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6 0x00007fd60145696c in ?? () from /opt/ros/foxy/lib/librclcpp.so
#7 0x00007fd6001e1f3f in message_filters::Cache<geometry_msgs::msg::PointStamped_<std::allocator<void> > >::getInterval(rclcpp::Time const&, rclcpp::Time const&) const ()
from /home/gowtham.ranganathan/AutowareAuto/install/test_node/lib/libtest_node_node.so
#8 0x00007fd6001de86c in autoware::test_node::TestNodeNode::process(std::shared_ptr<geometry_msgs::msg::PointStamped_<std::allocator<void> > const>) ()
from /home/gowtham.ranganathan/AutowareAuto/install/test_node/lib/libtest_node_node.so
#9 0x00007fd6001de233 in autoware::test_node::TestNodeNode::TestNodeNode(rclcpp::NodeOptions const&)::{lambda(std::shared_ptr<geometry_msgs::msg::PointStamped_<std::allocator<void> > const>)#1}::operator()(std::shared_ptr<geometry_msgs::msg::PointStamped_<std::allocator<void> > const>) const () from /home/gowtham.ranganathan/AutowareAuto/install/test_node/lib/libtest_node_node.so
#10 0x00007fd6001df18c in std::_Function_handler<void (std::shared_ptr<geometry_msgs::msg::PointStamped_<std::allocator<void> > const> const&), autoware::test_node::TestNodeNode::TestNodeNode(rclcpp::NodeOptions const&)::{lambda(std::shared_ptr<geometry_msgs::msg::PointStamped_<std::allocator<void> > const> ...
Have you seen this issue? https://github.com/ros2/message_filte... Seems like your problem has to do with the use of different clocks. Also it would be useful if you could provide the backtrack of the exception. The navigation project has a howto: https://navigation.ros.org/tutorials/...
Thanks for the reply, William. I have posted the backtrace to the description.
We don't get what we need, this line isn't useful
#6 0x00007fd60145696c in ?? () from /opt/ros/foxy/lib/librclcpp.so
, so you need to install the debug binaries or build it from source in debug.