Skip to content

Commit

Permalink
Merge pull request #315 from Nobu19800/bugs/loadmodule
Browse files Browse the repository at this point in the history
create_component関数でRTCが起動できない場合がある問題の修正
  • Loading branch information
n-kawauchi authored Aug 5, 2024
2 parents 85db64f + ac1f388 commit d4d02f4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
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

0 comments on commit d4d02f4

Please sign in to comment.