Skip to content

Commit

Permalink
Merge branch 'master' into feature/retryaccess
Browse files Browse the repository at this point in the history
  • Loading branch information
Nobu19800 committed Sep 20, 2024
2 parents ce3ae3b + 6fd9d88 commit 9d125fe
Show file tree
Hide file tree
Showing 42 changed files with 4,986 additions and 1,534 deletions.
2 changes: 1 addition & 1 deletion COPYRIGHT
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

Copyright (C) 2003-2018
Copyright (C) 2003-2024
Noriaki Ando and the OpenRTM-aist Project team
Intelligent Systems Research Institute,
National Institute of Advanced Industrial Science and Technology (AIST),
Expand Down
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
include OpenRTM-aist.pth
include MANIFEST.in
include setup.py
include setup.cfg
include pyproject.toml
include README
exclude README.md
recursive-include packages Makefile
recursive-include packages/deb *.sh copyright changelog rules README* compat control control.* files
recursive-include packages/rpm *.sh openrtm-aist.spec.in openrtm-aist_py3.spec.in
Expand Down
29 changes: 11 additions & 18 deletions OpenRTM_aist/DefaultConfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
lang = "Python"
elif os.name == "posix":
cpp_suffixes = "so"
supported_languages = "C++, Python, Python3, Java"
lang = "Python3"
supported_languages = "C++, Python, Java"
lang = "Python"
else:
cpp_suffixes = "dylib"
supported_languages = "C++, Python, Python3, Java"
lang = "Python3"
supported_languages = "C++, Python, Java"
lang = "Python"

##
# @if jp
Expand Down Expand Up @@ -90,32 +90,25 @@
"manager.auto_shutdown_duration", "20.0",
"manager.termination_waittime", "1.0",
"manager.name", "manager",
"manager.command", "rtcd",
"manager.command", "rtcd2_python",
"manager.nameservers", "default",
"manager.language", lang,
"manager.components.naming_policy", "process_unique",
"manager.modules.C++.manager_cmd", "rtcd",
"manager.modules.Python.manager_cmd", "rtcd_python",
"manager.modules.Java.manager_cmd", "rtcd_java",
"manager.modules.C++.manager_cmd", "rtcd2",
"manager.modules.Python.manager_cmd", "rtcd2_python",
"manager.modules.Java.manager_cmd", "rtcd2_java",
"manager.modules.search_auto", "YES",
"manager.local_service.enabled_services", "ALL",
"sdo.service.provider.enabled_services", "ALL",
"sdo.service.consumer.enabled_services", "ALL",
"manager.supported_languages", supported_languages,
"manager.modules.C++.profile_cmd", "rtcprof",
"manager.modules.Python.profile_cmd", "rtcprof_python",
"manager.modules.Java.profile_cmd", "rtcprof_java",
"manager.modules.C++.profile_cmd", "rtcprof2",
"manager.modules.Python.profile_cmd", "rtcprof2_python",
"manager.modules.Java.profile_cmd", "rtcprof2_java",
"manager.modules.C++.suffixes", cpp_suffixes,
"manager.modules.Python.suffixes", "py",
"manager.modules.Java.suffixes", "class",
"manager.modules.C++.load_paths", "",
"manager.modules.Python.load_paths", "",
"manager.modules.Java.load_paths", ""]

if os.name != "nt":
python3_config = [
"manager.modules.Python3.manager_cmd", "rtcd_python3",
"manager.modules.Python3.profile_cmd", "rtcprof_python3",
"manager.modules.Python3.suffixes", "py",
"manager.modules.Python3.load_paths", ""]
default_config.extend(python3_config)
2 changes: 1 addition & 1 deletion OpenRTM_aist/GlobalFactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def getIdentifiers(self):
# ReturnCode addFactory(const Identifier& id,
# Creator creator)

def addFactory(self, id, creator):
def addFactory(self, id, creator, prop=None):
if not creator:
return self.INVALID_ARG

Expand Down
4 changes: 2 additions & 2 deletions OpenRTM_aist/InPort.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ def __init__(self, name, value):
self._valueMutex = threading.RLock()

marshaling_types = OpenRTM_aist.SerializerFactories.instance().getSerializerList(value)
marshaling_types = OpenRTM_aist.flatten(marshaling_types).lstrip()
self.addProperty("dataport.marshaling_types", marshaling_types)
marshaling_types_str = ",".join([x.strip() for x in marshaling_types])
self.addProperty("dataport.marshaling_types", marshaling_types_str)

self._listeners.setDataType(copy.deepcopy(value))
self._listeners.setPortType(OpenRTM_aist.PortType.InPortType)
Expand Down
48 changes: 33 additions & 15 deletions OpenRTM_aist/Manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def activateManager(self):

