Problem with Subscriber class from message_filter in Python
I am currently facing a problem, that the Subscriber() is expecting 3 arguments, while in the docs it is always being done with 2: http://docs.ros.org/en/api/message_fi...
Therefore I am getting an IndexError: tuple index out of range. Looking at the source code of Subscriber:
class Subscriber(SimpleFilter):
"""
ROS2 subscription filter,Identical arguments as :class:`rclpy.Subscriber`.
This class acts as a highest-level filter, simply passing messages
from a ROS2 subscription through to the filters which have connected
to it.
"""
def __init__(self, *args, **kwargs):
SimpleFilter.__init__(self)
self.node = args[0]
self.topic = args[2]
kwargs.setdefault('qos_profile', 10)
self.sub = self.node.create_subscription(*args[1:], self.callback, **kwargs)
def callback(self, msg):
self.signalMessage(msg)
def getTopic(self):
return self.topic
def __getattr__(self, key):
"""Serve same API as rospy.Subscriber"""
return self.sub.__getattribute__(key)
you can see that let's say
imu_sub = Subscriber("imu/", Imu)
won't work, as it expects 3 arguments. As I consider myself still as a novice in Python and ROS2, I'd appreciate any help on this topic.