Example #1
0
def standalone(name, script, plugins):
    """
    Execute roshlet standalone. This method blocks until roshlet exits.

    @param name: roshlet name
    @type  name: str
    @param package: roshlet package
    @type  package: str
    @param type_: roshlet type
    @type  type_: str
    @param plugins: list of roshlet plugins to load for roshlet
    @type  plugins: [str]
    @raise roslib.packages.InvalidROSPkgException: If package does not exist
    @raise IOError: If roshlet cannot be located
    """
    # clean plugin list
    plugins = [p for p in plugins if p]

    # load rosh symbols
    rosh.rosh_init()

    # Load roshlet and execute blocking in this thread
    pc = rosh.get_default_plugin_context()
    args = rosh.impl.roshlets.load_roshlet(script, pc, plugins)
    rosh.impl.roshlets.exec_roshlet(*args)
Example #2
0
    def __init__(self, *args, **kwds):
        """
        Constructor is the same as rosbag.Bag, with the addition of the 'ctx' keyword argument.

        @param ctx: ROSH Context
        @type  ctx: Context
        """
        if "ctx" in kwds:
            self._ctx = kwds["ctx"]
            del kwds["ctx"]
        else:
            self._ctx = rosh.get_default_plugin_context().ctx
        super(Bag, self).__init__(*args, **kwds)
        self._lock = threading.Lock()
        self._record_topics = None
        self._state = ZERO_STATE
Example #3
0
    def record(self, topic):
        if self.closed:
            raise ROSHException("closed")
        if self._record is not None:
            raise ROSHException("already recording topic %s"%(self._record._name))
            
        if isinstance(topic, TopicNS):
            pass
        elif type(topic) == str:
            ctx = rosh.get_default_plugin_context().ctx
            topic = ctx.topics[topic]

        # TODO: clean this up once I add proper subscribe() to topic
        topic._add_subscriber_callback(self.write)
        self._record = topic
        self._state = RECORD_STATE