Ask Your Question
1

tf AttributeError: 'module' object has no attribute 'transformations'

asked 2014-05-27 06:46:00 -0600

updated 2014-05-27 06:49:28 -0600

I'm using roscopter package to get the imu data from my quadcopter.

It worked well but I got error when running it today.

rosrun roscopter imu_transform_publish.py

[ERROR] [WallTime: 1401208503.130663] bad callback: <function imu_callback at 0x18c9578>
Traceback (most recent call last):
File "/opt/ros/hydro/lib/python2.7/dist-packages/rospy/topics.py", line 682, in _invoke_callback
cb(msg)
File "/home/aqua/ros_catkin/src/roscopter/scripts/imu_transform_publish.py", line 75, in imu_callback
q = tf.transformations.quaternion_from_euler(roll,pitch,yaw)
AttributeError: 'module' object has no attribute 'transformations'

import tf

q = tf.transformations.quaternion_from_euler(roll,pitch,yaw)

According to the tf tutorial, tf.transformations.quaternion_from_euler(roll,pitch,yaw) should be correct, so I'm confused where the problem is.

also for the tf module, it locates in my catkin workspace:

Python 2.7.4 (default, Sep 26 2013, 03:20:26) 
[GCC 4.7.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tf
>>> print tf
<module 'tf' from '/home/aqua/ros_catkin/devel/lib/python2.7/dist-packages/tf/__init__.pyc'>
edit retag flag offensive close merge delete

Comments

Hi, i am new to ros and just met the same problem. Just download a new tf-file from github as you did. But what should i do afterwards? Would you please explain more about integrating this file into catkin_ws? I use catkin_make rather than rosbuild

Jian1994 gravatar imageJian1994 ( 2019-11-25 16:34:41 -0600 )edit

@Jian1994 just put it into your catkin workspace

lanyusea gravatar imagelanyusea ( 2019-11-25 20:34:59 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-05-27 08:11:58 -0600

tfoote gravatar image

updated 2014-05-27 08:12:32 -0600

I cannot reproduce this problem in source:

In [1]: import tf
In [2]: tf.transformations.quaternion_from_euler(1,2,3)
Out[2]: array([-0.71828702,  0.31062245,  0.44443511,  0.43595284])
In [3]: print(tf)
<module 'tf' from '/home/tfoote/work/geometry_experimental/devel/lib/python2.7/dist-packages/tf/__init__.pyc'>

Or from debian packages:

In [1]: import tf
In [2]: tf.transformations.quaternion_from_euler(1,2,3)
Out[2]: array([-0.71828702,  0.31062245,  0.44443511,  0.43595284])
In [3]: print(tf)
<module 'tf' from '/opt/ros/hydro/lib/python2.7/dist-packages/tf/__init__.pyc'>

I'd suggest that you make sure that your environment is clean and the referenced init script is pointing to a valid source directory.

edit flag offensive delete link more

Comments

I still failed... Could you help check what is inside folder `home/tfoote/work/geometry_experimental/devel/lib/python2.7/dist-packages/tf`? beside __init__.py __init__.pyc I found the `msg` and `srv` folders but both are empty.

lanyusea gravatar imagelanyusea ( 2014-05-27 08:20:49 -0600 )edit
1

thanks. I downloaded https://github.com/ros/geometry/tree/hydro-devel/tf to my catkinWorkspace and build it, it works.

lanyusea gravatar imagelanyusea ( 2014-05-27 08:38:54 -0600 )edit

That suggests that you have not fully built the package. The generated messages are required and your tf library is probably missing the compiled so files too making the import malfunction. Although you're using the python pieces, some of them depend on compiled and generated code from the build step.

tfoote gravatar imagetfoote ( 2014-05-27 08:38:54 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-05-27 06:46:00 -0600

Seen: 2,501 times

Last updated: May 27 '14