viewer_loger.py
Go to the documentation of this file.
1 import glob
2 import os
3 
4 
5 class ViewerLoger:
6  """
7  This class replace the robotviewer client and log the data sent to the
8  viewer for future replay.
9 
10  Example of use:
11  from viewer_loger import ViewerLoger
12  robot.viewer = ViewerLoger(robot)
13 
14  """
15 
16  def __init__(self, robot):
17  self.robot = robot
18  self.viewer = robot.viewer
19  self.fileMap = {}
20  for f in glob.glob("/tmp/view*.dat"):
21  os.remove(f)
22 
23  def updateElementConfig(self, name, state):
24  t = self.robot.state.time
25  if name not in self.fileMap:
26  self.fileMap[name] = open("/tmp/view_" + name + ".dat", "w")
27  self.fileMap[name].write(
28  "\t".join(
29  [
30  str(f)
31  for f in [
32  t,
33  ]
34  + list(state)
35  ]
36  )
37  + "\n"
38  )
39  self.viewer.updateElementConfig(name, state)


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Wed Jun 21 2023 02:51:26