Environment API

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.

Parameters
rod_database_pathstr
assembly_config_pathstr
start_timefloat
:rtype:py:obj:None
run(action, duration=None, disable_progress_bar=False, check_nan=False, check_steady_state=None)[source]

Run simulation for a duration given action.

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)

:rtype:py:data:~typing.Optional[TerminalInfo]
save_state(directory=None, verbose=False)[source]

Save state parameters of each rod.

Parameters
directory: Optional[str]

Directory path name. The path must exist.

:rtype:py:obj:None
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.

Parameters
directoryOptional[str]

Directory path name.

:rtype:py:obj:None
render_video(**kwargs)[source]

Make video 3D rod movement in time.

Return type

None

save_data(tag=None)[source]

save_data.

Parameters
tagOptional[str]

String tag that appends to the file name.

:rtype:py:obj:None
close()[source]

Close the simulator.

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.

Return type

bool

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.

Return type

bool

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
Return type

str

property simulation: str
Return type

str

property renderings: str
Return type

str

property data: str
Return type

str

initialize()[source]

Initialization step: create missing directories