Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create_component関数でRTCが起動できない場合がある問題の修正 #315

Merged
merged 2 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions OpenRTM_aist/Manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,17 @@ def join(self):
def load(self, fname, initfunc):
self._rtcout.RTC_TRACE("Manager.load(fname = %s, initfunc = %s)",
(fname, initfunc))
prop = OpenRTM_aist.Properties()
prop.setProperty("module_file_name", fname)

return self.load_prop(prop, initfunc)

def load_prop(self, prop, initfunc):
self._rtcout.RTC_TRACE("Manager.load(module_file_name = %s, module_file_path = %s, language = %s, initfunc = %s)",
(prop.getProperty("module_file_name"),
prop.getProperty("module_file_path"),
prop.getProperty("language")))
fname = prop.getProperty("module_file_name")
fname = fname.replace("/", os.sep)
fname = fname.replace("\\", os.sep)
fname, initfunc = self._listeners.module_.preLoad(fname, initfunc)
Expand All @@ -582,7 +593,7 @@ def load(self, fname, initfunc):
if not initfunc:
mod = [s.strip() for s in fname_.split(".")]
initfunc = mod[0] + "Init"
path = self._module.load(fname, initfunc)
path = self._module.load_prop(prop, initfunc)
self._rtcout.RTC_DEBUG("module path: %s", path)
path, initfunc = self._listeners.module_.postLoad(path, initfunc)
except OpenRTM_aist.ModuleManager.NotAllowedOperation as e:
Expand Down Expand Up @@ -946,7 +957,7 @@ def createComponent(self, comp_args):
self._rtcout.RTC_INFO(
"Loading module: %s",
found_obj.getProperty("module_file_path"))
self.load(found_obj.getProperty("module_file_path"), "")
self.load_prop(found_obj, "")
factory = self._factory.find(comp_id)
if not factory:
self._rtcout.RTC_ERROR("Factory not found for loaded module: %s",
Expand Down
16 changes: 13 additions & 3 deletions OpenRTM_aist/ModuleManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,19 @@ def __init__(self, reason_):
# std::string ModuleManager::load(const std::string& file_name,
# const std::string& init_func)
def load(self, file_name, init_func=None):

self._rtcout.RTC_TRACE("load(fname = %s)", file_name)

prop = OpenRTM_aist.Properties()
prop.setProperty("module_file_name", file_name)
return self.load_prop(prop, init_func)

def load_prop(self, prop, init_func=None):
self._rtcout.RTC_TRACE("load(module_file_name = %s, module_file_path = %s, language = %s)",
(prop.getProperty("module_file_name"),
prop.getProperty("module_file_path"),
prop.getProperty("language")))
file_name = prop.getProperty("module_file_name")
file_path = prop.getProperty("module_file_path")
if file_name == "":
raise ModuleManager.InvalidArguments("Invalid file name.")

Expand All @@ -260,7 +271,6 @@ def load(self, file_name, init_func=None):

import_name = os.path.split(file_name)[-1]
pathChanged = False
file_path = None

if OpenRTM_aist.isAbsolutePath(file_name):
if not self._absoluteAllowed:
Expand All @@ -275,7 +285,7 @@ def load(self, file_name, init_func=None):
import_name = splitted_name[-1]
file_path = file_name

else:
elif not file_path:
paths = self._properties.getProperty(
"manager.modules.Python.load_paths").split(",")
paths.extend(self._properties.getProperty(
Expand Down
Loading