Importing ROS Messages in Python
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:
- Do I need to add an
__init__.py
to mymsg
folder to be able to importbattery.msg
? I don't entirely know pythonic standards, but it seems odd that I'd need to designatemsg
as a module. - Is this an acceptable way to structure my package? I'm trying to be standards-compliant, but I don't know if I am!