AttributeError: 'module' object has no attribute 'TransformBroadcaster'

asked 2020-02-05 07:11:17 -0500

Vini71 gravatar image

updated 2020-02-05 08:02:03 -0500

gvdhoorn gravatar image

Hi I am having the following error when I try to publish a broadcast for a model which I have and a listener for their TF

marcus@marcus-Aspire-VX5-591G:~/catkin_ws$ roslaunch car_description basic_car_follow_marcus.launch 
... logging to /home/marcus/.ros/log/47d27328-4816-11ea-b48c-c82158f9534e/roslaunch-marcus-Aspire-VX5-591G-8700.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://marcus-Aspire-VX5-591G:34181/

SUMMARY
========

PARAMETERS
 * /rosdistro: kinetic
 * /rosversion: 1.12.14

NODES
  /
    basic_car_tf_listener_node (car_description/basic_car_tf_listener.py)
    marcus_tf_broadcaster_node (car_description/marcus_tf_broadcaster.py)

ROS_MASTER_URI=http://localhost:11311

process[marcus_tf_broadcaster_node-1]: started with pid [8717]
process[basic_car_tf_listener_node-2]: started with pid [8718]
Traceback (most recent call last):
  File "/home/marcus/catkin_ws/src/car_description/scripts/basic_car_tf_listener.py", line 11, in <module>
    listener = tf.TransformListener()
AttributeError: 'module' object has no attribute 'TransformListener'
[INFO] [1580907826.365022, 0.000000]: Retrieveing Model indexes 
[INFO] [1580907826.390081, 704.509000]: Final robots_index_dict =  {'marcus': 1} 
[INFO] [1580907826.394515, 704.513000]: Error, The _robots_models_dict is not ready = 'marcus'
[basic_car_tf_listener_node-2] process has died [pid 8718, exit code 1, cmd /home/marcus/catkin_ws/src/car_description/scripts/basic_car_tf_listener.py basic_car marcus __name:=basic_car_tf_listener_node __log:=/home/marcus/.ros/log/47d27328-4816-11ea-b48c-c82158f9534e/basic_car_tf_listener_node-2.log].
log file: /home/marcus/.ros/log/47d27328-4816-11ea-b48c-c82158f9534e/basic_car_tf_listener_node-2*.log
[INFO] [1580907827.396160, 705.510000]: Ready..Starting to Publish TF data now...
Traceback (most recent call last):
  File "/home/marcus/catkin_ws/src/car_description/scripts/marcus_tf_broadcaster.py", line 44, in <module>
    publisher_of_tf()
  File "/home/marcus/catkin_ws/src/car_description/scripts/marcus_tf_broadcaster.py", line 38, in publisher_of_tf
    handle_turtle_pose(pose_now, robot_name)
  File "/home/marcus/catkin_ws/src/car_description/scripts/marcus_tf_broadcaster.py", line 9, in handle_turtle_pose
    br = tf.TransformBroadcaster()
AttributeError: 'module' object has no attribute 'TransformBroadcaster'
[marcus_tf_broadcaster_node-1] process has died [pid 8717, exit code 1, cmd /home/marcus/catkin_ws/src/car_description/scripts/marcus_tf_broadcaster.py __name:=marcus_tf_broadcaster_node __log:=/home/marcus/.ros/log/47d27328-4816-11ea-b48c-c82158f9534e/marcus_tf_broadcaster_node-1.log].
log file: /home/marcus/.ros/log/47d27328-4816-11ea-b48c-c82158f9534e/marcus_tf_broadcaster_node-1*.log
all processes on machine have died, roslaunch will exit
shutting down processing monitor...
... shutting down processing monitor complete

I have intalled Tf and TF2 , the geometry pkgs...but I don't know to repair this error.

edit retag flag offensive close merge delete

Comments

Could you show us some code?

I'm wondering whether you have your imports setup correctly.

Please also note that tf (as in: version 1) is deprecated and you should really be using tf2.

gvdhoorn gravatar image gvdhoorn  ( 2020-02-05 07:27:15 -0500 )edit

It's simply because there is no attribute with the name you called, for that Object. This means that you got the error when the "module" does not contain the method you are calling. But it is evident that the method is there, which leads to believe that may be the method was added by you in the python source code after you had already imported the file (module). Or, some times packages get deprecated and they rename some functions. If that is true, then you may want to exit and reimport the module once again to be able to access the new method.

You can do it in another way to reimport the module with changes without having to exit the interpreter is to do the following:

import importlib
importlib.reload(myModule)
geraldwarp gravatar image geraldwarp  ( 2020-09-14 00:12:09 -0500 )edit