当前位置: 首页>>代码示例>>Python>>正文


Python ProxySubscriberCached.disable_buffer方法代码示例

本文整理汇总了Python中flexbe_core.proxy.ProxySubscriberCached.disable_buffer方法的典型用法代码示例。如果您正苦于以下问题:Python ProxySubscriberCached.disable_buffer方法的具体用法?Python ProxySubscriberCached.disable_buffer怎么用?Python ProxySubscriberCached.disable_buffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flexbe_core.proxy.ProxySubscriberCached的用法示例。


在下文中一共展示了ProxySubscriberCached.disable_buffer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: GetJointValuesDynState

# 需要导入模块: from flexbe_core.proxy import ProxySubscriberCached [as 别名]
# 或者: from flexbe_core.proxy.ProxySubscriberCached import disable_buffer [as 别名]
class GetJointValuesDynState(EventState):
	'''
	Retrieves current values of specified joints.

	># joint_names	string[]	List of desired joint names.

	#> joint_values float[] 	List of current joint values.

	<= retrieved 				Joint values are available.

	'''

	def __init__(self):
		'''
		Constructor
		'''
		super(GetJointValuesDynState, self).__init__(
			outcomes=['retrieved'],
			output_keys=['joint_values'],
			input_keys=['joint_names'])
		
		self._topic = '/joint_states'
		self._sub = ProxySubscriberCached({self._topic: JointState})

		self._joints = None
		self._joint_values = list()
			
		
	def execute(self, userdata):
		while self._sub.has_buffered(self._topic):
			msg = self._sub.get_from_buffer(self._topic)
			for i in range(len(msg.name)):
				if msg.name[i] in self._joints \
				and self._joint_values[self._joints.index(msg.name[i])] is None:
					self._joint_values[self._joints.index(msg.name[i])] = msg.position[i]

		if all(v is not None for v in self._joint_values):
			userdata.joint_values = self._joint_values
			return 'retrieved'

			
	def on_enter(self, userdata):
		self._sub.enable_buffer(self._topic)
		self._joint_values = [None] * len(self._joints)
		self._joints = userdata.joint_names


	def on_exit(self, userdata):
		self._sub.disable_buffer(self._topic)
开发者ID:FlexBE,项目名称:generic_flexbe_states,代码行数:51,代码来源:get_joint_values_dyn_state.py


注:本文中的flexbe_core.proxy.ProxySubscriberCached.disable_buffer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。