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

ImportError: No module named gazebo_msgs.msg

asked 2015-02-12 07:04:59 -0500

EMP gravatar image

Hi,

Having installed and using the gazebo simulator environment for a while now I was wondering why when I try to import from a related package I get an error.

...
from geometry_msgs.msg import Pose,Twist #works fine
from gazebo_msgs.msg import ModelState
...

ImportError: No module named gazebo_msgs.msg
Looking through folders there doesn’t seem to be a difference between geometry_msgs and gazebo_msgs files/structure.

I want to then subscribe to the listed topic

rostopic list:
...
/gazebo/model_states
...

Then: self.subModelState = rospy.Subscriber("/gazebo/model_states",ModelState,self.DroneState)

Cheers, EMP

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2015-02-13 02:47:56 -0500

Which ROS distro are you using?

On Hydro and later, this works for me:

import rospy
from gazebo_msgs.msg import ModelState

On Fuerte, you need to import roslib, like this:

import rospy
import roslib
roslib.load_manifest('my_pkg')
from gazebo_msgs.msg import ModelState

And before you do that, you have to make sure that in my_pkg/manifest.xml, you have the line:

<depend package="gazebo_msgs"/>

Of course, in any distro you also need to have gazebo_msgs installed and on your ROS_PACKAGE_PATH; you can check by running roscd gazebo_msgs.

edit flag offensive delete link more

Comments

Thanks, I forgot about the package dependencies: I added <depend package="gazebo_msgs"/> and it worked obviously.
Thanks again

EMP gravatar image EMP  ( 2015-02-14 10:53:20 -0500 )edit

Question Tools

Stats

Asked: 2015-02-12 07:04:59 -0500

Seen: 3,592 times

Last updated: Feb 13 '15