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

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

Hi,

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.

EDIT:

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: -->
  <build_depend>message_generation</build_depend> 
  <!-- Use buildtool_depend for build tool packages: -->
  <!--   <buildtool_depend>catkin</buildtool_depend> -->
  <!-- Use run_depend for packages you need at runtime: -->
  <run_depend>message_runtime</run_depend> 
  <!-- Use test_depend for packages you need only for testing: -->
  <!--   <test_depend>gtest</test_depend> -->
  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>control_msgs</build_depend>
  <build_depend>rospy</build_depend>
  <build_depend>mongo_ros</build_depend>
  <build_depend>std_msgs</build_depend>
  <build_depend>tf</build_depend>
  <run_depend>control_msgs</run_depend>
  <run_depend>mongo_ros</run_depend>
  <run_depend>rospy</run_depend>
  <run_depend>std_msgs</run_depend>
  <run_depend>tf</run_depend>

And CMakeList.txt:

find_package(catkin REQUIRED COMPONENTS
  control_msgs
  rospy
  std_msgs
  tf
  #mongo_ros
)

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:

    mongo_rosConfig.cmake
    mongo_ros-config.cmake

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

Comments

What is your ``$PYTHONPATH``?

joq gravatar image joq  ( 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" http://bit.ly/1bV8ugF

kms-dev gravatar image kms-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 image joq  ( 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: "http://wiki.ros.org/warehousewg/Tutorials/Using 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 image kms-dev  ( 2013-10-24 08:08:14 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

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.

Regards.

edit flag offensive delete link more

Comments

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

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

Yes, I have the same functionality as with mongo_ros

kms-dev gravatar image kms-dev  ( 2013-10-31 11:57:11 -0500 )edit
2

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

Comments

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 C++...so I'll try pymongo. I will comment my results soon. Thanks for the help.

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

Question Tools

Stats

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

Seen: 690 times

Last updated: Oct 31 '13