-
Notifications
You must be signed in to change notification settings - Fork 53
Description
- Operating System:
- x64 Linux - Ubuntu 20.04
- Installation type:
- From source
- Version or commit hash:
Steps to reproduce issue
- Create a package that can generate types from IDL.
- Create an IDL message file with a char[4] type as one of the struct fields.
- Build the package and source the setup.bash
- Use
ros2 topic pub <topic name> <any message type from package with IDL containing the char array> {}
orros2 topic echo <topic with type from that same package>
- ros2cli tool will fail with a traceback
Description
Ultimately, the root cause (as indicated at the end of the error message below) is an unmatched closing parenthesis which is generated for the char[] type in _msg.py.em.
This does not:
- Happen for other types that I have tested like
long[4]
andshort[4]
, only forchar[4]
- Happen for non-array
char
- Change based on array size (4 is just an example)
This issue seems to have been in the codebase for quite some time, but only started causing issues in a recent Rolling build that I performed about a week ago, so it seems like something changed that caused this to start happening at runtime. This may be related to this recent commit:
91df295#diff-0da744c3127964a8907eb35fc0b5c04e32eccd515d8cf7fb839ec80ebb82fa59
One clue is that the error for the offending struct happens even when publishing or subscribing to a topic with a different type than the char[] containing one within the same package, which I believe is caused by all types getting imported in <some package>/msg/__init__.py
Fix:
Example
myorg_msgs/msg/TestMessage.idl
module myorg_msgs {
module msg {
struct TestMessage {
char [4];
};
};
};
Command/error:
spiderkeys@spiderdesk:/opt/mr/myorg$ ros2 topic pub hello myorg_msgs/msg/TestMessage {}
Traceback (most recent call last):
File "/opt/ros/install/bin/ros2", line 33, in <module>
sys.exit(load_entry_point('ros2cli==0.10.1', 'console_scripts', 'ros2')())
File "/opt/ros/install/lib/python3.8/site-packages/ros2cli/cli.py", line 67, in main
rc = extension.main(parser=parser, args=args)
File "/opt/ros/install/lib/python3.8/site-packages/ros2topic/command/topic.py", line 41, in main
return extension.main(args=args)
File "/opt/ros/install/lib/python3.8/site-packages/ros2topic/verb/pub.py", line 97, in main
return main(args)
File "/opt/ros/install/lib/python3.8/site-packages/ros2topic/verb/pub.py", line 108, in main
return publisher(
File "/opt/ros/install/lib/python3.8/site-packages/ros2topic/verb/pub.py", line 133, in publisher
msg_module = get_message(message_type)
File "/opt/ros/install/lib/python3.8/site-packages/rosidl_runtime_py/utilities.py", line 28, in get_message
interface = import_message_from_namespaced_type(get_message_namespaced_type(identifier))
File "/opt/ros/install/lib/python3.8/site-packages/rosidl_runtime_py/import_message.py", line 30, in import_message_from_namespaced_type
module = importlib.import_module(
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/opt/mr/myorg/install/myorg_msgs/lib/python3.8/site-packages/myorg_msgs/msg/__init__.py", line 22, in <module>
from myorg_msgs.msg._test_message import TestMessage # noqa: F401
File "/opt/mr/myorg/install/myorg_msgs/lib/python3.8/site-packages/myorg_msgs/msg/_test_message.py", line 134
all(val >= 0 and val) < 256 for val in value)), \
^
SyntaxError: unmatched ')'