Rospy import dancing

I would like to share a story about how I killed a couple of hours recently. I write on rospy a small architecture to work with a robot. Since there are no good examples and I’m not an expert in the python, without thinking twice, I added the path to the project (let it be ~/work/src/coolp) in PYTHONPATH. Then I added empty directly to the root of proper packages ( eg. coolp/control/__ next to the scripts that you want to import coolp/control/ and now at any place where I need this script – from control.control_arm import LeftArm.

And everything went fine until I needed to add my message. Following the instructions in the msg folder I created a file, added horrible instructions in CMakeLists.txt and package.xml, and made catkin_make. Everything looks fine – I can see a Python file with a generated message in ~/work/devel/lib/python2.7/dist-packages/control/msg. In pycharm, everything is also fine , message is seen ( of course prior to that I set it upadded Interpreter Path to ~/work/devel/lib/python2.7/dist-packages in settings->project interpreter->2.7.12->More ..- >Show paths. But when I try to run – “No module named msg”.

I’m not going to make you feel bored, it’s all about It turns out that the control in src and control in devel (actually is generated with the same name as the package in src) have the same paths for the python and it’s goes crazy of such impudence. When I delete – everything is ok, generated msg is seen, only scripts in src are not seen. Found out – there is an approach with the help of, but there still catkin_install should be done (now I do not run any catkins for the python) and in any case to support another one builder in the 21st century – count me out! So I put msg in a separate package (like coolp/control_msg/msg..) and move on. If you have any thoughts where I was wrong or maybe you just can give a clue – you are very welcomed to comment =)


0 0 vote
Рейтинг статьи
0 комментариев
Inline Feedbacks
View all comments