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

rosserial and custom message: cannot load package error

asked 2011-08-25 16:26:08 -0600

brice rebsamen gravatar image

updated 2011-08-25 16:28:09 -0600

I am trying to set an arduino node. Here is the short version of the story.

I defined a custom message ("lowlevel/Arduino") and generated the appropriate header using the script for that. The arduino code compiles alright. However, I am having a problem on the python_node side: it cannot load my package 'lowlevel':

[ERROR] [WallTime: 1314328569.317936] Cannot import package : lowlevel
[ERROR] [WallTime: 1314328569.318390] Failed to parse subscriber.

However, if I run the following commands in ipython, it seems to work:

In [1]: import roslib; roslib.load_manifest("rosserial_python")
In [2]: import rospy
In [3]: roslib.load_manifest('lowlevel')
In [4]: m=__import__('lowlevel.msg')
In [5]: m.msg.Arduino
Out[5]: <class 'lowlevel.msg._Arduino.Arduino'>

What am I doing wrong? I did 'rosmake lowlevel' btw. This happens in diamondback, with ubuntu 10.04 packages.

edit retag flag offensive close merge delete

Comments

In that same program, could you add a hello world publisher just to make sure that everything else is working correctly?
adasta gravatar image adasta  ( 2011-08-25 17:12:57 -0600 )edit
Done: a publisher (Bool) and a subscriber (FLoat64). It works: they are reported by the python_node alright.
brice rebsamen gravatar image brice rebsamen  ( 2011-08-25 18:15:03 -0600 )edit
It's getting weirder: after some fiddling with the rosserial code (added a couple of loginfo) it started to work. Then I had to delete and download again my (svn-based) code, and things don't work anymore...
brice rebsamen gravatar image brice rebsamen  ( 2011-08-31 17:27:20 -0600 )edit
could you post your arduino code?
adasta gravatar image adasta  ( 2011-09-01 09:35:15 -0600 )edit
I can post my code, but where? Here we are limited to a few characters only... Besides, I don't think the code will help, you would also need my message definition, and my package structure... Please advise
brice rebsamen gravatar image brice rebsamen  ( 2011-09-03 01:37:32 -0600 )edit
Nevertheless I found something. I the load_pkg_module function, my package is actually found in the path (in_path is True at the end of the for loop). Therefore, the manifest is not loaded and the __import__ call fails. If however I do call load_manifest(package), the __import__ call succeeds.
brice rebsamen gravatar image brice rebsamen  ( 2011-09-03 01:41:21 -0600 )edit
Which makes me think: how come my package is in my path? I posit that it's because it's the current directory. So if I run from the 'lowlevel' directory then it is in the path and then load_manifest is not called. In that case, lowlevel.msg is not found because it is in the src subdirectory.
brice rebsamen gravatar image brice rebsamen  ( 2011-09-03 02:34:43 -0600 )edit
If all of that is correct (I am currently not in front of my work computer so I can't test), then it seems that testing if the package is in the path and skipping the load_manifest call if it is is not a good idea...
brice rebsamen gravatar image brice rebsamen  ( 2011-09-03 02:37:19 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2011-09-05 03:21:25 -0600

adasta gravatar image

updated 2011-09-05 03:28:37 -0600

Hi Brice,

You found a pretty tricky bug! I guess we had never tried to run rosserial_python from within the package of a custom message. Python automatically adds the working directory of a python executable to the python sys.path. As a result, when rosserial_python went to check if it had the package in its sys.path, it found the current working directory. I just updated the code to check for the src directory of the package instead of just the package name. It should work now.

Just pull the latest repo.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2011-08-25 16:26:08 -0600

Seen: 1,209 times

Last updated: Sep 05 '11