anthonygardner / plant

0 stars 0 forks source link

Improve pybind11 wrapper #2

Open anthonygardner opened 1 year ago

anthonygardner commented 1 year ago

I don't like my current implementation of pybind11. The wrapper is generated such that everything goes through a .core module. In other words, calling the C++ code from Python looks like this:

from plant.core import (
sensors,
transforms,
Vector3f,
)

This import is going to be painful as the library and simulation complexity grow. I want to generate a new Python API that follows the directory tree of the source code. For example:

from plant.core import transforms
from plant.sensors import IMU
from plant.structs import Vector3f
anthonygardner commented 1 year ago

After some cleanup, I can import C++ classes and functions in a more intuitive way. Currently, the imports look like this:

from plant import sensors, structs, transforms

This allows me to write Python import statements as:

imu = sensors.IMU(0, 0)

It's closer to what I want but still not quite there. The ultimate goal is to reference the directory tree of the C++ source code, so I still need to figure out how to write pybind11 submodules such that they are interpreted by Python in the same way, e.g:

from plant.core import transforms
from plant.sensors import IMU