ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

tf module suddently not working anymore

asked 2021-08-09 16:03:25 -0500

dave gravatar image

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 catkin_ws and make a catkin_make. Now, I can import tf in Python again, but I can't run Gazebo properly nor can I use rqt_tf_tree.

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

edit retag flag offensive close merge delete

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/

dave gravatar image dave  ( 2021-08-09 16:06:08 -0500 )edit

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:

echo $PATH
echo $PYTHONPATH
python   --version
Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-08-09 18:28:39 -0500 )edit

Hi Mike,

Yes, ros-melodic-tf2-msgs was already installed.

echo $PATH gives me:

/home/dave/catkin_ws/devel/bin:/opt/ros/melodic/bin:/home/dave/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

Then: echo $PYTHONPATH

Gives me:

echo $PYTHONPATH

/home/dave/catkin_ws/devel/lib/python2.7/dist-packages:/opt/ros/melodic/lib/python2.7/dist-packages

And finally, python --version gives me:

Python 2.7.17
dave gravatar image dave  ( 2021-08-10 04:49:13 -0500 )edit
1

All of that looks good. Here are some less common things to check:

  1. Is there a conflicting tf2_msgs ros-package in your catkin_ws/src tree?
  2. Sometimes catkin gets confused by errors from earlier compile attempts. Have you tried deleting the top-level devel and build directories in catkin_ws?
  3. Verify that this file exists on your system:

    /opt/ros/melodic/lib/python2.7/dist-packages/tf2_msgs/srv/_FrameGraph.py

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-08-10 07:16:37 -0500 )edit

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.

dave gravatar image dave  ( 2021-08-10 09:00:07 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-08-10 09:01:50 -0500

dave gravatar image

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.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2021-08-09 16:03:25 -0500

Seen: 325 times

Last updated: Aug 10 '21