rosros 0.2.5
Simple unified interface to ROS1 / ROS2 Python API
|
ROS1 bag reader and writer. More...
Public Member Functions | |
__init__ (self, f, mode="r", compression=rosbag.Compression.NONE, chunk_threshold=768 *1024, allow_unindexed=False, options=None, skip_index=False) | |
Opens a ROS1 bag file. | |
get_message_class (self, typename, typehash=None) | |
Returns ROS1 message class for typename, or None if unknown type. | |
get_message_definition (self, msg_or_type) | |
Returns ROS1 message type definition full text from bag, including subtype definitions. | |
get_message_type_hash (self, msg_or_type) | |
Returns ROS1 message type MD5 hash. | |
get_qoses (self, topic, typename) | |
Returns None (ROS2 bag API conformity stand-in). | |
get_topic_info (self, *_, **__) | |
Returns topic and message type metainfo as {(topic, typename, typehash): count}. | |
read_messages (self, topics=None, start_time=None, end_time=None, connection_filter=None, raw=False) | |
Yields messages from the bag in chronological order. | |
write (self, topic, msg, t=None, raw=False, connection_header=None, **__) | |
Writes a message to the bag. | |
Static Public Member Functions | |
reindex_file (f) | |
Reindexes bag file on disk. | |
Static Public Attributes | |
str | EXTENSION = ".bag" |
Default extension for bag files. | |
ROS1 bag reader and writer.
Extends `rosbag.Bag` with more conveniences, and smooths over the rosbag bug of yielding messages of wrong type, if message types in different topics have different packages but identical fields and hashes.
Does **not** smooth over the rosbag bug of writing different types to one topic.
rosbag does allow writing messages of different types to one topic, just like live ROS topics can have multiple message types published to one topic. And their serialized bytes will actually be in the bag, but rosbag will only register the first type for this topic (unless it is explicitly given another connection header with metadata on the other type).
All messages yielded will be deserialized by rosbag as that first type, and whether reading will raise an exception or not depends on whether the other type has enough bytes to be deserialized as that first type.
rosros.ros1.Bag.__init__ | ( | self, | |
f, | |||
mode = "r" , |
|||
compression = rosbag.Compression.NONE , |
|||
chunk_threshold = 768 * 1024 , |
|||
allow_unindexed = False , |
|||
options = None , |
|||
skip_index = False |
|||
) |
Opens a ROS1 bag file.
f | bag file path to open |
mode | mode to open bag in, one of "r", "w", "a" |
compression | bag write compression mode, one of Compression |
chunk_threshold | minimum number of uncompressed bytes per chunk to write |
allow_unindexed | allow opening unindexed bags |
options | optional dict with values for "compression" and "chunk_threshold" |
skip_index | skip reading the connection index records on open |
rosros.ros1.Bag.get_message_class | ( | self, | |
typename, | |||
typehash = None |
|||
) |
rosros.ros1.Bag.get_message_definition | ( | self, | |
msg_or_type | |||
) |
rosros.ros1.Bag.get_message_type_hash | ( | self, | |
msg_or_type | |||
) |
rosros.ros1.Bag.get_qoses | ( | self, | |
topic, | |||
typename | |||
) |
rosros.ros1.Bag.get_topic_info | ( | self, | |
* | _, | ||
** | __ | ||
) |
rosros.ros1.Bag.read_messages | ( | self, | |
topics = None , |
|||
start_time = None , |
|||
end_time = None , |
|||
connection_filter = None , |
|||
raw = False |
|||
) |
Yields messages from the bag in chronological order.
topics | list of topics or a single topic. If an empty list is given, all topics will be read. |
start_time | earliest timestamp of messages to return, as `rospy.Time` or convertible (int/float/duration/datetime/decimal)
|
end_time | latest timestamp of messages to return as `rospy.Time` or convertible (int/float/duration/datetime/decimal)
|
connection_filter | function to filter connections to include |
raw | if True, then returned messages are tuples of (typename, bytes, md5sum, typeclass)
|
|
static |
rosros.ros1.Bag.write | ( | self, | |
topic, | |||
msg, | |||
t = None , |
|||
raw = False , |
|||
connection_header = None , |
|||
** | __ | ||
) |
Writes a message to the bag.
topic | name of topic |
msg | ROS message to write, or tuple if raw |
t | message timestamp if not using current wall time, as `rospy.Time` or convertible (int/float/duration/datetime/decimal)
|
raw | if true, msg is expected as (typename, bytes, typehash, typeclass) or (typename, bytes, typehash, position, typeclass) |
connection_header | custom connection header dict if any, as {"topic", "type", "md5sum", "message_definition"} |
|
static |