#python iterator yields wrong message when topics is just a string and not a tuple
bug
Iterator yields wrong message when topics is just a string and not a tuple.
The issue occurs when the mcap file has to topics with the first charakters matching
for example:
```
/sensors/1
/sensors/12
```
the the iterator will always yield `/sensors/1` when you request `/sensors/12`
the line of code that causes this issue is this one
```
if topics is not None and channel.topic not in topics:
continue
```
in the seeking reader class in the iter messages function
one possible fix is to call the function with a tuple
`reader.iter_decoded_messages(topics=("/sensors/12",))`
- Version:0.5.6
- Platform: Windows
```
from mcap_ros2.decoder import DecoderFactory
from mcap.reader import make_reader
file = ""
reader = make_reader(file, decoder_factories=[DecoderFactory()])
reader.iter_decoded_messages(topics=("/sensors/12"))
```
**Expected Behavior**
It should should yield /sensors/12 and not /sensors/1
关闭于 2025-12-24 6 条评论