Convert connections attribute to list

This commit is contained in:
Marko Durkovic
2022-04-21 15:15:10 +02:00
parent f7d69e35d5
commit 34ffe96692
14 changed files with 72 additions and 74 deletions
@@ -23,7 +23,7 @@ def offset_timestamps(src: Path, dst: Path, offset: int) -> None:
"""
with Reader(src) as reader, Writer(dst) as writer:
conn_map = {}
for conn in reader.connections.values():
for conn in reader.connections:
ext = cast(ConnectionExtRosbag2, conn.ext)
conn_map[conn.id] = writer.add_connection(
conn.topic,
+1 -1
View File
@@ -22,7 +22,7 @@ def remove_topic(src: Path, dst: Path, topic: str) -> None:
"""
with Reader(src) as reader, Writer(dst) as writer:
conn_map = {}
for conn in reader.connections.values():
for conn in reader.connections:
if conn.topic == topic:
continue
ext = cast(ConnectionExtRosbag2, conn.ext)
+1 -1
View File
@@ -20,7 +20,7 @@ def process_bag(src: Path) -> None:
"""
with Reader(src) as reader:
typs = {}
for conn in reader.connections.values():
for conn in reader.connections:
typs.update(get_types_from_msg(conn.msgdef, conn.msgtype))
register_types(typs)
+3 -3
View File
@@ -37,8 +37,8 @@ Instances of the :py:class:`Reader <rosbags.rosbag2.Reader>` class are typically
# create reader instance
with Reader('/home/ros/rosbag_2020_03_24.bag') as reader:
# topic and msgtype information is available on .connections dictionary
for connection in reader.connections.values():
# topic and msgtype information is available on .connections list
for connection in reader.connections:
print(connection.topic, connection.msgtype)
# iterate over messages
@@ -48,7 +48,7 @@ Instances of the :py:class:`Reader <rosbags.rosbag2.Reader>` class are typically
print(msg.header.frame_id)
# messages() accepts connection filters
connections = [x for x in reader.connections.values() if x.topic == '/imu_raw/Imu']
connections = [x for x in reader.connections if x.topic == '/imu_raw/Imu']
for connection, timestamp, rawdata in reader.messages(connections=connections):
msg = deserialize_cdr(ros1_to_cdr(rawdata, connection.msgtype), connection.msgtype)
print(msg.header.frame_id)
+3 -3
View File
@@ -52,8 +52,8 @@ Instances of the :py:class:`Reader <rosbags.rosbag2.Reader>` class are used to r
# create reader instance and open for reading
with Reader('/home/ros/rosbag_2020_03_24') as reader:
# topic and msgtype information is available on .connections dict
for connection in reader.connections.values():
# topic and msgtype information is available on .connections list
for connection in reader.connections:
print(connection.topic, connection.msgtype)
# iterate over messages
@@ -63,7 +63,7 @@ Instances of the :py:class:`Reader <rosbags.rosbag2.Reader>` class are used to r
print(msg.header.frame_id)
# messages() accepts connection filters
connections = [x for x in reader.connections.values() if x.topic == '/imu_raw/Imu']
connections = [x for x in reader.connections if x.topic == '/imu_raw/Imu']
for connection, timestamp, rawdata in reader.messages(connections=connections):
msg = deserialize_cdr(rawdata, connection.msgtype)
print(msg.header.frame_id)