-
Notifications
You must be signed in to change notification settings - Fork 17
Description
Two problems I noticed trying to port the first tutorial (creating nodes with bride, http://wiki.ros.org/bride/Tutorials/Creating-nodes-with-BRIDE) to python:
For the sake of simplicity I will report all paths as configured on my machine which are /home/uhr-se/catkin_ws and /home/uhr-se/catkin_ws/src/talker as workspace and package path respectively.
- The created cfg file in
/home/uhr-se/catkin_ws/src/talker/cfg/talker.cfgcontained a syntax error:
gen.add("word", int_t, 0, "Autogenerated parameter based on model.", , -100, 100)
The fith parameter is missing, which generated the following error when running catkin_make:
[...]
[100%] [100%] Built target listener_gencfg
Generating dynamic reconfigure files from cfg/talker.cfg: /home/uhr-se/catkin_ws/devel/include/talker/talkerConfig.h /home/uhr-se/catkin_ws/devel/lib/python2.7/dist-packages/talker/cfg/talkerConfig.py
File "/home/uhr-se/catkin_ws/src/talker/cfg/talker.cfg", line 8
gen.add("word", int_t, 0, "Autogenerated parameter based on model.", , -100, 100)
^
SyntaxError: invalid syntax
make[2]: *** [/home/uhr-se/catkin_ws/devel/include/talker/talkerConfig.h] Error 1
make[1]: *** [talker/CMakeFiles/talker_gencfg.dir/all] Error 2
make: *** [all] Error 2
Invoking "make" failed
Setting the fith parameter to an arbitrary value such as 0 resolved the issue.
- When the generated node and its package match (talker.py in the package talker), an error occurs while resolving the package. The import cfg-statement in line 6
from talker.cfg import talkerConfig as ConfigType
results in the very same node being imported again instead of the correspoding built package in/dist-packages. This leads to the following error which is caused since the cfg module (which is located in the correspondingdist-packages/talker) cannot be found:
Traceback (most recent call last):
File "/home/uhr-se/catkin_ws/src/talker/src/talker.py", line 6, in <module>
from talker.cfg import talkerConfig as ConfigType
File "/home/uhr-se/catkin_ws/src/talker/src/talker.py", line 6, in <module>
from talker.cfg import talkerConfig as ConfigType
ImportError: No module named cfg
To see why that happens one can inspect the values of sys.path and look at the module path of 'talker':
import sys, talker
print sys.path[ :2 ]
print 'Module talker', talker
sys.exit( 1 )
# Output:
# ['/home/uhr-se/catkin_ws/src/talker/src', '/home/uhr-se/catkin_ws/devel/lib/python2.7/dist-packages']
# Module talker <module 'talker' from '/home/uhr-se/catkin_ws/src/talker/src/talker.py'>
The module talker should actually be imported from the second path instead of the first path. The node runs as expected if one reverses the order of the first two paths:
sys.path[:2]=sys.path[:2][::-1]
import talker
print 'Module talker', talker
# Output:
# Module talker <module 'talker' from '/home/uhr-se/catkin_ws/devel/lib/python2.7/dist-packages/talker/__init__.pyc'>