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)
dynamic_graph.sot.core.utils.viewer_loger.ViewerLoger.updateElementConfig
def updateElementConfig(self, name, state)
Definition: viewer_loger.py:23
dynamic_graph.sot.core.utils.viewer_loger.ViewerLoger.__init__
def __init__(self, robot)
Definition: viewer_loger.py:16
dynamic_graph.sot.core.utils.viewer_loger.ViewerLoger
Definition: viewer_loger.py:5
dynamic_graph.sot.core.utils.viewer_loger.ViewerLoger.fileMap
fileMap
Definition: viewer_loger.py:19
dynamic_graph.sot.core.utils.viewer_loger.ViewerLoger.robot
robot
Definition: viewer_loger.py:17
dynamic_graph.sot.core.utils.viewer_loger.ViewerLoger.viewer
viewer
Definition: viewer_loger.py:18


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Tue Oct 24 2023 02:26:32