Skip to content

Commit

Permalink
split up seek tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lihui815 committed Aug 10, 2021
1 parent 06c279c commit 12aac3b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
15 changes: 13 additions & 2 deletions rosbag2_py/test/test_sequential_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,20 @@ def test_sequential_reader():
assert msg.data == f'Hello, world! {msg_counter}'
msg_counter += 1

# Seek No Filter
reader.reset_filter()

def test_sequential_reader_seek():
bag_path = str(Path(__file__).parent.parent / 'resources' / 'talker')
storage_options, converter_options = get_rosbag_options(bag_path)

reader = rosbag2_py.SequentialReader()
reader.open(storage_options, converter_options)

topic_types = reader.get_all_topics_and_types()

# Create a map for quicker lookup
type_map = {topic_types[i].name: topic_types[i].type for i in range(len(topic_types))}

# Seek No Filter
reader = rosbag2_py.SequentialReader()
reader.open(storage_options, converter_options)
reader.seek(1585866237113147888)
Expand Down
29 changes: 23 additions & 6 deletions rosbag2_py/test/test_sequential_reader_multiple_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import rosbag2_py # noqa


def test_sequential_reader():
def test_reset_filter():
bag_path = str(Path(__file__).parent.parent / 'resources' / 'wbag')
storage_options, converter_options = get_rosbag_options(bag_path)

Expand Down Expand Up @@ -72,6 +72,14 @@ def test_sequential_reader():
assert topic == 'EEE'
assert t == 1005


def test_seek_forward():
bag_path = str(Path(__file__).parent.parent / 'resources' / 'wbag')
storage_options, converter_options = get_rosbag_options(bag_path)

reader = rosbag2_py.SequentialReader()
reader.open(storage_options, converter_options)

# seek forward
reader.seek(1822)

Expand Down Expand Up @@ -99,6 +107,20 @@ def test_sequential_reader():
assert topic == 'BBB'
assert t == 1826


def test_seek_backward():
bag_path = str(Path(__file__).parent.parent / 'resources' / 'wbag')
storage_options, converter_options = get_rosbag_options(bag_path)

reader = rosbag2_py.SequentialReader()
reader.open(storage_options, converter_options)

# seek forward first
reader.seek(1822)
storage_filter = rosbag2_py.StorageFilter(topics=['BBB', 'GGG'])
reader.set_filter(storage_filter)
(topic, data, t) = reader.read_next()

# seek backwards & filter preserved
reader.seek(1408)

Expand All @@ -116,8 +138,3 @@ def test_sequential_reader():

assert topic == 'BBB'
assert t == 1413


def test_plugin_list():
reader_plugins = rosbag2_py.get_registered_readers()
assert 'my_read_only_test_plugin' in reader_plugins

0 comments on commit 12aac3b

Please sign in to comment.