Environment API#
- class br2.environment.Environment(run_tag, rendering_fps=25, time_step=2e-05, final_time=None)[source]#
- Attributes:
- rendering_fpsint
Rendering fps for output videos. (default=25)
- time_stepfloat
Simulation timestep. Faster time-step could reduce the simulation walltime, but the simulation may be unstable. (default=2.0e-5)
- final_timeOptional[float]
- reset(rod_database_path, assembly_config_path, start_time=0.0, **kwargs)[source]#
Creates the simulation environment.
- Return type:
None
- Parameters:
- rod_database_pathstr
- assembly_config_pathstr
- start_timefloat
- run(action, duration=None, disable_progress_bar=False, check_nan=False, check_steady_state=None)[source]#
Run simulation for a duration given action.
- Return type:
Optional
[TerminalInfo
]- Parameters:
- actiondict
Action specified for each rods.
- durationOptional[float]
If duration is not specified, run a single step (duration=step_size)
- disable_progress_barbool
- check_nanbool
If True, check if any Nan is detected in the simulation at the end of the run. (default=False)
- check_steady_stateOptional[int]
Check steady state condition at the end of the run. If 1, the velocity steady- state is checked. If 2, dynamic steady-state condition is checked.(default=None)
- save_state(directory=None, verbose=False)[source]#
Save state parameters of each rod.
- Return type:
None
- Parameters:
- directory: Optional[str]
Directory path name. The path must exist.
- load_state(directory='', clear_callback=False, verbose=False)[source]#
Load the rod-state. Compatibale with ‘save_state’ method.
If the save-file does not exist, it returns error.
- Return type:
None
- Parameters:
- directoryOptional[str]
Directory path name.
Terminal Information#
- class br2.environment.TerminalInfo(end_status=False)[source]#
- Attributes:
- end_statusbool
Indicate if simulation reached end.
- <variable>_nan_statusbool
Indicate if NaN exists in <variable>. Only given when check_nan is True.
- <variable>_steady_state_statusbool
Indicate if <variable> is in steady-state. Only given when check_steady_state is given.
- max_velocityfloat
Maximum velocity at the end of the run. Only given when check_steady_state=1.
-
end_status:
bool
= False#
- property combined_nan_status: bool#
Combined status for if NaN exists. Return true if any NaN status is true.
Notes
If check_nan is not given in simulation, this property does not give correct indication.
- property combined_steady_state_status: bool#
Combined status for steady state. Return true if all steady-state status is true.
Notes
If check_steady_state is not given in simulation, this property does not give correct indication.
Data Paths#
- class br2.environment.DataPaths(tag)[source]#
Data path collection
- Attributes:
- tagstr
Simulation tag that will be appended at the end of the result directory.
- pathsstr
Parent directory path
- simulationstr
Path to save the simulation data for pause/restart purpose.
- renderingsstr
Path to save all the rendering videos.
- datastr
Path to save data for the post-processing.
-
tag:
str
#
- property paths: str#
- property simulation: str#
- property renderings: str#
- property data: str#