pathfinder-for-autonomous-navigation / psim

Six DOF flight simulator and related GNC implementations.
MIT License
4 stars 6 forks source link

Refactor pybind11 Code to Fix Configuration Bug #285

Closed kylekrol closed 3 years ago

kylekrol commented 3 years ago

See title for summary. All pybind11code was all consolidated to a single file as well to make the Python specific types more visible.

@shihaocao here is some terminal output. I believe the bug has been fixed.

@jezero ~/git/pan/psim git:(bugfix/configuration|+7) venv:(3.9.1)
% python
Python 3.9.1 (default, Dec 13 2020, 11:55:53)
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lin, psim
>>>
>>> config = psim.Configuration(['config/parameters/truth/base.txt', 'config/parameters/truth/deployment.txt', 'config/parameters/sensors/base.txt'])
>>> config['truth.leader.attitude.w'] = lin.Vector3()
>>> config['truth.leader.attitude.w']
Vector3
0
0
0
>>> exit()

Summary of Changes

Refactoring of the Configuration Object's Parameter Dictionary

The main issue behind the bug was the fact that the configuration's parameter dictionary used a reference to the parameter's string name as a key. When we overwrote a parameter in the dictionary, the referenced string key from the previous parameter was freed and potentially overwritten making it seem like that key didn't exist in the dictionary anymore. As such, the dictionary in the configuration object was updated to store a string by value as opposed to by reference.

Migration of pybind11 Code

The pybind11 code was also moved to python/psim/_psim.cpp as opposed to src/psim/_psim/** as it's not a C++ library.

shihaocao commented 3 years ago

Rip, unable to confirm

shihaocao commented 3 years ago

image

shihaocao commented 3 years ago

Changes look good to me. Verified working in PTest :)