roles¶
Submodules¶
Classes¶
- class brom_drake.productions.roles.role.Role(name: str, description: str, port_assignments: List[RolePortAssignment])[source]¶
Description
This class defines a “slot” to be filled in a Drake Diagram. A name is used for unique identification and a description is (optionally) used to describe what is expected of a drake LeafSystem (or Diagram) that properly “fills the role” (i.e., fills the slot) in a Drake Diagram.
Parameters
- name: str
Unique identifier of the role.
- description: str
Non-binding description of the role.
- port_assignments: List[RolePortAssigment]
Each element of this list describes:
an external target (e.g., LeafSystems) that the role expects to connect to
the port on the
LeafSystemthat fills this role that should connect to that target.
Usage
Consider the following pieces of code:
from brom_drake.productions.roles import Role, RolePortAssignment from brom_drake.productions.roles.role_port_assignment import PairingType kGraspConfirmer = Role( name="Confirm-When-Grasp-Worked", description="Attempts to define with a boolean whether or not the object we're interested in is currently in our grasp.", port_assignments=[ # Required inputs for Role RolePortAssignment( external_target_name="target_cube_pose", performer_port_name="current_manipuland_pose", pairing_type=PairingType.kInput ), RolePortAssignment( external_target_name="cube_model_idx", performer_port_name="object_model_index", pairing_type=PairingType.kInput ), RolePortAssignment( external_target_name="gripper_pose", performer_port_name="gripper_pose", pairing_type=PairingType.kInput, ), RolePortAssignment( external_target_name="production_gripper_model_idx", performer_port_name="gripper_model_index", pairing_type=PairingType.kInput ), RolePortAssignment( external_target_name="gripper_configuration", performer_port_name="gripper_configuration", pairing_type=PairingType.kInput, ), # Output Of Role RolePortAssignment( external_target_name="grasp_complete", performer_port_name="grasp_success_flag", pairing_type=PairingType.kOutput, ) ] )
The above example defines a Role with:
name:
"Confirm-When-Grasp-Worked"- Required Input Ports:
"current_manipuland_pose""object_model_index""gripper_pose""gripper_model_index""gripper_configuration"
- Required Output Port:
"grasp_success_flag"
- Required Ports to exist somewhere else in the Diagram:
"target_cube_pose""cube_model_idx""gripper_pose""production_gripper_model_idx""gripper_configuration""grasp_complete"
Without all of these satisfied, we can not successfully place a LeafSystem into a Production that expects the
"Confirm-When-Grasp-Worked"role.- connect_performer_ports_to(builder: DiagramBuilder, performer: LeafSystem | Diagram)[source]¶
Description
Connect each inputs and output port mentioned in self.port_assignments on performer to the first port found in builder with the correct name.
Warning
The
.Build()method should not have been called onbuilderbefore invoking this method.Parameters
- builder: DiagramBuilder
The
DiagramBuildercontaining a partially built diagram.- performer: Performer
The object that we think can fill the role defined by self.
- class brom_drake.productions.roles.role_port_assignment.PairingType(*values)[source]¶
Description
Describes the type of connection defined by a RolePortAssignment.
kInput => Connection is between an external target and a performer’s INPUT port.
kOutput => Connection is between an external target and a performer’s OUTPUT port.
- class brom_drake.productions.roles.role_port_assignment.RolePortAssignment(external_target_name: str, performer_port_name: str, pairing_type: PairingType, is_required: bool = True)[source]¶
Description
A potential connection between an object that “fills a role” in a Drake diagram, and the rest of the diagram. Some connections are required, but they need not be.
TODO(Kwesi): Refactor this class to use the
DiagramTargetobject.Parameters
- external_target_name: TargetName
The name of the port (or system) that we want to connect this port to
- performer_port_name: PortName
The name of the port that should exist on the LeafSystem (or Diagram) that “fills the role”.
- pairing_type: PairingType
Describes whether or not performer_port_name is an input or output port. This determines whether or not external_target_name should be an output or input port, respectively.
- is_required: bool, optional
Default is True.
Description
Creates the appropriate version of “Performer does not have required input port” error message.
TODO(Kwesi): Should we create an error type for this?
- create_connections_in(builder: DiagramBuilder, performer: LeafSystem | Diagram)[source]¶
Description
Creates the connection between the performer and the appropriate port in the incomplete Drake diagram specified by builder.
Parameters
- builder: DiagramBuilder
Contains the partially built Diagram.
- performer: Performer
The LeafSystem (or Diagram) that we wish to connect to the incomplete Diagram in
builder.
- create_input_port_connections_in(builder: DiagramBuilder, performer: LeafSystem | Diagram)[source]¶
Description
Assuming that the assignment defines an input port connection, this function finds either:
A system with the target name, and connects the first output port of the target to the performer’s input OR
The first system with the port given by the constraints, and connects that output port to the performer’s input port.
Parameters
- builder: DiagramBuilder
Contains the partially built Diagram.
- performer: Performer
The LeafSystem (or Diagram) that we wish to connect to the incomplete Diagram in
builder.
- create_output_port_connections_in(builder: DiagramBuilder, performer: LeafSystem | Diagram)[source]¶
Description
Assuming that the assignment defines an OUTPUT port connection, this function finds either:
A system with the target name, and connects the first input port of the target to the performer’s output OR
The first system with the input port given by the constraints, and connects that input port to the performer’s output port.
Parameters
- builder: DiagramBuilder
Contains the partially built Diagram.
- performer: Performer
The LeafSystem (or Diagram) that we wish to connect to the incomplete Diagram in
builder.
- find_any_matching_input_targets(builder: DiagramBuilder) List[LeafSystem][source]¶
Description
This function attempts to find all targets that match the input target definition, i.e.:
A system with the input port with given name
A system with the given name.
TODO(Kwesi): Compress this method and the output targets method?
- builder: DiagramBuilder
Contains the partially built Diagram.
Returns
- matching_systems_list: List[LeafSystem]
A list of all systems that match the constraints/target definition.
- find_any_matching_output_targets(builder: DiagramBuilder) List[LeafSystem][source]¶
Description
This function attempts to find all targets that match the output target definition, i.e.:
A system with the output port with given name
A system with the given name.
Parameters
- builder: DiagramBuilder
Contains the partially built Diagram.
Returns
- matching_systems_list: List[LeafSystem]
A list of all systems that match the constraints/target definition.
Functions¶
(None found)
Variables¶
(None found)