本文整理汇总了Python中easyprocess.EasyProcess.rfind方法的典型用法代码示例。如果您正苦于以下问题:Python EasyProcess.rfind方法的具体用法?Python EasyProcess.rfind怎么用?Python EasyProcess.rfind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类easyprocess.EasyProcess
的用法示例。
在下文中一共展示了EasyProcess.rfind方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: motors_monitor
# 需要导入模块: from easyprocess import EasyProcess [as 别名]
# 或者: from easyprocess.EasyProcess import rfind [as 别名]
def motors_monitor(self):
cmd_dyn = 'rostopic echo /{}/safe/motor_states/default -n 1'.format(self.robot_name)
while True:
# Dynamixel states
try:
out = EasyProcess(cmd_dyn).call(timeout=1).stdout
out = out[:out.rfind('\n')]
states = yaml.load(out)
self.dynamixel_motors_states = {m['id']: m for m in states['motor_states']}
except:
self.dynamixel_motors_states= {}
# Pololu states
for i in self.pololu_boards.keys():
cmd_pol = 'rostopic echo /{}/{}/motors_states -n 1'.format(self.robot_name, i)
try:
out = EasyProcess(cmd_pol).call(timeout=1).stdout
out = out[:out.rfind('\n')]
states = yaml.load(out)
states = dict(zip(states['name'], states['position']))
self.pololu_boards[i] = states
except:
self.pololu_boards[i] = {}
time.sleep(1)