Robotics StackExchange | Archived questions

Standards for Mixing C++ and Python Nodes in same Package

I'm looking for best practices for using both Python and C++ in a ROS package. Both Packages documentation and the PyStyleGuide provide a basis for directory structures, but not within the context of both C++ and Python simultaneously.

For example, imagine I have a package foo with a C++ node bar and a python-based node baz. Let's say both nodes are complex enough to require separate library source files. I'd put together a directory structure like this:

foo
├── include
│   └── bar.h
├── launch
│   ├── bar.launch
│   ├── baz.launch
│   └── foo.launch
├── msg
│   └── bar.msg
├── nodes
│   └── baz_node.py
├── src
│   ├── foo
│   │   ├── __init__.py
│   │   └── baz.py
│   ├── bar_node.cpp
│   └── bar.cpp
├── srv
│   └── baz.msg
├── CMakeLists.txt
├── package.xml
└── setup.py

I'm not a fan of mixing both C++ and python code under src, but not sure whether there are any standards/examples associated with this kind of code layout. Can anyone point me towards better solutions? Thanks!

Asked by nckswt on 2017-03-22 15:29:05 UTC

Comments

Most of the ROS packages that I've seen use a directory structure like this.

Asked by ahendrix on 2017-03-22 17:20:02 UTC

I've seen lots of packages like this, and not a fan of this too. I usually create a scripts folder beside the src folder for .py files.

Asked by Orhan on 2020-07-09 16:52:23 UTC

Answers