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

ImportError: No module named tf

asked 2015-03-13 16:27:32 -0500

kgnkwmr gravatar image

updated 2015-03-14 06:55:35 -0500

gvdhoorn gravatar image

I am writing a node that involves calculating the distance from the PR2's left wrist to a point in space, and publishing that distance. The point is in the base frame, so to make calculations easier I'm attempting to change the frame of the point. However, when I run it, nothing is published (when I use rostopic echo, it indicates that the parameter is not being published. Essentially it doesn't know that it exists). I tried using rosrun on the file and it errors saying

ImportError: No module named tf

Here's what the beginning of my code looks like

#!/usr/bin/env python

# This publisher will calculated the distance of an object
# from PR2
import roslib
roslib.load_manifest('PR2_assignment0')
import rospy
import sys
from std_msgs.msg import String
import tf

from std_msgs.msg import Float64
from geometry_msgs.msg import PointStamped

I've made many modifications but it still does not seem to work (I've checked threads with similar problems but their solutions aren't working). Other files with a similar format work, but mine doesn't...

I haven't tried the code without the tf frame, so I'll try that out for now and see if it sheds light on some things.

Any suggestions?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2019-08-14 16:55:07 -0500

Try installing tf package using sudo apt-get install ros-<ros-distro>-tf.

edit flag offensive delete link more
0

answered 2015-03-16 13:01:30 -0500

imcmahon gravatar image

From your description, it sounds like your Python script is being called from a workspace without your ROS Python path set properly. Make sure you have built your catkin workspace with catkin_make and then source your devel/setup.bash to set your environment. You can verify the environment is then set with env | grep PYTHON

foo@bar:~/ros_ws$ catkin_make
foo@bar:~/ros_ws$ source devel/setup.bash 
foo@bar:~/ros_ws$ env | grep PYTHON
PYTHONPATH=/home/foo/ros_ws/devel/lib/python2.7/dist-packages:/opt/ros/indigo/lib/python2.7/dist-packages:

Just a sidenote, if you are using a catkin workspace, you won't need import roslib and roslib.load_manifest('PR2_assignment0'). See the answer for the question What does roslibload_manifest do? for a more detailed explanation.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-03-13 16:27:32 -0500

Seen: 9,798 times

Last updated: Aug 14 '19