wkentaro / octomap-python

Python binding of the OctoMap library.
81 stars 28 forks source link

Unable to read octree from .bt file #10

Open Abhishek-EE opened 2 years ago

Abhishek-EE commented 2 years ago

Hello, I was trying to use octomap-python to read the binary tree stored in .bt file but it throws this error, the error logs are as follows,

File "/Users/abhishekranjansingh/opt/anaconda3/envs/path-generator/lib/python3.9/runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "/Users/abhishekranjansingh/opt/anaconda3/envs/path-generator/lib/python3.9/runpy.py", line 87, in _run_code exec(code, run_globals) File "/Users/abhishekranjansingh/.vscode/extensions/ms-python.python-2022.0.1814523869/pythonFiles/lib/python/debugpy/__main__.py", line 45, in <module> cli.main() File "/Users/abhishekranjansingh/.vscode/extensions/ms-python.python-2022.0.1814523869/pythonFiles/lib/python/debugpy/../debugpy/server/cli.py", line 444, in main run() File "/Users/abhishekranjansingh/.vscode/extensions/ms-python.python-2022.0.1814523869/pythonFiles/lib/python/debugpy/../debugpy/server/cli.py", line 285, in run_file runpy.run_path(target_as_str, run_name=compat.force_str("__main__")) File "/Users/abhishekranjansingh/opt/anaconda3/envs/path-generator/lib/python3.9/runpy.py", line 268, in run_path return _run_module_code(code, init_globals, run_name, File "/Users/abhishekranjansingh/opt/anaconda3/envs/path-generator/lib/python3.9/runpy.py", line 97, in _run_module_code _run_code(code, mod_globals, init_globals, File "/Users/abhishekranjansingh/opt/anaconda3/envs/path-generator/lib/python3.9/runpy.py", line 87, in _run_code exec(code, run_globals) File "/Users/abhishekranjansingh/dev/cptsp-solver/cptsp_solver/main.py", line 41, in <module> octree = octomap.OcTree("AIR_A320_200.bt") File "octomap/octomap.pyx", line 322, in octomap.OcTree.__cinit__ TypeError: expected bytes, str found

When i try using readBinary(string) function it says: Traceback (most recent call last): File "<string>", line 1, in <module> File "octomap[/octomap.pyx]()", line 439, in octomap.OcTree.readBinary TypeError: startswith first arg must be str or a tuple of str, not bytes

If anyone has any alternative to my current approach the help would be highly appreciated.

wkentaro commented 2 years ago

Can you give a sample .bt file to debug?

Abhishek-EE commented 2 years ago

Hi @wkentaro, Thanks for such quick response. Sure, here is the link for the file https://drive.google.com/file/d/1pWoAS4JcN3GUg5wmmkHvUXw-kzPGDHhy/view?usp=sharing

wkentaro commented 2 years ago

Not ideal, but you can use .encode() as a workaround.

octree = octomap.OcTree("./AIR_A320_200.bt".encode())
Abhishek-EE commented 2 years ago

Thanks for the being so apt, this works. I think the readBinary function would also work if I encode the input.