Visualize¶
This class wrap the Pytorch Tensorboard class.
Present the simulation results on Tensorboard is so easy and interactive with
Create log file and log signal¶
from OpenControl.visualize import Logger
logX = Logger(log_dir='results')
for i in range(100):
logX.log('euler', [i*np.cos(i), i*np.sin(i)], i)
logX.end_log()
Analysis simulation on Tensorboard¶
Note
If you run the code on Google Colab shell, just load Tensorboard first
%load_ext tensorboard
then run this shell to show
%tensorboard --logdir results
Usage¶
- class OpenControl.visualize.Logger(log_dir='results', filename_suffix='')¶
Bases:
object
Real-time visualize simulation results, using Tensorboard
- writer¶
the same as SummaryWriter
- Type
class
- __init__(log_dir='results', filename_suffix='')¶
The same as SummaryWriter
- Parameters
log_dir (str, optional) – the direction to save the log file. Defaults to ‘results’ folder.
filename_suffix (str, optional) – suffix added to the name of log file. Defaults to ‘’.
- end_log()¶
Call this function to end logging
- log(section, signals, step)¶
Log the signals with the name of section in the step time
- Parameters
section (str) – name of signals
signals (array) – signals
step (int) – only int type is acceptable. Please convert float timestep to int