Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 49

Importing ROS Messages in Python

$
0
0
I'm using ROS as middleware to connect my model (in Python) and my view (in JS), so I want to keep my Python code as separate as possible from ROS-related code. My directory structure looks like: . |____CMakeLists.txt |____cops_and_robots | |______init__.py | |____Cop.py | |____Map.py | |____MapObj.py | |____Robot.py | |____test | | |____unit | | | |______init__.py | | | |____moveTest.py |____msg | |____battery.msg | |____cmd.msg |____package.xml |____README.txt |____scripts | |____status_talker.py | |____websocket_interface.py |____setup.py I'm trying to import `battery.msg` from my `status_talker.py` script, but Python doesn't work too well with relative imports. I have two questions: 1. Do I need to add an `__init__.py` to my `msg` folder to be able to import `battery.msg`? I don't entirely know pythonic standards, but it seems odd that I'd need to designate `msg` as a module. 2. Is this an acceptable way to structure my package? I'm trying to be standards-compliant, but I don't know if I am!

Viewing all articles
Browse latest Browse all 49

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>