Fails to convert message with const definition in it
OS: Ubuntu 20.04 Python 3.8.10 rosbags installed through pip, version 0.9.4
Hi,
I might have stumbled across a bug in the conversion; While writing a custom script with custom messages I stumbled across the the following exception when the message definition contains a constant (only tried string constants)
The exception:
File "/home/bbferka/.local/lib/python3.8/site-packages/rosbags/typesys/base.py", line 69, in parse_message_definition
assert npos == len(text), f'Could not parse: {text!r}'
To reconstruct:
Msg definitions: MsgWithConst.msg
string FIRST_CONSTANT="whatever"
string SECOND_CONSTANT="whatever"
uint32 number
MsgWithoutConst.msg
string FIRST_CONSTANT
string SECOND_CONSTANT
uint32 number
And a short python script for it:
#!/usr/bin/env python3
from pathlib import Path
from rosbags.typesys import get_types_from_msg, register_types
add_types= {}
msg_without_const = Path('./MsgWithoutConst.msg').read_text()
add_types.update(get_types_from_msg(msg_without_const, 'test_msg/msg/MsgWithoutConst'))
print("Success")
msg_with_const = Path('./MsgWithConst.msg').read_text()
add_types.update(get_types_from_msg(msg_with_const, 'test_msg/msg/MsgWithConst'))
print("Success")
In the script I pasted the first call to get_types_from_msg
is successful for me but the second one fails;
Any help in how to address this problem is appreciated;