puppetmaker¶
Submodules¶
Classes¶
- class brom_drake.utils.puppetmaker.configuration.Configuration(frame_on_parent: pydrake.multibody.tree.Frame, name: str, frame_on_child: pydrake.multibody.tree.Frame = None, sphere_radius: float = 0.1, sphere_color: numpy.ndarray = None, sphere_mass: float = 0.001, create_actuators_on_init: bool = True)[source]¶
- class brom_drake.utils.puppetmaker.puppet_signature.AllJointSignatures(prismatic: List[brom_drake.utils.puppetmaker.puppet_signature.PuppeteerJointSignature], revolute: List[brom_drake.utils.puppetmaker.puppet_signature.PuppeteerJointSignature])[source]¶
- class brom_drake.utils.puppetmaker.puppet_signature.PuppeteerJointSignature(joint: pydrake.multibody.tree.Joint, joint_actuator: pydrake.multibody.tree.JointActuator)[source]¶
- class brom_drake.utils.puppetmaker.puppet_signature.PuppetSignature(name: str, model_instance_index: pydrake.multibody.tree.ModelInstanceIndex, prismatic_ghost_bodies: List[pydrake.multibody.tree.ModelInstanceIndex], revolute_ghost_bodies: List[pydrake.multibody.tree.ModelInstanceIndex], joints: brom_drake.utils.puppetmaker.puppet_signature.AllJointSignatures)[source]¶
- class brom_drake.utils.puppetmaker.puppetmaker.Puppetmaker(plant: MultibodyPlant, puppet_anchored_to: Frame = None, frame_on_puppet: Frame = None, name: str = None, sphere_radius: float = None, config: Configuration = None)[source]¶
Description
This class turns a “free body” in Drake into a “puppet” whose pose and orientation can be controlled using 6 actuated joints (3 prismatic and 3 revolute).
This object is used to:
Add “invisible” actuators for moving a free body (i.e., add_strings_for or add_actuators_for), and
Control actuate a free body that has been added with the expected “puppet” actuators (i.e., `add_puppet_controller_for)
Important
The 2 functions of the puppetmaker are designed to be used at different times. The add_strings_for or add_actuators_for methods MUST be called BEFORE finalizing the plant. The add_puppet_controller_for method MUST be called AFTER finalizing the plant.
Notes
The puppet is assumed to be a free body (i.e., it has no existing joints connecting it to the world). After adding the puppet actuators, the puppet will NO LONGER be a free body.
You must call add_strings_for or add_actuators_for BEFORE finalizing the plant.
- add_actuated_prismatic_joint(axis_dimension: int, previous_frame: Frame, next_frame: Frame, joint_name: str) Tuple[PrismaticJoint, JointActuator][source]¶
Description
This method will add an prismatic joint in the direction axis_dimension between previous_frame and next_frame, along with an actuator to control it.
Parameters
- axis_dimension: int
The axis to translate in (0 for X, 1 for Y, 2 for Z).
- previous_frame: Frame
The frame of the parent side of the joint.
- next_frame: Frame
The frame of the child side of the joint.
- joint_name: str
The name of the joint we are creating.
Returns
- translation_joint_ii: PrismaticJoint
The created prismatic joint.
- translation_actuator_ii: JointActuator
The created actuator for the prismatic joint.
- add_actuated_revolute_joint(angle_type: RollPitchYawAngle, previous_frame: Frame, next_frame: Frame, joint_name: str) Tuple[Joint, JointActuator][source]¶
Description
This method will add a revolute joint in the direction axis_dimension between previous_frame and next_frame, along with an actuator to control it.
Parameters
- axis_dimension: int
The axis to rotate about
- add_actuators_for(target_model: ModelInstanceIndex) PuppetSignature[source]¶
Description
Creates actuated joints on the object we want to be the “puppet” so that we can control its entire pose. This will be 6 joints:
Translation in X
Translation In Y
Translation In Z
Rotation (Roll)
Rotation (Pitch)
Rotation (Yaw)
Parameters
- target_model: pydrake.multibody.tree.ModelInstanceIndex
The model instance index of the puppet to add actuators for.
- add_all_actuated_revolute_joints(target_model: ModelInstanceIndex, massless_sphere_indices: List[ModelInstanceIndex]) List[PuppeteerJointSignature][source]¶
Description
This function creates the 3 actuated revolute joints needed to control the orientation of the puppet.
Because the puppet’s orientation is controlled using roll-pitch-yaw angles, the order of the revolute joints will correspond to the standard body rotation order for roll-pitch-yaw (note this is not roll first, then pitch, then yaw).
Notes
This function expects 3 massless sphere inputs. The first sphere in the list should be the one representing the last translation sphere (i.e., the one we should connect the first revolute sphere to.)
- add_feedforward_sum_system_for(signature: PuppetSignature, builder: DiagramBuilder) Tuple[Adder, ConstantVectorSource][source]¶
Description¶
This method will create a simple Adder system to add feedforward inputs to the PID controller output.
- add_massless_sphere_to_plant_with_name(name: str, color: ndarray = None) ModelInstanceIndex[source]¶
Description
This method adds a sphere with:
nearly zero mass
no collision geometry,
and an associated color
to the Puppeteer’s plant.
The sphere’s name will be assigned by the input to the function.
- add_puppet_controller_for(signature: PuppetSignature, builder: DiagramBuilder, Kp: ndarray = None, Kd: ndarray = None) Tuple[RigidTransformToVectorSystem, PassThrough | None][source]¶
Description
This method will create a simple PID controller to actuate the puppet to a desired pose.
Parameters
- signaturePuppetSignature
The signature of the puppet to be controlled.
- builderDiagramBuilder
The diagram builder to add the controller to.
- Kpnp.ndarray, optional
The proportional gain for the PID controller. If not provided, a default value will be used.
- Kdnp.ndarray, optional
The derivative gain for the PID controller. If not provided, a default value will be used.
Returns
- pose_to_vector_systemRigidTransformToVectorSystem
The system that converts the desired pose to a vector format. This system is what provides the target to the PID controller. You can think of this as the “reference” signal for the controller.
- passthrough_systemPassThrough|None
A passthrough system that can be used to provide inputs to the “puppet” if the Puppet contains actuated joints. If the puppet does not contain any actuated joints, then this will be None.
- add_strings_for(target_model: ModelInstanceIndex) PuppetSignature[source]¶
Description
Adds the necessary actuators for the puppet’s joints.
Parameters
- target_model: pydrake.multibody.tree.ModelInstanceIndex
The model instance index of the puppet to add actuators for.
- combine_feedforward_and_controller_for(builder: DiagramBuilder, feedforward_adder: Adder, controller: PidController) Tuple[Adder, ConstantVectorSource][source]¶
Description¶
This method will connect the output of the PID controller to one input of the feedforward adder.
- connect_plant_to_controller(builder: DiagramBuilder, controller: PidController, signature: PuppetSignature) None[source]¶
Description
Connect the plant to the controller.
- create_actuator_demux(signature: PuppetSignature, builder: DiagramBuilder) Tuple[Demultiplexer, PassThrough | None][source]¶
Description
This method creates a demultiplexer to split the actuator inputs to the puppet’s various models.
- create_actuator_passthrough_for_puppet_with_actuated_joints(signature: PuppetSignature, builder: DiagramBuilder) Tuple[PassThrough, PassThrough][source]¶
Description
This method creates two passthrough systems: 1. passes the “default” actuator inputs for the puppet’s (default) actuated joints, 2. passes the “puppet” actuator input for puppeteering.
Returns
- default_actuator_inputs_passthroughPassThrough
A passthrough system that passes the default actuator inputs for the puppet’s (default) actuated joints.
- puppet_actuator_inputPassThrough
A passthrough system that passes the puppet actuator input for puppeteering.
- create_ghost_bodies_for_actuators() Tuple[List[ModelInstanceIndex], List[ModelInstanceIndex]][source]¶
Description¶
This method creates a set of simple spheres which we will use to connect actuators to the “puppet”. We will reuse the simple shape API’s in Brom to create a set of new URDFs that will have (i) no mass, and (ii) no collision geometry.
- find_index_of_position_state_in(model_instance_index: ModelInstanceIndex, signature: PuppetSignature) int | None[source]¶
Description¶
This method finds the names of the “position” component for the state of the joint connected to model_instance_index.
- find_index_of_velocity_state_in(model_instance_index: ModelInstanceIndex, signature: PuppetSignature) int | None[source]¶
Description
This method finds the names of the “velocity” component for the state of the joint connected to model_instance_index.
Parameters
- model_instance_index: pydrake.multibody.tree.ModelInstanceIndex
The model instance index of the model to search through.
- signature: PuppetSignature
The signature of the puppet being controlled.
- rotation_joint_name(target_model: ModelInstanceIndex, rpy_selection: RollPitchYawAngle, remove_puppeteer_prefix: bool = False) str[source]¶
Description
This method returns the name of a specific rotation joint created for the puppet.
Parameters
- target_model: pydrake.multibody.tree.ModelInstanceIndex
The model instance index of the puppet.
- axis_dimension: int
The axis dimension (0, 1, or 2) corresponding to the rotation joint to get the name for.
- remove_puppeteer_prefix: bool, optional
If True, the returned joint name will not include the puppeteer prefix. Default is False.
- rotation_joint_names(target_model: ModelInstanceIndex, remove_puppeteer_prefix: bool = False) List[str][source]¶
Description
This method returns the names of all rotation joints created for the puppet.
Parameters
- target_model: pydrake.multibody.tree.ModelInstanceIndex
The model instance index of the puppet.
- remove_puppeteer_prefix: bool, optional
If True, the returned joint names will not include the puppeteer prefix. Default is False.
Functions¶
(None found)
Variables¶
(None found)