Thong Chan
Thong Chan

Reputation: 11

ImportError: No module named mavros_msgs.msg

Im using ros kinetic and Ubuntu 16.04

Im trying to do run this project but not running inside a docker container. I had copied the whole gym file from container to my desktop and try to run outside the docker container.

After i had done

user@user-HP-Pavilion-15-Notebook-PC:~/gym/gym-gazebo/gym_gazebo/envs/installation$ bash turtlebot_setup.bash
user@user-HP-Pavilion-15-Notebook-PC:~/gym/gym-gazebo/examples/scripts_turtlebot$ python circuit2_turtlebot_lidar_qlearn.py

I get this

/usr/lib/python2.7/dist-packages/skimage/viewer/qt/__init__.py:18: UserWarning: Could not import PyQt4: ImageViewer not available!
  warnings.warn("Could not import PyQt4: ImageViewer not available!")
Could not import matplotlib -- skimage.viewer not available.
Traceback (most recent call last):
  File "circuit2_turtlebot_lidar_qlearn.py", line 25, in <module>
    env = gym.make('GazeboCircuit2TurtlebotLidar-v0')
  File "/usr/local/lib/python2.7/dist-packages/gym/envs/registration.py", line 167, in make
    return registry.make(id)
  File "/usr/local/lib/python2.7/dist-packages/gym/envs/registration.py", line 119, in make
    env = spec.make()
  File "/usr/local/lib/python2.7/dist-packages/gym/envs/registration.py", line 85, in make
    cls = load(self._entry_point)
  File "/usr/local/lib/python2.7/dist-packages/gym/envs/registration.py", line 14, in load
    result = entry_point.load(False)
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2324, in load
    return self.resolve()
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2330, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/home/thong/gym/gym-gazebo/gym_gazebo/envs/__init__.py", line 12, in <module>
    from gym_gazebo.envs.gazebo_erlecopter_hover import GazeboErleCopterHoverEnv
  File "/home/thong/gym/gym-gazebo/gym_gazebo/envs/gazebo_erlecopter_hover.py", line 14, in <module>
    from mavros_msgs.msg import OverrideRCIn
ImportError: No module named mavros_msgs.msg

And this is my turtlebot_setup.bash

#!/bin/bash

if [ -z "$GAZEBO_MODEL_PATH" ]; then
  bash -c 'echo "export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:"`pwd`/../assets/models >> ~/.bashrc'
else
  bash -c 'sed "s,GAZEBO_MODEL_PATH=[^;]*,'GAZEBO_MODEL_PATH=`pwd`/../assets/models'," -i ~/.bashrc'
fi

#Load turtlebot variables. Temporal solution
chmod +x catkin_ws/src/turtlebot_simulator/turtlebot_gazebo/env-hooks/25.turtlebot-gazebo.sh.em
bash catkin_ws/src/turtlebot_simulator/turtlebot_gazebo/env-hooks/25.turtlebot-gazebo.sh.em

#add turtlebot launch environment variable
if [ -z "$GYM_GAZEBO_WORLD_MAZE" ]; then
  bash -c 'echo "export GYM_GAZEBO_WORLD_MAZE="`pwd`/../assets/worlds/maze.world >> ~/.bashrc'
else
  bash -c 'sed "s,GYM_GAZEBO_WORLD_MAZE=[^;]*,'GYM_GAZEBO_WORLD_MAZE=`pwd`/../assets/worlds/maze.world'," -i ~/.bashrc'
fi
if [ -z "$GYM_GAZEBO_WORLD_CIRCUIT" ]; then
  bash -c 'echo "export GYM_GAZEBO_WORLD_CIRCUIT="`pwd`/../assets/worlds/circuit.world >> ~/.bashrc'
else
  bash -c 'sed "s,GYM_GAZEBO_WORLD_CIRCUIT=[^;]*,'GYM_GAZEBO_WORLD_CIRCUIT=`pwd`/../assets/worlds/circuit.world'," -i ~/.bashrc'
fi
if [ -z "$GYM_GAZEBO_WORLD_CIRCUIT2" ]; then
  bash -c 'echo "export GYM_GAZEBO_WORLD_CIRCUIT2="`pwd`/../assets/worlds/circuit2.world >> ~/.bashrc'
else
  bash -c 'sed "s,GYM_GAZEBO_WORLD_CIRCUIT2=[^;]*,'GYM_GAZEBO_WORLD_CIRCUIT2=`pwd`/../assets/worlds/circuit2.world'," -i ~/.bashrc'
fi
if [ -z "$GYM_GAZEBO_WORLD_CIRCUIT2C" ]; then
  bash -c 'echo "export GYM_GAZEBO_WORLD_CIRCUIT2C="`pwd`/../assets/worlds/circuit2c.world >> ~/.bashrc'
else
  bash -c 'sed "s,GYM_GAZEBO_WORLD_CIRCUIT2C=[^;]*,'GYM_GAZEBO_WORLD_CIRCUIT2C=`pwd`/../assets/worlds/circuit2c.world'," -i ~/.bashrc'
fi
if [ -z "$GYM_GAZEBO_WORLD_ROUND" ]; then
  bash -c 'echo "export GYM_GAZEBO_WORLD_ROUND="`pwd`/../assets/worlds/round.world >> ~/.bashrc'
else
  bash -c 'sed "s,GYM_GAZEBO_WORLD_ROUND=[^;]*,'GYM_GAZEBO_WORLD_ROUND=`pwd`/../assets/worlds/round.world'," -i ~/.bashrc'
fi

#copy altered urdf model
cp -r ../assets/urdf/kobuki_urdf/urdf/ catkin_ws/src/kobuki/kobuki_description

#copy laser mesh file
cp ../assets/meshes/lidar_lite_v2_withRay.dae catkin_ws/src/kobuki/kobuki_description/meshes

exec bash # reload bash

What should I do to solve this? and How do I properly install the package?

Upvotes: 0

Views: 3519

Answers (1)

Mohammad Ali
Mohammad Ali

Reputation: 574

Check To See If U Have The Msg In Your Env-Path With rosmsg list.

if You Don't Have It There Then It's Your Path Problem Try sourcing The setup.bash Of Main ROS folder(or if U compiled it from source setup.bash from Your Workspace)

EDIT 1

you can install Mavros (and Mavros_msgs) using apt install ros-kinetic-mavros ros-kinetic-mavros-msgs

Upvotes: 1

Related Questions