0
$\begingroup$

Rosanswers logo

I am running Ubuntu 20.04.3 LTS and following the tf2 tutorials at https://docs.ros.org/en/foxy/Tutorials/Tf2/Writing-A-Tf2-Broadcaster-Py.html. I have managed the static broadcaster OK but can not get the above link to compile. I have installed all the dependencies defined in the static broadcaster tutorial and get a far as Step 3 Build & run in the linked tutorial. However I can not get it to compile. I use the directory ros2_foxy as my equivalent of dev_ws so that I can more easily migrate to galactic. This is my .bashrc_ros which I link at the end of .bashrc whenever a new terminal is opened.

source /opt/ros/foxy/setup.bash

export ROS_DOMAIN_ID=1

cd /home/brian/ros2_foxy/

source install/local_setup.bash

This is the command I enter and the full output

brian@HP-notebook:~/ros2_foxy$ colcon build --symlink-install --packages-select learning_tf2_py Starting >>> learning_tf2_py Traceback (most recent call last):2_py - 0.2s]
File "", line 1, in
File "/usr/lib/python3.8/distutils/core.py", line 215, in run_setup exec(f.read(), g) File "", line 13, in NameError: name 'os' is not defined --- stderr: learning_tf2_py Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/colcon_core/executor/init.py", line 91, in call rc = await self.task(*args, **kwargs) File "/usr/lib/python3/dist-packages/colcon_core/task/init.py", line 93, in call return await task_method(*args, **kwargs) File "/usr/lib/python3/dist-packages/colcon_ros/task/ament_python/build.py", line 51, in build setup_py_data = get_setup_data(self.context.pkg, env) File "/usr/lib/python3/dist-packages/colcon_core/task/python/init.py", line 20, in get_setup_data return dict(pkg.metadatakey) File "/usr/lib/python3/dist-packages/colcon_ros/package_identification/ros.py", line 129, in getter return get_setup_information( File "/usr/lib/python3/dist-packages/colcon_python_setup_py/package_identification/python_setup_py.py", line 241, in get_setup_information _setup_information_cache[hashable_env] = _get_setup_information( File "/usr/lib/python3/dist-packages/colcon_python_setup_py/package_identification/python_setup_py.py", line 281, in get_setup_information result = subprocess.run( File "/usr/lib/python3.8/subprocess.py", line 516, in run raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/bin/python3', '-c', "import sys;from setuptools.extern.packaging.specifiers import SpecifierSet;from distutils.core import run_setup;dist = run_setup( 'setup.py', script_args=('--dry-run',), stop_after='config');skip_keys = ('cmdclass', 'distclass', 'ext_modules', 'metadata');data = {
key: value for key, value in dist.dict.items() if (
not key.startswith('
') and
not callable(value) and key not in skip_keys and key not in dist.display_option_names
)};data['metadata'] = { k: v for k, v in dist.metadata.dict.items()
if k not in ('license_files', 'provides_extras')};sys.stdout.buffer.write(repr(data).encode('utf-8'))"]' returned non-zero exit status 1. --- Failed <<< learning_tf2_py [0.26s, exited with code 1]

Summary: 0 packages finished [0.36s]
1 package failed: learning_tf2_py 1 package had stderr output: learning_tf2_py Command '['/usr/bin/python3', '-c', "import sys;from setuptools.extern.packaging.specifiers import SpecifierSet;from distutils.core import run_setup;dist = run_setup( 'setup.py', script_args=('--dry-run',), stop_after='config');skip_keys = ('cmdclass', 'distclass', 'ext_modules', 'metadata');data = {
key: value for key, value in dist.dict.items() if (
not key.startswith('_') and
not callable(value) and key not in skip_keys and key not in dist.display_option_names
)};data['metadata'] = { k: v for k, v in dist.metadata.dict.items()
if k not in ('license_files', 'provides_extras')};sys.stdout.buffer.write(repr(data).encode('utf-8'))"]' returned non-zero exit status 1.


Originally posted by bassline on ROS Answers with karma: 28 on 2021-10-13

Post score: 0


Original comments

Comment by clyde on 2021-10-14:
This looks like a Python environment problem. This is a complex topic, and I am not an expert, but I have screwed up my Python environment a few times. :-/ Try building inside a docker container like osrf/ros:foxy-desktop to see if it works there.

Comment by bassline on 2021-10-15:
I have not used Docker so it will take me a while to familiarise myself with it and then set up an environment. I'll add the results later.

Comment by kak13 on 2021-10-15:
try to delete build/ install/ log/ then redo the colcon build

Comment by bassline on 2021-10-15:
Having the deleted the above directories I then get a "missing turtlesim" error on build. If I then build turtleseim and retry to build learning_tf2_py I get the same error.

Comment by kak13 on 2021-10-15:
you downloaded tf2_py from the github, right? If so, go in that directory and git branch then let me know what you see. I can help you on here in real time for next 20 minutes.

Comment by bassline on 2021-10-16:
I realised I had not tried the demo launch file in the static tutorial. This also fails with a similar message. Plan of attack :-

  1. Retry everything on a pi4+ with 4Gb to eliminate environment issues
  2. Boot laptop to Windows to check for firmware updates (laptop < 1 yr old)
  3. Continue Docker training raising issues on their forums. As I have other things to do this may take several days.

Comment by bassline on 2021-10-16:
bad news is that it failed on the Pi4 with the same error. Firmware update were made to the laptop with the same result. Pausing to think it through and later try to sort docker (where I will raise issues on their site)

Comment by clyde on 2021-10-16:
Ah, hold off on the docker idea. I mislead you. I just ran the tutorial and was able to re-create your problem. I don't have any experience building Python-only ROS2 packages, so it might take me a while to figure out the bug, but at this point I think it's a bug in the tutorial. (Any other ROS Python power-users feel free to jump in!)

Comment by bassline on 2021-10-17:
The suggested answer moves us forward but I still get the following error

VERBOSE=1 colcon build --packages-select learning_tf2_py --event-handlers console_direct+ Starting >>> learning_tf2_py Traceback (most recent call last):2_py - 2.2s] File "", line 1, in File "/usr/lib/python3.8/distutils/core.py", line 215, in run_setup exec(f.read(), g) File "", line 16, in TypeError: 'module' object is not callable Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/colcon_core/executor/init.py", line 91, in call rc = await self.task(*args, **kwargs) File "/usr/lib/python3/dist-packages/colcon_core/task/init.py", line 93, in call return await task_method(*args, **kwargs) File "/usr/lib/python3/dist-packages/colcon_ros/task/ament_python/build.py", line 51, in build setup_py_data = get_setup_data(self.context.pkg, env) File "/usr/lib/python3/dist-packages/colcon_core/task/python/__in

Comment by bassline on 2021-10-17:
Now builds on HP laptop but error on Pi4. I will close issue and work on Pi4 issue separately

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

The tutorial is missing some key instructions for modifying setup.py. Add these lines to the top of setup.py:

from glob import glob
import os

Then the build colcon build --packages-select learning_tf2_py should succeed.

The tutorial source code is here: https://github.com/ros/geometry_tutorials/tree/ros2/turtle_tf2_py

I think it's worth filing a bug against the tutorial so that others don't fall into this trap.

(Sorry for leading you astray earlier!)


Originally posted by clyde with karma: 1247 on 2021-10-16

This answer was ACCEPTED on the original site

Post score: 3


Original comments

Comment by Electrolight on 2022-05-18:
You helped me get unstuck after 3 days of bashing my head against the wall. The errors I've been having are useless to point me in the right direction. This was the single google search result when i just paste the entire nonsens... and it actually worked.

Thank you.

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.