tf module suddently not working anymore
Hello,
I have been working with Gazebo and the tf libraries one day, and the next day, the tf library seems to have issues. I am not able to run Gazebo properly and load robot models and I could not even import the tf module in Python anymore.
I run ROS Melodic on Ubuntu 18.04 (actually Pop!_OS) on an Intel i5 10th gen CPU, no GPU.
I do not know, what lead to this issue.
I tried to uninstall the ros-melodic-tf package which then removed many other packages. After re-installing them, it still doesn't work.
I then downloaded the tf ROS package from the GitHub repo and added it to the catkinws and make a `catkinmake`. Now, I can import tf in Python again, but I can't run Gazebo properly nor can I use rqttftree.
When I run rosrun rqt_tf_tree rqt_tf_tree
, I get the following error:
rosrun rqt_tf_tree rqt_tf_tree
RosPluginProvider.load(rqt_tf_tree/RosTfTree) exception raised in __builtin__.__import__(rqt_tf_tree.tf_tree, [RosTfTree]):
Traceback (most recent call last):
File "/opt/ros/melodic/lib/python2.7/dist-packages/rqt_gui/ros_plugin_provider.py", line 80, in load
attributes['module_name'], fromlist=[attributes['class_from_class_type']], level=0)
File "/opt/ros/melodic/lib/python2.7/dist-packages/rqt_tf_tree/tf_tree.py", line 39, in <module>
from tf2_msgs.srv import FrameGraph
ImportError: No module named srv
PluginManager._load_plugin() could not load plugin "rqt_tf_tree/RosTfTree":
Traceback (most recent call last):
File "/opt/ros/melodic/lib/python2.7/dist-packages/qt_gui/plugin_handler.py", line 102, in load
self._load()
File "/opt/ros/melodic/lib/python2.7/dist-packages/qt_gui/plugin_handler_direct.py", line 55, in _load
self._plugin = self._plugin_provider.load(self._instance_id.plugin_id, self._context)
File "/opt/ros/melodic/lib/python2.7/dist-packages/qt_gui/composite_plugin_provider.py", line 72, in load
instance = plugin_provider.load(plugin_id, plugin_context)
File "/opt/ros/melodic/lib/python2.7/dist-packages/qt_gui/composite_plugin_provider.py", line 72, in load
instance = plugin_provider.load(plugin_id, plugin_context)
File "/opt/ros/melodic/lib/python2.7/dist-packages/rqt_gui_py/ros_py_plugin_provider.py", line 61, in load
return super(RosPyPluginProvider, self).load(plugin_id, plugin_context)
File "/opt/ros/melodic/lib/python2.7/dist-packages/qt_gui/composite_plugin_provider.py", line 72, in load
instance = plugin_provider.load(plugin_id, plugin_context)
File "/opt/ros/melodic/lib/python2.7/dist-packages/rqt_gui/ros_plugin_provider.py", line 90, in load
raise e
ImportError: No module named srv
Does anyone know how I can fix this issue?
When I search on google for this issue, I mostly find questions about rosservices or Python modules. I can't find anything about a module called srv
.
Please let me know when I need to provide more info.
With kind regards,
Dave
Asked by dave on 2021-08-09 16:03:25 UTC
Answers
After checking all the suggestions made by Mike Scheutzow, I finally solved the issue by removing all the content inside the ~/catkin_ws/devel/
and ~/catkin_ws/build/
directories and ran catkin_make
again and now it works.
Asked by dave on 2021-08-10 09:01:50 UTC
Comments
I could find the following forum entry, but it was not very useful.
https://answers.ros.org/question/271274/import-error-no-module-named-srv/
Asked by dave on 2021-08-09 16:06:08 UTC
Do you have ros-melodic-tf2-msgs installed from apt?
Also, this could be a conflict between python2 and python3. Please show us the output from these command line commands:
Asked by Mike Scheutzow on 2021-08-09 18:28:39 UTC
Hi Mike,
Yes, ros-melodic-tf2-msgs was already installed.
echo $PATH
gives me:Then:
echo $PYTHONPATH
Gives me:
/home/dave/catkin_ws/devel/lib/python2.7/dist-packages:/opt/ros/melodic/lib/python2.7/dist-packages
And finally,
python --version
gives me:Asked by dave on 2021-08-10 04:49:13 UTC
All of that looks good. Here are some less common things to check:
tf2_msgs
ros-package in yourcatkin_ws/src
tree?devel
andbuild
directories incatkin_ws
?Verify that this file exists on your system:
/opt/ros/melodic/lib/python2.7/dist-packages/tf2_msgs/srv/_FrameGraph.py
Asked by Mike Scheutzow on 2021-08-10 07:16:37 UTC
For 1 and 3, I checked. There was no tf2_msgs package conflicting and the file
/opt/ros/melodic/lib/python2.7/dist-packages/tf2_msgs/srv/_FrameGraph.py
exists.After deleting all in the devel and build directories and re-running catkin_make, the rqt_tf_tree works again. Thanks a lot for this suggestion, I wouldn't have come up with that idea in the near future.
Asked by dave on 2021-08-10 09:00:07 UTC