#! /usr/bin/env python

import rospy
from threading import Lock


class Listener:
    def __init__(self, topic_name, topic_type, lock=None):
        """
        Listener is a wrapper around a subscriber where the callback simply records the latest msg.

        Parameters:
            topic_name (str): name of topic to subscribe to
            topic_type (msg_type): type of message received on topic
            lock (Lock): optional lock object used when setting stored data
        """

        self.data = None
        self.lock = lock
        if self.lock is None:
            self.lock = Lock()
            
        self.subscriber = rospy.Subscriber(topic_name, topic_type, self.callback)
        

    def callback(self, msg):
        with self.lock:
            self.data = msg

    def get(self):
        """
        Returns the latest msg from the subscribed topic
        """
        with self.lock:
            return self.data
    

@@ -124,22 +124,11 @@
 type
-, lock=None
 ):%0A
+
     
@@ -236,16 +236,202 @@
 t msg.%0A%0A
+        Listener does not consume the message %0A            (for consuming behavior, use the standard ros callback pattern)%0A        Listener does not check timestamps of message headers%0A%0A
         
@@ -708,67 +708,8 @@
 ck =
- lock%0A        if self.lock is None:%0A            self.lock =
  Loc

Remove optional lock input (I can't see when it would be useful) Document when Listener should be used