watcher¶
Submodules¶
Classes¶
(None found)
Functions¶
- brom_drake.utils.watcher.add_watcher.add_watcher(builder: DiagramBuilder, targets: List[str | Tuple[str, int] | Tuple[int, int] | Tuple[str, str] | Tuple[str, List[int]] | Tuple[int, List[int]] | Tuple[str, List[str]]] = None, watcher_dir: str = './brom/watcher', plot_arrangement: PortFigureArrangement = PortFigureArrangement.OnePlotPerPort, figure_naming_convention: FigureNamingConvention = FigureNamingConvention.kFlat, file_format: str = 'png') DiagramWatcher[source]¶
Description
This function adds a
DiagramWatcherto a Drake Diagram. The diagram is not finalized yet and so it is accessible via the builder argument. The watcher will insert LogVectorSink systems to log the output ports of the systems specified in the targets argument.Importantly, this function does NOT build the diagram.
Parameters
- builderDiagramBuilder
The diagram builder to which we want to add the watcher.
- targetsList[Tuple[Union[str, int]]]
The targets that we want to watch.
- watcher_dirstr, optional
The directory in which we will store the data collected by the DiagramWatcher. By default,
DEFAULT_WATCHER_DIR.- plot_arrangementPortFigureArrangement, optional
The arrangement of the plots. By default, PortFigureArrangement.OnePlotPerPort.
- figure_naming_conventionFigureNamingConvention, optional
The naming convention for the figures. By default, FigureNamingConvention.kFlat.
- file_formatstr, optional
The file format for the figures. By default, “png”.
Example Usage
The simplest way to use this function is to just pass in the diagram builder:
watcher = add_watcher(builder)
You can also specify which systems and ports to watch by passing in a list of targets. Each target can be specified as either:
A string representing the name of the system to watch (all ports will be watched), or
A tuple of (system_name: str, port_index: int) to watch a specific port of a system, or
A tuple of (system_index: int, port_index: int) to watch a specific port of a system by its index.
Here are some examples of how to specify targets:
watcher = add_watcher(builder, [("plant", 0), ("controller", 0)])
Returns
- watcherDiagramWatcher
The watcher that we have added to the diagram builder.
- brom_drake.utils.watcher.add_watcher.add_watcher_and_build(builder: DiagramBuilder, targets: List[str | Tuple[str, int] | Tuple[int, int] | Tuple[str, str] | Tuple[str, List[int]] | Tuple[int, List[int]] | Tuple[str, List[str]]] = None, watcher_dir: str = './brom/watcher', plot_arrangement: PortFigureArrangement = PortFigureArrangement.OnePlotPerPort, figure_naming_convention: FigureNamingConvention = FigureNamingConvention.kFlat, file_format: str = 'png') Tuple[DiagramWatcher, Diagram, Context][source]¶
Description
This function adds a
DiagramWatcherto a Drake Diagram. The diagram is not finalized yet and so it is accessible via the builder argument. The watcher will insert LogVectorSink systems to log the output ports of the systems specified in the targets argument.Once all of the LogVectorSink systems have been added, the diagram is built and a reference to the built diagram and its default context is added to the DiagramWatcher object.
Example Usage:
watcher = add_watcher_and_build(builder)
In addition, one can specify which systems to watch:
watcher = add_watcher_and_build(builder, targets=[("plant",)])
The DiagramWatcher will then watch all supported ports of the “plant” system that it can find.
Furthermore, to specify which systems and specific ports to watch:
watcher = add_watcher_and_build(builder, targets=[("plant", 0), ("controller", 0)])
This will watch output port 0 of both the “plant” and “controller” systems, if possible.
Parameters
- builder: DiagramBuilder
The diagram builder to which we want to add the watcher.
- targets: List[Tuple[Union[str, int]]]
The targets that we want to watch.
- watcher_dir: str
The directory in which we will store the data collected by the DiagramWatcher.
- plot_arrangement: PortFigureArrangement
The arrangement of the plots. (Can be PortFigureArrangement.OnePlotPerPort OR PortFigureArrangement.OnePlotPerDim)
- figure_naming_convention: FigureNamingConvention
The naming convention for the figures. (Can be FigureNamingConvention.kFlat OR FigureNamingConvention.kHierarchical)
- file_format: str
The file format for the figures.
Returns
- watcher: DiagramWatcher
The watcher that we have added to the diagram builder.
- diagram: Diagram
The built diagram.
- diagram_context: Context
The default context for the built diagram.
- brom_drake.utils.watcher.add_watcher.parse_list_of_simplified_targets(builder: DiagramBuilder, targets: List[str | Tuple[str, int] | Tuple[int, int] | Tuple[str, str] | Tuple[str, List[int]] | Tuple[int, List[int]] | Tuple[str, List[str]]]) List[DiagramTarget][source]¶
Description
This function takes a list of simplified targets and converts them to the full form.
Example Usage
targets = [("plant", 0), ("controller", 0)] parsed_targets = parse_list_of_simplified_targets(targets)
Parameters
- builderDiagramBuilder
The diagram builder to which we want to add the watcher.
- targetsList[Tuple[Union[str, int]]
The list of simplified targets.
Returns
- parsed_targets: List[DiagramTarget]
A list of all the targets that we want to watch.
Variables¶
(None found)