[ROS2] Sourcing colcon-generated setup.bash includes ROS1 catkin workspace
Hello,
I have experience with ROS1, and now I am learning ROS2. I installed ROS2 eloquent through the debian repos, set up my workspace with colcon following the tutorials, and now I am in the "Writing a simple publisher and subscriber (Python)" tutorial. When running the publisher node, I get the error:
AttributeError: type object 'type' has no attribute '_TYPE_SUPPORT' This might be a ROS 1 message type but it should be a ROS 2 message type. Make sure to source your ROS 2 workspace after your ROS 1 workspace.
According to google, this is due to the PYTHONPATH environment variable. However, I noticed the error only occurs when sourcing the "install/setup.bash" script generated by the "colcon build" command. Investigating the colcon-generated script, I find it is also pointing to my CATKIN workspace (I have ROS melodic installed):
# source chained prefixes
# setting COLCON_CURRENT_PREFIX avoids determining the prefix in the sourced script
COLCON_CURRENT_PREFIX="/opt/ros/melodic"
_colcon_prefix_chain_bash_source_script "$COLCON_CURRENT_PREFIX/local_setup.bash"
# setting COLCON_CURRENT_PREFIX avoids determining the prefix in the sourced script
COLCON_CURRENT_PREFIX="/home/renan/catkin_ws/devel"
_colcon_prefix_chain_bash_source_script "$COLCON_CURRENT_PREFIX/local_setup.bash"
# setting COLCON_CURRENT_PREFIX avoids determining the prefix in the sourced script
COLCON_CURRENT_PREFIX="/opt/ros/eloquent"
_colcon_prefix_chain_bash_source_script "$COLCON_CURRENT_PREFIX/local_setup.bash"
Commenting the " COLCON_CURRENT_PREFIX="/opt/ros/melodic" " and " COLCON_CURRENT_PREFIX="/home/renan/catkin_ws/devel" " lines, and resourcing the install/setup.bash file, the python publisher node runs fine.
What could be the problem here? I don't know if this is typical for ROS2, but it seems to be causing confusion with the message definitions in ROS2.
Thanks in advance.