visualizers.viser_app.app#

Module Contents#

class visualizers.viser_app.app.SimulationProcess(task: jacta.visualizers.viser_app.tasks.task.Task, context: jacta.visualizers.viser_app.io.SimulationIOContext)#

Bases: multiprocessing.context.Process

Container for the simulation thread in the viser app. .. py:method:: simulation_loop() -> None

Main simulation loop for SimulationProcess.

Parameters:
  • task (jacta.visualizers.viser_app.tasks.task.Task) –

  • context (jacta.visualizers.viser_app.io.SimulationIOContext) –

write_states() None#

Write current sim states to context.

Return type:

None

reset() None#

Resets the simulation to a new initial state.

Return type:

None

class visualizers.viser_app.app.ControlProcess(controller: jacta.visualizers.viser_app.controllers.controller.Controller, server: viser.ViserServer, context: jacta.visualizers.viser_app.io.IOContext, profiler: jacta.visualizers.viser_app.profiler.ViserProfiler | None = None)#

Bases: multiprocessing.Process

Process that executes a controller at a fixed rate. .. py:method:: run() -> None

Main control flow for the ControllerProcess.

When running, the Process will try to run the control loop. If an exception is encountered, the Process stores the exception in a Queue, prints the exception, and removes its GUI elements.

Parameters:
  • controller (jacta.visualizers.viser_app.controllers.controller.Controller) –

  • server (viser.ViserServer) –

  • context (jacta.visualizers.viser_app.io.IOContext) –

  • profiler (Optional[jacta.visualizers.viser_app.profiler.ViserProfiler]) –

remove() None#

Helper function to clean up GUI elements for this control instance.

Return type:

None

terminate() None#

Cleans up GUI elements on process termination.

Return type:

None

control_loop() Exception | None#

Main outer control loop. Run controller at fixed control frequency.

Return type:

Exception | None

set_profiler_recording(recording: bool = False) None#

Turns on/off profiler recording and updates inner control loop.

Parameters:

recording (bool) –

Return type:

None

write_controls() None#

Write control result out to buffer.

Return type:

None

write_traces() None#

Write traces out to buffer.

Return type:

None

class visualizers.viser_app.app.ViserApp(init_controller: str = 'predictive_sampling', init_task: str = 'cartpole', port: int = 8008, benchmark_dir: pathlib.Path | None = PACKAGE_ROOT / 'log/controller')#

Main class for running the viser app. .. py:method:: flip_profile_button_label() -> None

Flips the button label for the disable/enable profile

Parameters:
  • init_controller (str) –

  • init_task (str) –

  • port (int) –

  • benchmark_dir (Optional[pathlib.Path]) –

setup_task() None#

Task setup for task selected currently in GUI; spawns simulation, control, and visualization processes.

Return type:

None

setup_visualization() None#

Creates the visualization stack

Return type:

None

setup_context() None#

Set the context field and set the initial controller state.

This method can be overwritten for hardware deployment.

Return type:

None

setup_physics(task: jacta.visualizers.viser_app.tasks.task.Task) None#

Set the physics field.

This method can be overwritten for hardware deployment.

Parameters:

task (jacta.visualizers.viser_app.tasks.task.Task) –

Return type:

None

setup_controller(control_config: jacta.visualizers.viser_app.controllers.controller.ControllerConfig | None = None, task_config: jacta.visualizers.viser_app.tasks.task.TaskConfig | None = None) None#

Spawns controller process for controller method currently selected in GUI.

Parameters:
  • control_config (jacta.visualizers.viser_app.controllers.controller.ControllerConfig | None) –

  • task_config (jacta.visualizers.viser_app.tasks.task.TaskConfig | None) –

Return type:

None

control_cycle_callback(_: viser.GuiEvent) None#

Logic for turning on/off the controller via GUI button.

Parameters:

_ (viser.GuiEvent) –

Return type:

None

simulation_cycle_callback(_: viser.GuiEvent) None#

Logic for turning on/off the simulation via GUI button.

Parameters:

_ (viser.GuiEvent) –

Return type:

None

simulation_reset_callback(_: viser.GuiEvent) None#

Resets the simulation via GUI button.

Parameters:

_ (viser.GuiEvent) –

Return type:

None

control_selection_callback(event: viser.GuiEvent) None#

Callback for changing controllers. Does not reset sim/vis, but sets up new controller.

Parameters:

event (viser.GuiEvent) –

Return type:

None

task_selection_callback(event: viser.GuiEvent) None#

Callback for changing tasks. Changes target task and runs a clean task setup.

Parameters:

event (viser.GuiEvent) –

Return type:

None

enable_profiling_callback(event: viser.GuiEvent) None#

Callback to enabling/disabling the performance profiler. Initializes the function in the controller

Parameters:

event (viser.GuiEvent) –

Return type:

None

config_download_callback(event: viser.GuiEvent) None#

Callback for downloading the current controller/task configs.

Parameters:

event (viser.GuiEvent) –

Return type:

None

visualizers.viser_app.app.main() None#

Helper main method to make app installable as script via pyproject.toml.

Return type:

None