sdofactory_ = OpenRTM_aist.SdoServiceConsumerFactory.instance()
self._config.setProperty("sdo.service.consumer.available_services",
OpenRTM_aist.flatten(sdofactory_.getIdentifiers()))
",".join([x.strip() for x in sdofactory_.getIdentifiers()]))

self.invokeInitProc()
self.initPreCreation()
Expand Down 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 @@ -938,15 +949,15 @@ def createComponent(self, comp_args):
comp_id.getProperty("implementation_id"))
return None

if not found_obj.findNode("module_file_name"):
self._rtcout.RTC_ERROR("Hmm...module_file_name key not found.")
if not found_obj.findNode("module_file_path"):
self._rtcout.RTC_ERROR("Hmm...module_file_path key not found.")
return None

# module loading
self._rtcout.RTC_INFO(
"Loading module: %s",
found_obj.getProperty("module_file_name"))
self.load(found_obj.getProperty("module_file_name"), "")
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 Expand Up @@ -1599,7 +1610,7 @@ def initLogstreamPlugins(self):
for mod_ in lmod_:
if not mod_:
continue
basename_ = mod_.split(".")[0] + "Init"
basename_ = os.path.basename(mod_).split(".")[0] + "Init"
try:
self._module.load(mod_, basename_)
except BaseException:
Expand Down Expand Up @@ -1680,9 +1691,9 @@ def initLogger(self):

self._rtcout.RTC_INFO(
"%s", self._config.getProperty("openrtm.version"))
self._rtcout.RTC_INFO("Copyright (C) 2003-2020, Noriaki Ando and OpenRTM development team,")
self._rtcout.RTC_INFO("Copyright (C) 2003-2024, Noriaki Ando and OpenRTM development team,")
self._rtcout.RTC_INFO(" Intelligent Systems Research Institute, AIST,")
self._rtcout.RTC_INFO("Copyright (C) 2020, Noriaki Ando and OpenRTM development team,")
self._rtcout.RTC_INFO("Copyright (C) 2024, Noriaki Ando and OpenRTM development team,")
self._rtcout.RTC_INFO(" Industrial Cyber-Physical Research Center, AIST,")
self._rtcout.RTC_INFO(" All right reserved.")
self._rtcout.RTC_INFO("Manager starting.")
Expand Down Expand Up @@ -2389,6 +2400,8 @@ def shutdownComponents(self):
except BaseException:
self._rtcout.RTC_TRACE(OpenRTM_aist.Logger.print_exception())

self.cleanupComponents()

for ec in self._ecs:
try:
self._poa.deactivate_object(self._poa.servant_to_id(ec))
Expand Down Expand Up @@ -2657,10 +2670,8 @@ def configureComponent(self, comp, prop):
naming_formats = self._config.getProperty("naming.formats")
if comp_prop.findNode("naming.formats"):
naming_formats = comp_prop.getProperty("naming.formats")
naming_formats = OpenRTM_aist.flatten(
OpenRTM_aist.unique_sv(
OpenRTM_aist.split(
naming_formats, ",")))
naming_formats = ",".join([x.strip() for x in OpenRTM_aist.unique_sv(
OpenRTM_aist.split(naming_formats, ","))])

naming_names = self.formatString(naming_formats, comp.getProperties())
comp.getProperties().setProperty("naming.formats", naming_formats)
Expand Down Expand Up @@ -3161,7 +3172,7 @@ def initPreConnection(self):

tmp = port0_str.split(".")
tmp.pop()
comp0_name = OpenRTM_aist.flatten(tmp, ".")
comp0_name = ".".join([x.strip() for x in tmp])

port0_name = port0_str

Expand Down Expand Up @@ -3203,7 +3214,7 @@ def initPreConnection(self):

tmp = port_str.split(".")
tmp.pop()
comp_name = OpenRTM_aist.flatten(tmp, ".")
comp_name = ".".join([x.strip() for x in tmp])
port_name = port_str

if comp_name.find("://") == -1:
Expand Down Expand Up @@ -3577,16 +3588,19 @@ def __init__(self, name=None, prop=None, factory=None):
self._category = ""
self._impleid = name
self._version = ""
self._language = ""
elif prop:
self._vendor = prop.getProperty("vendor")
self._category = prop.getProperty("category")
self._impleid = prop.getProperty("implementation_id")
self._version = prop.getProperty("version")
self._language = prop.getProperty("language")
elif factory:
self._vendor = factory.profile().getProperty("vendor")
self._category = factory.profile().getProperty("category")
self._impleid = factory.profile().getProperty("implementation_id")
self._version = factory.profile().getProperty("version")
self._language = factory.profile().getProperty("language")

def __call__(self, factory):
if self._impleid == "":
Expand All @@ -3608,6 +3622,10 @@ def __call__(self, factory):
if self._version != "" and self._version != _prop.getProperty(
"version"):
return False

