Ask Your Question

After catkin migration import error

asked 2013-10-18 01:50:24 -0500

kms-dev gravatar image

updated 2014-01-28 17:18:16 -0500

ngrennan gravatar image


I have a working project in Fuerte, but when I tried to migrate code to Groovy and catkin I see the following:

    in <module>
    import mongo_ros as mr 
ImportError: No module named mongo_ros

What I forgot?
catkin_make works correctly but in execution pyhton do not found mongo_ros package. I installed warehousewg from apt-get and "roscd mongo_ros" also works.


Thanks for your quick response. I have followed catkin overlay tutorial but the problem persists. I can do roscd mongo_ros and works correctly like in the tutorial, but in execution python do not find mongo_ros package.

May be I don't have successfully created the package configuration and depends. I follow My package.xml file contains the following:

    <!-- The *_depend tags are used to specify dependencies -->
  <!-- Dependencies can be catkin packages or system dependencies -->
  <!-- Examples: -->
  <!-- Use build_depend for packages you need at compile time: -->
  <!-- Use buildtool_depend for build tool packages: -->
  <!--   <buildtool_depend>catkin</buildtool_depend> -->
  <!-- Use run_depend for packages you need at runtime: -->
  <!-- Use test_depend for packages you need only for testing: -->
  <!--   <test_depend>gtest</test_depend> -->

And CMakeList.txt:

find_package(catkin REQUIRED COMPONENTS

I have comment mongo_ros because I obtain cmake error:

CMake Error at /opt/ros/groovy/share/catkin/cmake/catkinConfig.cmake:72 (find_package):
  Could not find a configuration file for package mongo_ros.

  Set mongo_ros_DIR to the directory containing a CMake configuration file
  for mongo_ros.  The file will have one of the following names:


Why I obtain this CMake error? It seems that the problem is related with this...

Thank you, regards.

edit retag flag offensive close merge delete


What is your ``$PYTHONPATH``?

joq gravatar imagejoq ( 2013-10-22 06:19:20 -0500 )edit

~/ros/groovy/catkin-ws/devel/lib/python2.7/dist-packages:/opt/ros/groovy/lib/python2.7/dist-packages: But in those paths mongo_ros doesn't appear. It seems that python client is not supported: "The mongo_ros package no longer provides a Python ROS client library to the DB"

kms-dev gravatar imagekms-dev ( 2013-10-22 20:02:08 -0500 )edit

That link does not work for me. Where is the source you are using for mongo_ros?

joq gravatar imagejoq ( 2013-10-24 04:24:25 -0500 )edit

Links works if you copy and paste in address bar, I don't know why. Complete link: " the Python client library" I download with 'apt-get install ros-groovy-warehousewg' Now I am working in a C++ client to DB which offers services like: insert, remove...

kms-dev gravatar imagekms-dev ( 2013-10-24 08:08:14 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2013-10-18 05:11:56 -0500

joq gravatar image

updated 2013-10-25 05:52:09 -0500

You did not set up your environment correctly. From the little information provided, it is hard to know exactly what went wrong.

Please follow the catkin overlay tutorial carefully. Perhaps you omitted one of the required source commands.

EDIT: as you mentioned, the Python interface is no longer included in the mongo_ros package. The tutorial recommends using PyMongo, instead.

Did you install PyMongo?

edit flag offensive delete link more


Yes, I have installed. But my first idea was a C++ bridge to offer services that I need. Unfortunately I'm having problems with type conversion between Python and I'll try pymongo. I will comment my results soon. Thanks for the help.

kms-dev gravatar imagekms-dev ( 2013-10-27 22:32:17 -0500 )edit

answered 2013-10-31 03:37:45 -0500

kms-dev gravatar image

I receive mongo_ros import error because is no longer included in ros-groovy-warehouse_ros package.

Developers recommend using PyMongo, so I have to adapt my code for the new interface with database. The main changes that I have to do are the following:

  1. Change imports:

    import pymongo

    from pymongo import MongoClient

  2. Different way to set up the collection:

    self.pyMongoClient = MongoClient('localhost', 27017)
    self.db = self.pyMongoClient['trajectory_db']
    self.coll = self.db['trajectories']
  3. With mongo_ros I can create a collection of ros msg like JointTrajectory, so I can insert robot trajectories without any manipulation, directly with 'insert' method:

    self.coll.insert(trajectory, self.makeMetaData(traj_name))

    With pymongo I don't know how to insert ros msg into database, encode/serialization errors were received. Then I have to develop encode/decode function to convert trajectory points in a serializable objects (array of arrays) and vice versa.

Summarizing, I have to change my insert method, otherwise only little changes are necessary.


edit flag offensive delete link more


Thanks for posting your solution. I am sure it will help others. Is it working now?

joq gravatar imagejoq ( 2013-10-31 06:00:44 -0500 )edit

Yes, I have the same functionality as with mongo_ros

kms-dev gravatar imagekms-dev ( 2013-10-31 11:57:11 -0500 )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


Asked: 2013-10-18 01:50:24 -0500

Seen: 450 times

Last updated: Oct 31 '13