I'm going to make a robot simulator.
The simulator is mostly made in Python, except the controller part.
Controller is made in Cpp.
For each timestep, In simulator, robot model sends its states(motor angle, etc...) to a python method that wraps all the codes that generates desired action according to a learned policy, that the robot has to follow. The method uses openai Gym and Machine learning codes. Then the Controller part made in Cpp gets the desired action as input and should output the specific commands that can be fed to Robot's motors.
Question is, what is the best way to use Cpp code with python. I hope that I can just send the output from Policy part to Contoller and Controller outputs the motor commands. I just want to use cpp controller part like function, like seperate black-box if possible.
Python is interpreter language, and cpp is compiler language. Google suggests some candidates like Using Cpython, Using Bootst.python or Using Pybind11. The Cpp part involves lots of #include
s which link to controller related libraries, and will be used repeatedly during each timestep. For faster computation cpp part should be compiled just once I think.
Any suggestion is welcomed!