本文整理汇总了Python中plugin_manager.PluginManager.loadPlugins方法的典型用法代码示例。如果您正苦于以下问题:Python PluginManager.loadPlugins方法的具体用法?Python PluginManager.loadPlugins怎么用?Python PluginManager.loadPlugins使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plugin_manager.PluginManager
的用法示例。
在下文中一共展示了PluginManager.loadPlugins方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: JoyManager
# 需要导入模块: from plugin_manager import PluginManager [as 别名]
# 或者: from plugin_manager.PluginManager import loadPlugins [as 别名]
class JoyManager():
def __init__(self):
self.pre_status = None
self.history = StatusHistory(max_length=10)
self.controller_type = rospy.get_param('~controller_type', 'xbox')
self.plugins = rospy.get_param('~plugins', [])
self.current_plugin_index = 0
if self.controller_type == 'xbox':
self.JoyStatus = XBoxStatus
elif self.controller_type == 'ps3':
self.JoyStatus = PS3Status
elif self.controller_type == 'ps3wired':
self.JoyStatus = PS3WiredStatus
elif self.controller_type == 'auto':
s = rospy.Subscriber('/joy', Joy, autoJoyDetect)
while not rospy.is_shutdown():
if AUTO_DETECTED_CLASS:
self.JoyStatus = AUTO_DETECTED_CLASS
s.unregister()
break
else:
rospy.sleep(1)
self.plugin_manager = PluginManager('jsk_teleop_joy')
self.loadPlugins()
def loadPlugins(self):
self.plugin_manager.loadPlugins()
self.plugin_instances = self.plugin_manager.loadPluginInstances(self.plugins)
def nextPlugin(self):
rospy.loginfo('switching to next plugin')
self.current_plugin_index = self.current_plugin_index + 1
if len(self.plugin_instances) == self.current_plugin_index:
self.current_plugin_index = 0
self.current_plugin.disable()
self.current_plugin = self.plugin_instances[self.current_plugin_index]
self.current_plugin.enable()
def start(self):
if len(self.plugin_instances) == 0:
rospy.logfatal('no valid plugins are loaded')
return
self.current_plugin = self.plugin_instances[0]
self.current_plugin.enable()
self.joy_subscriber = rospy.Subscriber('/joy', Joy, self.joyCB)
def joyCB(self, msg):
status = self.JoyStatus(msg)
if self.pre_status and status.select and not self.pre_status.select:
self.nextPlugin()
else:
self.current_plugin.joyCB(status, self.history)
self.pre_status = status
self.history.add(status)
示例2: JoyManager
# 需要导入模块: from plugin_manager import PluginManager [as 别名]
# 或者: from plugin_manager.PluginManager import loadPlugins [as 别名]
class JoyManager():
STATE_INITIALIZATION = 1
STATE_RUNNING = 2
STATE_WAIT_FOR_JOY = 3
MODE_PLUGIN = 0
MODE_MENU = 1
mode = 0
plugin_instances = []
def stateDiagnostic(self, stat):
if self.state == self.STATE_INITIALIZATION:
stat.summary(DiagnosticStatus.WARN,
"initializing JoyManager")
elif self.state == self.STATE_RUNNING:
stat.summary(DiagnosticStatus.OK,
"running")
stat.add("Joy stick type", str(self.JoyStatus))
elif self.state == self.STATE_WAIT_FOR_JOY:
stat.summary(DiagnosticStatus.WARN,
"waiting for joy message to detect joy stick type")
return stat
def pluginStatusDiagnostic(self, stat):
if len(self.plugin_instances) == 0:
stat.summary(DiagnosticStatus.ERROR, "no plugin is loaded")
else:
stat.summary(DiagnosticStatus.OK,
"%d plugins are loaded" % (len(self.plugin_instances)))
stat.add("instances", ", ".join([p.name for p in self.plugin_instances]))
return stat
def __init__(self):
self.state = self.STATE_INITIALIZATION
self.pre_status = None
self.history = StatusHistory(max_length=10)
self.menu_pub = rospy.Publisher("/overlay_menu", OverlayMenu)
self.controller_type = rospy.get_param('~controller_type', 'auto')
self.plugins = rospy.get_param('~plugins', {})
self.current_plugin_index = 0
#you can specify the limit of the rate via ~diagnostic_period
self.diagnostic_updater = DiagnosticUpdater()
self.diagnostic_updater.setHardwareID("teleop_manager")
self.diagnostic_updater.add("State", self.stateDiagnostic)
self.diagnostic_updater.add("Plugin Status", self.pluginStatusDiagnostic)
#self.diagnostic_updater.add("Joy Input", self.joyInputDiagnostic)
self.diagnostic_updater.update()
if self.controller_type == 'xbox':
self.JoyStatus = XBoxStatus
elif self.controller_type == 'ps3':
self.JoyStatus = PS3Status
elif self.controller_type == 'ps3wired':
self.JoyStatus = PS3WiredStatus
elif self.controller_type == 'auto':
s = rospy.Subscriber('/joy', Joy, autoJoyDetect)
self.state = self.STATE_WAIT_FOR_JOY
error_message_published = False
r = rospy.Rate(1)
while not rospy.is_shutdown():
self.diagnostic_updater.update()
if AUTO_DETECTED_CLASS == "UNKNOWN":
if not error_message_published:
rospy.logfatal("unknown joy type")
error_message_published = True
r.sleep()
elif AUTO_DETECTED_CLASS:
self.JoyStatus = AUTO_DETECTED_CLASS
s.unregister()
break
else:
r.sleep()
self.diagnostic_updater.update()
self.plugin_manager = PluginManager('jsk_teleop_joy')
self.loadPlugins()
def loadPlugins(self):
self.plugin_manager.loadPlugins()
self.plugin_instances = self.plugin_manager.loadPluginInstances(self.plugins)
def switchPlugin(self, index):
self.current_plugin_index = index
if len(self.plugin_instances) <= self.current_plugin_index:
self.current_plugin_index = 0
elif self.current_plugin_index < 0:
self.current_plugin_index = len(self.plugin_instances)
self.current_plugin.disable()
self.current_plugin = self.plugin_instances[self.current_plugin_index]
self.current_plugin.enable()
def nextPlugin(self):
rospy.loginfo('switching to next plugin')
self.switchPlugin(self, self.current_plugin_index + 1)
def start(self):
self.publishMenu(0, close=True) # close menu anyway
self.diagnostic_updater.force_update()
if len(self.plugin_instances) == 0:
rospy.logfatal('no valid plugins are loaded')
return False
self.current_plugin = self.plugin_instances[0]
self.current_plugin.enable()
self.joy_subscriber = rospy.Subscriber('/joy', Joy, self.joyCB)
self.state = self.STATE_RUNNING
return True
def publishMenu(self, index, close=False):
menu = OverlayMenu()
#.........这里部分代码省略.........