Rosanswers logo


I`m trying to use a Rtabmap service, which is defined as follows:

 bool global
 bool optimized
 bool graph_only

Then, I call:

 ros2 service call /publish_map rtabmap_ros/srv/PublishMap "{global: 1, optimized: 1, graph_only: 0}"

But it returns:

Traceback (most recent call last):
File "/opt/ros/eloquent/bin/ros2", line 11, in <module>
    load_entry_point('ros2cli==0.8.7', 'console_scripts', 'ros2')()
File "/opt/ros/eloquent/lib/python3.6/site-packages/ros2cli/cli.py", line 69, in main
    rc = extension.main(parser=parser, args=args)
File "/opt/ros/eloquent/lib/python3.6/site-packages/ros2service/command/service.py", line 43, in main
    return extension.main(args=args)
File "/opt/ros/eloquent/lib/python3.6/site-packages/ros2service/verb/call.py", line 59, in main
    args.service_type, args.service_name, args.values, period)
File "/opt/ros/eloquent/lib/python3.6/site-packages/ros2service/verb/call.py", line 69, in requester
    module = importlib.import_module('.'.join(parts[:-1]))
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/user/rtabmap_ros/install/rtabmap_ros/lib/python3.6/site-packages/rtabmap_ros/srv/__init__.py", line 1, in <module>
    from rtabmap_ros.srv._get_map import GetMap  # noqa: F401
File "/home/user/rtabmap_ros/install/rtabmap_ros/lib/python3.6/site-packages/rtabmap_ros/srv/_get_map.py", line 77
    self.global = kwargs.get('global', bool())
SyntaxError: invalid syntax

Please, any idea why this is happening?

Thanks in advance!

Originally posted by mirella melo on ROS Answers with karma: 194 on 2020-12-02

Post score: 0


1 Answer 1


Rosanswers logo

Hey, the problem here seems to be the field name global used in the service definition. I could not find any ROS2 resource for this, but the ROS1 msg wiki said:

It is recommended that you avoid using field names that correspond to keywords in common languages -- although those names are legal, they create confusion as to how a field name is translated.

This seems to be exactly what is happening here. The ROS2 cli packages are written in python (this wasn't the case in ROS1), and global is a keyword in python. So IMO this looks like an issue in the rtabmap_ros package.

Originally posted by RobertWilbrandt with karma: 176 on 2020-12-03

This answer was ACCEPTED on the original site

Post score: 0

Original comments

Comment by mirella melo on 2020-12-03:
This makes sense! Hopefully, the Rtabmap team will fix it if this is the case. Thank you for your reply!!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.