tesseract-robotics / tesseract_python

This contains python wrappers for both Tesseract and Tesseract Planning packages
https://tesseract-robotics.github.io/tesseract_python/
28 stars 13 forks source link

TaskComposerPluginFactory constructor is not compatible with string input #56

Closed dave992 closed 1 year ago

dave992 commented 1 year ago

I am unable to construct a TaskComposerPluginFactory using a string as input:

import os

from tesseract_robotics import tesseract_common
from tesseract_robotics.tesseract_task_composer import TaskComposerPluginFactory

TESSERACT_SUPPORT_DIR = os.environ["TESSERACT_RESOURCE_PATH"]
TESSERACT_TASK_COMPOSER_DIR = os.environ["TESSERACT_TASK_COMPOSER_CONFIG_FILE"]

TASK_COMPOSER_PLUGIN_YAML = r"config/task_composer_plugins.yaml"

tesseract_common.setLogLevel(tesseract_common.CONSOLE_BRIDGE_LOG_DEBUG)

config_path = TESSERACT_TASK_COMPOSER_DIR + TASK_COMPOSER_PLUGIN_YAML
factory = TaskComposerPluginFactory(config_path)

I get the following error:

You can set logging level with TRAJOPT_LOG_THRESH. Valid values: FATAL ERROR WARN INFO DEBUG TRACE. Defaulting to ERROR
Traceback (most recent call last):
  File "/home/samxl/workspaces/tesseract_ws/src/tesseract_playground/task_composer.py", line 16, in <module>
    factory = TaskComposerPluginFactory(config_path)
  File "/home/samxl/.local/lib/python3.8/site-packages/tesseract_robotics/tesseract_task_composer/tesseract_task_composer_python.py", line 1958, in __init__
    _tesseract_task_composer_python.TaskComposerPluginFactory_swiginit(self, _tesseract_task_composer_python.new_TaskComposerPluginFactory(*args))
RuntimeError: operator[] call on a scalar

If I look at the TaskComposerPluginFactory, I find references to a constructor using a string as input and would've expected this to also be accepted.

For now, I will work around this by using a tesseract_common::FilesystemPath object as input.

dave992 commented 1 year ago

The relevant constructors that I found for the TaskComposerPluginFactory are:

Overload 2: Load plugins from file path :type config: path :param config: The config file path

Overload 3: Load plugins from string :type config: string :param config: The config string

I think the path refers to tesseract_common::FilesystemPath which is a wrapper for boost::filesystem::path based on the documentation. Would it be possible to have this compatible with Python patlib.Path?

johnwason commented 1 year ago

The use of FilesystemPath is to select the correct overload of the function/constructor. It is wrapping boost::filesystem::path. Using Pathlib would add more unnecessary complexity from these low level wrappers.

dave992 commented 1 year ago

Perhaps exclude the string overload from the wrapper then.

johnwason commented 1 year ago

The string constructor allows for the use of a string containing the yaml text without needing to open a file.

dave992 commented 1 year ago

Ah, the third overload is a YAML string. Sounds like perfect info for the docstring of the overload, although out of scope for this issue 😉

johnwason commented 1 year ago

The docstring is generated from the C++ doxygen comments in the upstream repository. Pull requests are always appreciated.