Coverage for /home/masasin/desktop/pyrosbag/pyrosbag/pyrosbag.py : 68%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
#!/usr/bin/env python # -*- coding: utf-8 -*- Programmatically control a ROS bag file.
This module implements the base class, and the various functions.
Currently implemented are:
* ``rosbag play``
"""
""" Catch bag player exceptions.
"""
""" Raised when interaction is attempted with a bag file which is not running.
"""
""" Open and manipulate a bag file programmatically.
Parameters ---------- filenames : StringTypes | List[StringTypes] The location of the bag files.
Attributes ---------- filenames : List[StringTypes] The location of the bag files. process : subprocess.Popen The process containing the running bag file.
"""
""" Write something to process stdin.
Parameters ---------- string : str The string to write.
Raises ------ BagNotRunningError If interaction is attempted when the bag file is not running.
"""
""" Stop a running bag file.
Raises ------ BagNotRunningError If the bag file is not running.
"""
""" Block until process is complete.
Raises ------ BagNotRunningError If the bag file is not running.
"""
def is_running(self): """ Check whether the bag file is running.
Returns ------- bool The bag file is running.
"""
""" Context manager entry point.
"""
# noinspection PyUnusedLocal """ Context manager exit point.
""" "to wait until completion.") else:
else:
""" Play Bag files.
""" quiet=None, immediate=None, start_paused=None, queue_size=None, publish_clock=None, clock_publish_freq=None, delay=None, publish_rate_multiplier=None, start_time=None, duration=None, loop=None, keep_alive=None): """ Play the bag file.
Parameters ---------- wait : Optional[Bool] Wait until completion. stdin : Optional[file] The stdin buffer. Default is subprocess.PIPE. stdout : Optional[file] The stdout buffer. stderr : Optional[file] The stderr buffer. quiet : Optional[Bool] Suppress console output. immediate : Optional[Bool] Play back all messages without waiting. start_paused : Optional[Bool] Start in paused mode. queue_size : Optional[int] Set outgoing queue size. Default is 100. publish_clock : Optional[Bool] Publish the clock time. clock_publish_freq : Optional[float] The frequency, in Hz, at which to publish the clock time. Default is 100. delay : Optional[float] The number of seconds to sleep afer every advertise call (e.g., to allow subscribers to connect). publish_rate_multiplier : Optional[float] The factor by which to multiply the publish rate. start_time : Optional[float] The number of seconds into the bag file at which to start. duration : Optional[float] The number of seconds from the start to play. loop : Optional[Bool] Loop playback. keep_alive : Optional[Bool] Keep alive past end of bag (e.g. for publishing latched topics).
""" arguments = ["rosbag", "play"] arguments.extend(self.filenames)
if quiet: arguments.append("-q") if immediate: arguments.append("-i") if start_paused: arguments.append("--pause") if queue_size is not None: arguments.append("--queue={}".format(queue_size)) if publish_clock: arguments.append("--clock") if clock_publish_freq: arguments.append("--hz={}".format(clock_publish_freq)) if delay: arguments.append("--delay={}".format(delay)) if publish_rate_multiplier: arguments.append("--rate={}".format(publish_rate_multiplier)) if start_time: arguments.append("--start={}".format(start_time)) if duration: arguments.append("--duration={}".format(duration)) if loop: arguments.append("-l") if keep_alive: arguments.append("-k")
self.process = sp.Popen(arguments, stdin=stdin, stdout=stdout, stderr=stderr) if wait: self.wait()
""" Pause the bag file.
""" self.send(" ")
""" Resume the bag file.
""" self.send(" ")
""" Step through a paused bag file.
""" self.send("s") |