carla-simulator/ros-bridge

Ubuntu 20.04 Foxy carla-ros-bridge Install colcon error

mgmike opened this issue · 1 comments

I am trying to install the conda-ros-bridge from the docs and I am getting the following error. Here is what I have now:

Ubuntu 20.04
Unreal Engine (4.26) and Carla (carla-simulator/focal 0.9.13): https://carla.readthedocs.io/en/latest/build_linux/
Ros2 (Foxy Installed through binary packages)
Python 3.8

Here is my $PYTHONPATH: /opt/ros/foxy/lib/python3.8/site-packages

When I run colcon build, I get this error

Starting >>> carla_msgs
Starting >>> ros_compatibility
Starting >>> carla_common
Starting >>> carla_ros_scenario_runner_types
--- stderr: carla_msgs
AttributeError in template '/home/mike/ros2_humble/install/rosidl_generator_c/share/rosidl_generator_c/cmake/../resource/msg__struct.h.em': 'Structure' object has no attribute 'get_comment_lines'
AttributeError when expanding 'idl__struct.h.em' into '/home/mike/carla-ros-bridge/build/carla_msgs/rosidl_generator_c/carla_msgs/msg/detail/carla_bounding_box__struct.h': 'Structure' object has no attribute 'get_comment_lines'
Error processing idl file: /home/mike/carla-ros-bridge/build/carla_msgs/rosidl_adapter/carla_msgs/msg/CarlaBoundingBox.idl
Traceback (most recent call last):
File "/home/mike/ros2_humble/install/rosidl_generator_c/share/rosidl_generator_c/cmake/../../../lib/rosidl_generator_c/rosidl_generator_c", line 38, in
sys.exit(main())
File "/home/mike/ros2_humble/install/rosidl_generator_c/share/rosidl_generator_c/cmake/../../../lib/rosidl_generator_c/rosidl_generator_c", line 34, in main
generate_c(args.generator_arguments_file)
File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_generator_c/init.py", line 37, in generate_c
generate_files(
File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_cmake/init.py", line 96, in generate_files
raise(e)
File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_cmake/init.py", line 87, in generate_files
expand_template(
File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_cmake/init.py", line 149, in expand_template
interpreter.string(template_content, template_path, locals=data)
File "/usr/lib/python3/dist-packages/em.py", line 2391, in string
self.safe(scanner, True, locals)
File "/usr/lib/python3/dist-packages/em.py", line 2401, in safe
self.parse(scanner, locals)
File "/usr/lib/python3/dist-packages/em.py", line 2421, in parse
token.run(self, locals)
File "/usr/lib/python3/dist-packages/em.py", line 1547, in run
self.subrun(info[0][1], interpreter, locals)
File "/usr/lib/python3/dist-packages/em.py", line 1631, in subrun
token.run(interpreter, locals)
File "/usr/lib/python3/dist-packages/em.py", line 1425, in run
interpreter.execute(self.code, locals)
File "/usr/lib/python3/dist-packages/em.py", line 2595, in execute
_exec(statements, self.globals, locals)
File "", line 2, in
File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_cmake/init.py", line 198, in _expand_template
interpreter.string(content, str(template_path), kwargs)
File "/usr/lib/python3/dist-packages/em.py", line 2391, in string
self.safe(scanner, True, locals)
File "/usr/lib/python3/dist-packages/em.py", line 2401, in safe
self.parse(scanner, locals)
File "/usr/lib/python3/dist-packages/em.py", line 2421, in parse
token.run(self, locals)
File "/usr/lib/python3/dist-packages/em.py", line 1425, in run
interpreter.execute(self.code, locals)
File "/usr/lib/python3/dist-packages/em.py", line 2595, in execute
_exec(statements, self.globals, locals)
File "", line 1, in
AttributeError: 'Structure' object has no attribute 'get_comment_lines'
Exception ignored in: <function Interpreter.del at 0x7f93370e2d30>
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/em.py", line 2094, in del
File "/usr/lib/python3/dist-packages/em.py", line 2157, in shutdown
File "/usr/lib/python3/dist-packages/em.py", line 2646, in finalize
File "/usr/lib/python3/dist-packages/em.py", line 2200, in push
AttributeError: '_io.TextIOWrapper' object has no attribute 'push'
make[2]: *** [CMakeFiles/carla_msgs__rosidl_generator_c.dir/build.make:161: rosidl_generator_c/carla_msgs/msg/carla_bounding_box.h] Error 1
make[2]: *** Deleting file 'rosidl_generator_c/carla_msgs/msg/carla_bounding_box.h'
make[1]: *** [CMakeFiles/Makefile2:349: CMakeFiles/carla_msgs__rosidl_generator_c.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:141: all] Error 2
Failed <<< carla_msgs [1.12s, exited with code 2]
Aborted <<< carla_ros_scenario_runner_types [1.10s]
Aborted <<< ros_compatibility [1.26s]
Aborted <<< carla_common [1.26s]
Summary: 0 packages finished [1.56s]
1 package failed: carla_msgs
3 packages aborted: carla_common carla_ros_scenario_runner_types ros_compatibility
2 packages had stderr output: carla_msgs carla_ros_scenario_runner_types
15 packages not processed

The first fix I tried was to set the CARLA_ROOT and PYTHONPATH environment variables as recommended in this issue.

My PYTHONPATH looked like this: /opt/ros/foxy/lib/python3.8/site-packages:/opt/carla-simulator/PythonPAI/carla/dist/carla-0.9.13-py3.7-linux-x86_64.egg:/opt/carla-simulator/PythonAPI/carla

Then I ran colcon build again and go this error:

Starting >>> carla_msgs
Starting >>> ros_compatibility
Starting >>> carla_common
Starting >>> carla_ros_scenario_runner_types
Finished <<< ros_compatibility [5.78s]
Starting >>> carla_waypoint_types
Finished <<< carla_common [5.76s]
Starting >>> carla_twist_to_control
Finished <<< carla_twist_to_control [1.40s]
Starting >>> rqt_carla_control
--- stderr: carla_ros_scenario_runner_types
AttributeError in template '/home/mike/ros2_humble/install/rosidl_generator_c/share/rosidl_generator_c/cmake/../resource/msg__struct.h.em': 'Structure' object has no attribute 'get_comment_lines'
AttributeError when expanding 'idl__struct.h.em' into '/home/mike/carla-ros-bridge/build/carla_ros_scenario_runner_types/rosidl_generator_c/carla_ros_scenario_runner_types/msg/detail/carla_scenario__struct.h': 'Structure' object has no attribute 'get_comment_lines'
Error processing idl file: /home/mike/carla-ros-bridge/build/carla_ros_scenario_runner_types/rosidl_adapter/carla_ros_scenario_runner_types/msg/CarlaScenario.idl
Traceback (most recent call last):
File "/home/mike/ros2_humble/install/rosidl_generator_c/share/rosidl_generator_c/cmake/../../../lib/rosidl_generator_c/rosidl_generator_c", line 38, in
sys.exit(main())
File "/home/mike/ros2_humble/install/rosidl_generator_c/share/rosidl_generator_c/cmake/../../../lib/rosidl_generator_c/rosidl_generator_c", line 34, in main
generate_c(args.generator_arguments_file)
File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_generator_c/init.py", line 37, in generate_c
generate_files(
File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_cmake/init.py", line 96, in generate_files
raise(e)
File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_cmake/init.py", line 87, in generate_files
expand_template(
File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_cmake/init.py", line 149, in expand_template
interpreter.string(template_content, template_path, locals=data)
File "/usr/lib/python3/dist-packages/em.py", line 2391, in string
self.safe(scanner, True, locals)
File "/usr/lib/python3/dist-packages/em.py", line 2401, in safe
self.parse(scanner, locals)
File "/usr/lib/python3/dist-packages/em.py", line 2421, in parse
token.run(self, locals)
File "/usr/lib/python3/dist-packages/em.py", line 1547, in run
self.subrun(info[0][1], interpreter, locals)
File "/usr/lib/python3/dist-packages/em.py", line 1631, in subrun
token.run(interpreter, locals)
File "/usr/lib/python3/dist-packages/em.py", line 1425, in run
interpreter.execute(self.code, locals)
File "/usr/lib/python3/dist-packages/em.py", line 2595, in execute
_exec(statements, self.globals, locals)
File "", line 2, in
File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_cmake/init.py", line 198, in _expand_template
interpreter.string(content, str(template_path), kwargs)
File "/usr/lib/python3/dist-packages/em.py", line 2391, in string
self.safe(scanner, True, locals)
File "/usr/lib/python3/dist-packages/em.py", line 2401, in safe
self.parse(scanner, locals)
File "/usr/lib/python3/dist-packages/em.py", line 2421, in parse
token.run(self, locals)
File "/usr/lib/python3/dist-packages/em.py", line 1425, in run
interpreter.execute(self.code, locals)
File "/usr/lib/python3/dist-packages/em.py", line 2595, in execute
_exec(statements, self.globals, locals)
File "", line 1, in
AttributeError: 'Structure' object has no attribute 'get_comment_lines'
Exception ignored in: <function Interpreter.del at 0x7f3b6ba61d30>
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/em.py", line 2094, in del
File "/usr/lib/python3/dist-packages/em.py", line 2157, in shutdown
File "/usr/lib/python3/dist-packages/em.py", line 2646, in finalize
File "/usr/lib/python3/dist-packages/em.py", line 2200, in push
AttributeError: '_io.TextIOWrapper' object has no attribute 'push'
make[2]: *** [CMakeFiles/carla_ros_scenario_runner_types__rosidl_generator_c.dir/build.make:139: rosidl_generator_c/carla_ros_scenario_runner_types/msg/carla_scenario.h] Error 1
make[2]: *** Deleting file 'rosidl_generator_c/carla_ros_scenario_runner_types/msg/carla_scenario.h'
make[1]: *** [CMakeFiles/Makefile2:386: CMakeFiles/carla_ros_scenario_runner_types__rosidl_generator_c.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:141: all] Error 2
Failed <<< carla_ros_scenario_runner_types [7.27s, exited with code 2]
Aborted <<< rqt_carla_control [0.13s]
Aborted <<< carla_msgs [7.54s]
Aborted <<< carla_waypoint_types [3.79s]
Summary: 3 packages finished [12.0s]
1 package failed: carla_ros_scenario_runner_types
3 packages aborted: carla_msgs carla_waypoint_types rqt_carla_control
3 packages had stderr output: carla_msgs carla_ros_scenario_runner_types carla_waypoint_types
12 packages not processed

It seems like the build got farther but there is still an issue. I believe it might be a python version issue since Ubuntu 20.04 uses python3.8 by default and the carla egg seems to use python3.7. Would I be correct in thinking this?

I also attempted to build carla from source but was unable to make the PythonAPI because it requires clang8 and Ubuntu20.04 comes with clang10. I then installed carla-simulator/focal via apt which is what I am using. Could this have anything to do with my issue?

I was able to find the fix to this issue, but it comes with more questions. I had installed from source ros2 Humble Hawksbill in my home directory so removing it was the fix.

Many versions of Ros are supposed to be able to work along side each other. I didn't include this in the main question, but my $PATH looked like this: /opt/ros/foxy/bin:/home/mike/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-17-oracle/bin:/usr/lib/jvm/java-17-oracle/db/bin
My question then is how does colcon find ros2_humble in my home directory when it wasn't in $PATH? Shouldn't it use environment variables to locate ros?