Skip to content

Commit

Permalink
Merge branch 'master' into bugs/propspace
Browse files Browse the repository at this point in the history
  • Loading branch information
Nobu19800 committed Sep 13, 2024
2 parents cd6c504 + 6fd9d88 commit 964fb91
Show file tree
Hide file tree
Showing 46 changed files with 5,052 additions and 1,594 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
31 changes: 8 additions & 23 deletions OpenRTM_aist/CorbaNaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,11 @@ def __init__(self, orb, name_server=None):

if name_server:
self._nameServer = "corbaloc::" + name_server + "/NameService"
try:
obj = orb.string_to_object(self._nameServer)
self._rootContext = obj._narrow(CosNaming.NamingContext)
if CORBA.is_nil(self._rootContext):
print("CorbaNaming: Failed to narrow the root naming context.")

except CORBA.ORB.InvalidName:
self.__print_exception()
print("Service required is invalid [does not exist].")
obj = orb.string_to_object(self._nameServer)
self._rootContext = obj._narrow(CosNaming.NamingContext)
if CORBA.is_nil(self._rootContext):
print("CorbaNaming: Failed to narrow the root naming context.")
raise MemoryError

return

Expand Down Expand Up @@ -346,14 +342,12 @@ def rebind(self, name_list, obj, force=True):
if force:
self.rebindRecursive(self._rootContext, name_list, obj)
else:
self.__print_exception()
raise

except CosNaming.NamingContext.CannotProceed as err:
if force:
self.rebindRecursive(err.cxt, err.rest_of_name, obj)
else:
self.__print_exception()
raise

##
Expand Down Expand Up @@ -570,12 +564,8 @@ def resolve(self, name):
else:
name_ = name

try:
obj = self._rootContext.resolve(name_)
return obj
except CosNaming.NamingContext.NotFound:
self.__print_exception()
return None
obj = self._rootContext.resolve(name_)
return obj

##
# @if jp
Expand Down Expand Up @@ -611,10 +601,7 @@ def unbind(self, name):
else:
name_ = name

try:
self._rootContext.unbind(name_)
except BaseException:
self.__print_exception()
self._rootContext.unbind(name_)

return

Expand Down Expand Up @@ -679,14 +666,12 @@ def bindNewContext(self, name, force=True):
if force:
self.bindRecursive(self._rootContext, name_, self.newContext())
else:
self.__print_exception()
raise
except CosNaming.NamingContext.CannotProceed as err:
if force:
self.bindRecursive(
err.cxt, err.rest_of_name, self.newContext())
else:
self.__print_exception()
raise
return None

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
Loading

0 comments on commit 964fb91

Please sign in to comment.