if self._language != "" and self._language != _prop.getProperty(
"language"):
return False

return True

Expand Down
73 changes: 39 additions & 34 deletions OpenRTM_aist/ManagerServant.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,14 @@ def create_component(self, module_name):

self._rtcout.RTC_TRACE("create_component(%s)", module_name)

if not module_name:
self._rtcout.RTC_ERROR("Module name is empty.")
return RTC.RTObject._nil
if module_name.lstrip().find("?") == 0:
self._rtcout.RTC_ERROR("Module name is empty.")
return RTC.RTObject._nil


rtc, module_name, manager_address = self.createComponentByAddress(
module_name)

Expand Down Expand Up @@ -530,8 +538,13 @@ def create_component(self, module_name):
OpenRTM_aist.Logger.print_exception())
self._slaves.remove(slave)
del guard

if not manager_name:
module_name = module_name + "&manager_name=manager_%p"
if "?" not in module_name:
module_name += "?"
else:
module_name += "&"
module_name += "manager_name=manager_%p"

rtc, _, _ = self.createComponentByManagerName(module_name)
return rtc
Expand Down Expand Up @@ -1311,47 +1324,28 @@ def findManagerByName(self, manager_name):
# std::string getParameterByModulename(string param_name, string
# &module_name)
def getParameterByModulename(self, param_name, module_name):
arg = module_name
pos0 = arg.find("&" + param_name + "=")
pos1 = arg.find("?" + param_name + "=")
param_start = module_name.find(param_name+"=")

if pos0 == -1 and pos1 == -1:
if param_start < 0:
return "", module_name

param_end = module_name.find("&", param_start)

pos = 0
if pos0 == -1:
pos = pos1
else:
pos = pos0

paramstr = ""
endpos = arg.find('&', pos + 1)
if endpos == -1:
endpos = arg.find('?', pos + 1)
if endpos == -1:
paramstr = arg[(pos + 1):]
else:
paramstr = arg[(pos + 1): endpos]
else:
paramstr = arg[(pos + 1): endpos]
self._rtcout.RTC_VERBOSE("%s arg: %s", (param_name, paramstr))
if param_end < 0:
param_end = len(module_name)

eqpos = paramstr.find("=")
# if eqpos == -1:
# self._rtcout.RTC_WARN("Invalid argument: %s", module_name)
# return ""
param_value = module_name[param_start+len(param_name)+1:param_end]

paramstr = paramstr[eqpos + 1:]
self._rtcout.RTC_DEBUG("%s is %s", (param_name, paramstr))
self._rtcout.RTC_DEBUG("%s is %s", (param_name, param_value))

if endpos == -1:
arg = arg[:pos]
else:
arg = arg[:pos] + arg[endpos:]
if module_name[param_start-1] == "?":
module_name = module_name[:param_start] + module_name[param_end:]
elif module_name[param_start-1] == "&":
module_name = module_name[:param_start-1] + module_name[param_end:]

module_name = arg
return param_value, module_name


return paramstr, module_name

##
# @if jp
Expand All @@ -1374,6 +1368,7 @@ def createComponentByManagerName(self, module_name):
arg = module_name

mgrstr, arg = self.getParameterByModulename("manager_name", arg)
param = OpenRTM_aist.urlparam2map(arg)

if not mgrstr:
return RTC.RTObject._nil, arg, mgrstr
Expand Down Expand Up @@ -1410,6 +1405,11 @@ def createComponentByManagerName(self, module_name):
load_path = load_path.replace("\\", "\\\\")
else:
cmd = rtcd_cmd
if "config_file" in param.keys():
cmd += " -f \"" + param["config_file"] + "\""
elif config.findNode("config_file"):
cmd += " -f \"" + config.getProperty("config_file") + "\""

cmd += " -o " + "manager.is_master:NO"
cmd += " -o " + "manager.corba_servant:YES"
cmd += " -o " + "corba.master_manager:" + \
Expand Down Expand Up @@ -1527,6 +1527,7 @@ def createComponentByAddress(self, module_name):

arg = module_name
mgrstr, arg = self.getParameterByModulename("manager_address", arg)
param = OpenRTM_aist.urlparam2map(arg)

if not mgrstr:
return RTC.RTObject._nil, arg, mgrstr
Expand Down Expand Up @@ -1564,6 +1565,10 @@ def createComponentByAddress(self, module_name):
load_path = load_path.replace("\\", "\\\\")
else:
cmd = rtcd_cmd
if "config_file" in param.keys():
cmd += " -f \"" + param["config_file"] + "\""
elif config.findNode("config_file"):
cmd += " -f \"" + config.getProperty("config_file") + "\""
cmd += " -o corba.master_manager:"
cmd += mgrstr # port number
cmd += " -o \"manager.modules.load_path:"
Expand Down
Loading

0 comments on commit 9d125fe

Please sign in to comment.