DiagramWatcher

Submodules

Classes

class brom_drake.DiagramWatcher.diagram_watcher_options.DiagramWatcherOptions(base_directory: str = './brom/watcher', plotting_options: PortWatcherPlottingOptions = (PortFigureArrangement.OnePlotPerPort, 300, True, 'png', FigureNamingConvention.kFlat), raw_data_options: PortWatcherRawDataOptions = (True, 'npy'), hide_messages: SuppressDiagramWatcherRules = SuppressDiagramWatcherRules(during_port_watcher_connection=False))[source]

Description

This class contains the options that configure the following properties of the DiagramWatcher: - Where it saves its data (plots, raw data, etc.) - the format that it uses to save its data/plots - what types of messages to suppress during its operation

Tip

The DiagramWatcherOptions class has useful defaults defined for ALL of its attributes, so in most cases, the user will not need to modify any of them. You can simply create a DiagramWatcherOptions object with no arguments and it will work out of the box. (e.g., options = DiagramWatcherOptions())

Attributes

base_directory: str, optional

The base directory where the watcher will save any data (e.g., plots, or dataframes) during its operation as well as logs.

plotting_options: PortWatcherPlottingOptions, optional

The options that configure how the PortWatcher will save its plots.

raw_data_options: PortWatcherRawDataOptions, optional

The options that configure how the PortWatcher will save its raw data.

hide_messages: SuppressDiagramWatcherRules, optional

The rules that define which types of messages to suppress during the operation of the DiagramWatcher.

to_port_watcher_options() PortWatcherOptions[source]

Description

This function converts the DiagramWatcherOptions to a PortWatcherOptions object.

Returns

PortWatcherOptions

The PortWatcherOptions object.

class brom_drake.DiagramWatcher.diagram_watcher_options.SuppressDiagramWatcherRules(during_port_watcher_connection: bool = False)[source]

Description

A signal that defines which types of messages to suppress when using the DiagramWatcher.

Attributes

during_port_watcher_connection: bool

If True, suppress log messages that occur during the connection of PortWatchers to the DiagramWatcher.

class brom_drake.DiagramWatcher.DiagramWatcher.DiagramWatcher(subject: DiagramBuilder, targets: List[DiagramTarget] = None, options: DiagramWatcherOptions = DiagramWatcherOptions(base_directory='./brom/watcher', plotting_options=PortWatcherPlottingOptions(plot_arrangement=<PortFigureArrangement.OnePlotPerPort: 1>, plot_dpi=300, save_to_file=True, file_format='png', figure_naming_convention=<FigureNamingConvention.kFlat: 0>), raw_data_options=PortWatcherRawDataOptions(save_to_file=True, file_format='npy'), hide_messages=SuppressDiagramWatcherRules(during_port_watcher_connection=False)))[source]

Description

An object that will iterate through all elements of a partially built Drake Diagram (via the DiagramBuilder) and add PortWatchers to the specified targets.

Parameters

subject: DiagramBuilder

We will search through the subject (a diagram builder) to find all the systems that we want to monitor.

targets: List[DiagramTarget], optional

The targets that we want to monitor, by default this tries to monitor all systems in the diagram. (i.e., when this value is None, we will monitor all systems).

options: DiagramWatcherOptions, optional

The options that configure the DiagramWatcher, by default DiagramWatcherOptions()

check_targets(targets: List[DiagramTarget], eligible_systems: List[MultibodyPlant | AffineSystem | LeafSystem]) List[MultibodyPlant | AffineSystem | LeafSystem][source]

Description

Finds the systems specified by the targets list that we want to watch/monitor. We will try to ignore all systems that are: - Scene Graphs - Loggers and raise an error if the target is not found in the eligible systems.

Parameters

targetsList[DiagramTarget]

The targets that we want to monitor.

eligible_systemsList[Union[MultibodyPlant, AffineSystem, LeafSystem]]

The systems that are eligible for monitoring.

create_logger() Logger[source]

Description

Configures the “activity summary” a log of brom’s activity.

Returns

logger: logging.Logger

The configured logger for LOG MESSAGES. In other words, this is not a logger of signals from the diagram.

create_new_port_watcher_options(options: PortWatcherOptions, plot_dir: str = None, raw_data_dir: str = None) PortWatcherOptions[source]

Description

Creates a new set of PortWatcherOptions with the given options.

Parameters

optionsPortWatcherOptions

The options to use as a base.

plot_dirstr, optional

The directory to save the plots in, by default None

raw_data_dirstr, optional

The directory to save the raw data in, by default None

find_eligible_systems(builder: DiagramBuilder) List[MultibodyPlant | AffineSystem | LeafSystem][source]

Description

Finds all the systems that are eligible for logging. We want to ignore all systems that are:

  • Scene Graphs

  • Loggers

get_smart_targets(subject: DiagramBuilder, targets: List[DiagramTarget]) List[DiagramTarget][source]

Description

For each target with None ports, we will try to “smartly” create the targets that we want to monitor.

Parameters

subjectDiagramBuilder

The diagram builder that contains the systems.

targetsList[DiagramTarget]

The targets that we want to monitor.

Returns

List[DiagramTarget]

The list of targets with inferred ports.

save_figures()[source]

Description

Saves all the figures made from plotting data currently saved in the known port watchers.

save_raw_data()[source]

Description

Saves all the raw data from the port watchers.

class brom_drake.DiagramWatcher.errors.UnrecognizedTargetError(target: <module 'brom_drake.DiagramTarget' from '/home/runner/work/brom_drake-py/brom_drake-py/src/brom_drake/DiagramTarget/__init__.py'>, system_names: List[str] = None)[source]

Description

Raised when a system is not recognized by the DiagramWatcher.

Functions

(None found)

Variables

brom_drake.DiagramWatcher.constants.INELIGIBLE_SYSTEM_TYPES = [<class 'pydrake.geometry.SceneGraph'>, <class 'pydrake.systems.primitives.VectorLogSink'>, <class 'pydrake.systems.primitives.ConstantVectorSource'>]

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.

brom_drake.DiagramWatcher.diagram_watcher_options.DEFAULT_WATCHER_DIR = './brom/watcher'

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

brom_drake.DiagramWatcher.DiagramWatcher.INELIGIBLE_SYSTEM_TYPES = [<class 'pydrake.geometry.SceneGraph'>, <class 'pydrake.systems.primitives.VectorLogSink'>, <class 'pydrake.systems.primitives.ConstantVectorSource'>]

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.

brom_drake.DiagramWatcher.errors.INELIGIBLE_SYSTEM_TYPES = [<class 'pydrake.geometry.SceneGraph'>, <class 'pydrake.systems.primitives.VectorLogSink'>, <class 'pydrake.systems.primitives.ConstantVectorSource'>]

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.