0
$\begingroup$

Rosanswers logo

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.


Originally posted by brice rebsamen on ROS Answers with karma: 1001 on 2011-08-25

Post score: 0


Original comments

Comment by brice rebsamen on 2011-09-04:
And I confirm: if I run the rosserial_python from a different directory than my package directory, it works.

Comment by brice rebsamen on 2011-09-04:
I mailed you the whole package. the message definition is in the msg folder, when I run rosmake, it creates a msg_gen folder with the cpp and lisp definitions, but the python message definition go to src/lowlevel/msg. Is that wrong? How can I fix?

Comment by adasta on 2011-09-03:
I am not sure if I understand what you just said: ", lowlevel.msg is not found because it is in the src subdirectory" Msg descriptions need to be put in the msg folder. Python =msg generator looks there for the message. Could you just email your packag/code? [email protected]

Comment by brice rebsamen on 2011-09-03:
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...

Comment by brice rebsamen on 2011-09-03:
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.

Comment by brice rebsamen on 2011-09-03:
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.

Comment by brice rebsamen on 2011-09-03:
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

Comment by adasta on 2011-09-01:
could you post your arduino code?

Comment by brice rebsamen on 2011-08-31:
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...

Comment by brice rebsamen on 2011-08-25:
Done: a publisher (Bool) and a subscriber (FLoat64). It works: they are reported by the python_node alright.

Comment by adasta on 2011-08-25:
In that same program, could you add a hello world publisher just to make sure that everything else is working correctly?

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by adasta with karma: 508 on 2011-09-05

This answer was ACCEPTED on the original site

Post score: 2

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.