How to source two workspaces?
I think I still don't understand how to manage the ROS workspace.
In my case, I have two workspaces, namely, naisr_ws
and catkin_build_ws
. catkin_build_ws
is for using cv_bridge and tf in Python3 (link).
The following is my configuration and trial. I added source ~/catkin_build_ws/devel/setup.bash
at the end of ~/.bashrc
but cannot import tf
.
After sourcing it manually, it works. What is the difference...?
jinrae@costar-Oryx-Pro:~/catkin_build_ws$ tail -2 ~/.bashrc | cat
source ~/naisr_ws/devel/setup.bash
source ~/catkin_build_ws/devel/setup.bash # for python3, e.g., opencv
jinrae@costar-Oryx-Pro:~/catkin_build_ws$ python3
Python 3.6.9 (default, Jun 29 2022, 11:45:57)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/ros/melodic/lib/python2.7/dist-packages/tf/__init__.py", line 30, in <module>
from tf2_ros import TransformException as Exception, ConnectivityException, LookupException, ExtrapolationException
File "/opt/ros/melodic/lib/python2.7/dist-packages/tf2_ros/__init__.py", line 38, in <module>
from tf2_py import *
File "/opt/ros/melodic/lib/python2.7/dist-packages/tf2_py/__init__.py", line 38, in <module>
from ._tf2 import *
ImportError: dynamic module does not define module export function (PyInit__tf2)
>>>
jinrae@costar-Oryx-Pro:~/catkin_build_ws$ source ~/catkin_build_ws/devel/setup.bash
jinrae@costar-Oryx-Pro:~/catkin_build_ws$ python3
Python 3.6.9 (default, Jun 29 2022, 11:45:57)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tf
>>>
This doesnt quite address your "import tf" issue, but I don't think you can have two workspaces.
"You can’t run multiple catkin workspaces on the same session. The last to be sourced is the one that is activated."
If you are sourcing catkin_build_ws at the very last line on your bashrc then it should work the same way as if you source it explicitly. Provided you have sourced the bashrc in your current terminal.