|
282 | 282 | <p>(1) If you need a minimal-state representation for motion planning, mathematical optimization, or similar, then you can either use a continuous-time plant or set the config option <code>use_sampled_output_ports=false</code> on a discrete-time plant.</p> |
283 | 283 | <p>(2) By default, setting the positions of a discrete-time plant in the Context will not have any effect on the dynamics-related output ports, e.g., the contact results will not change. If you need to see changes to outputs without running the plant in a Simulator, then you can either use a continuous-time plant, set the config option <code>use_sampled_output_ports=false</code>, or use <a class="el" href="classdrake_1_1systems_1_1_system.html#a90b36c14bbcdf47bf14f2906e18573ca" title="This method triggers all of the forced events registered with this System (which might be a Diagram).">ExecuteForcedEvents()</a> to force a dynamics step and then the outputs (and positions) will change.</p> |
284 | 284 | <p><a class="anchor" id="mbp_actuation"></a></p><h3>Actuation</h3> |
285 | | -<p>In a MultibodyPlant model an actuator can be added as a <a class="el" href="classdrake_1_1multibody_1_1_joint_actuator.html" title="The JointActuator class is mostly a simple bookkeeping structure to represent an actuator acting on a...">JointActuator</a>, see <a class="el" href="classdrake_1_1multibody_1_1_multibody_plant.html#af528f7747dc75227fdec76aba89e7d2b" title="Creates and adds a JointActuator model for an actuator acting on a given joint.">AddJointActuator()</a>. The plant declares actuation input ports to provide feedforward actuation, both for the MultibodyPlant as a whole (see <a class="el" href="classdrake_1_1multibody_1_1_multibody_plant.html#a1cc1d71e6c2e91fcd215105ae4ed01e4" title="Returns a constant reference to the input port for external actuation for all actuated dofs.">get_actuation_input_port()</a>) and for each individual <a class="el" href="classdrake_1_1multibody_1_1_multibody_plant.html#model_instances">model instance</a> in the MultibodyPlant (see <a class="el" href="classdrake_1_1multibody_1_1_multibody_plant.html#a8c9e7974ae1d996a6ca3430893bd5df2">get_actuation_input_port(ModelInstanceIndex)</a>). Any actuation input ports not connected are assumed to be zero. Actuation values from the full MultibodyPlant model port (<a class="el" href="classdrake_1_1multibody_1_1_multibody_plant.html#a1cc1d71e6c2e91fcd215105ae4ed01e4" title="Returns a constant reference to the input port for external actuation for all actuated dofs.">get_actuation_input_port()</a>) and from the per model-instance ports ( <a class="el" href="classdrake_1_1multibody_1_1_multibody_plant.html#a8c9e7974ae1d996a6ca3430893bd5df2">get_actuation_input_port(ModelInstanceIndex)</a>) are summed up.</p> |
| 285 | +<p>In a MultibodyPlant model an actuator can be added as a <a class="el" href="classdrake_1_1multibody_1_1_joint_actuator.html" title="The JointActuator class is mostly a simple bookkeeping structure to represent an actuator acting on a...">JointActuator</a>, see <a class="el" href="classdrake_1_1multibody_1_1_multibody_plant.html#af528f7747dc75227fdec76aba89e7d2b" title="Creates and adds a JointActuator model for an actuator acting on a given joint.">AddJointActuator()</a>. The plant declares actuation input ports to provide feedforward actuation, both for the MultibodyPlant as a whole (see <a class="el" href="classdrake_1_1multibody_1_1_multibody_plant.html#a1cc1d71e6c2e91fcd215105ae4ed01e4" title="Returns a constant reference to the input port for external actuation for all actuated dofs.">get_actuation_input_port()</a>) and for each individual <a class="el" href="classdrake_1_1multibody_1_1_multibody_plant.html#model_instances">model instance</a> in the MultibodyPlant (see <a class="el" href="classdrake_1_1multibody_1_1_multibody_plant.html#a8c9e7974ae1d996a6ca3430893bd5df2">get_actuation_input_port(ModelInstanceIndex)</a>).</p><ul> |
| 286 | +<li>Actuation inputs and actuation effort limits are taken to be in joint coordinates (they are not affected by the actuator gear ratio).</li> |
| 287 | +<li>Any actuation input ports not connected are assumed to be zero.</li> |
| 288 | +<li>Actuation values from the full MultibodyPlant model port (<a class="el" href="classdrake_1_1multibody_1_1_multibody_plant.html#a1cc1d71e6c2e91fcd215105ae4ed01e4" title="Returns a constant reference to the input port for external actuation for all actuated dofs.">get_actuation_input_port()</a>) and from the per model-instance ports ( <a class="el" href="classdrake_1_1multibody_1_1_multibody_plant.html#a8c9e7974ae1d996a6ca3430893bd5df2">get_actuation_input_port(ModelInstanceIndex)</a>) are summed up.</li> |
| 289 | +</ul> |
286 | 290 | <dl class="section note"><dt>Note</dt><dd>A <a class="el" href="classdrake_1_1multibody_1_1_joint_actuator.html" title="The JointActuator class is mostly a simple bookkeeping structure to represent an actuator acting on a...">JointActuator</a>'s index into the vector data supplied to MultibodyPlant's actuation input port for all actuators (<a class="el" href="classdrake_1_1multibody_1_1_multibody_plant.html#a1cc1d71e6c2e91fcd215105ae4ed01e4" title="Returns a constant reference to the input port for external actuation for all actuated dofs.">get_actuation_input_port()</a>) is given by <a class="el" href="classdrake_1_1multibody_1_1_joint_actuator.html#a42d883dde11e65819319f8060b0843b4" title="Returns the index to the first element for this joint actuator / within the vector of actuation input...">JointActuator::input_start()</a>, NOT by its JointActuatorIndex. That is, the vector element data for a <a class="el" href="classdrake_1_1multibody_1_1_joint_actuator.html" title="The JointActuator class is mostly a simple bookkeeping structure to represent an actuator acting on a...">JointActuator</a> at index JointActuatorIndex(i) in the full input port vector is found at index: MultibodyPlant::get_joint_actuator(JointActuatorIndex(i)).input_start(). For the <a class="el" href="classdrake_1_1multibody_1_1_multibody_plant.html#a8c9e7974ae1d996a6ca3430893bd5df2">get_actuation_input_port(ModelInstanceIndex)</a> specific to a model index, the vector data is ordered by monotonically increasing <a class="el" href="namespacedrake_1_1multibody.html#acc810ff385ed4dede2e011b0b6fd3f2c">JointActuatorIndex</a> for the actuators within that model instance: the 0ᵗʰ vector element corresponds to the lowest-numbered JointActuatorIndex of that instance, the 1ˢᵗ vector element corresponds to the second-lowest-numbered JointActuatorIndex of that instance, etc.</dd> |
287 | 291 | <dd> |
288 | 292 | The following snippet shows how per model instance actuation can be set: <div class="fragment"><div class="line"><a class="code" href="namespacedrake_1_1multibody.html#af65439a17091283a89eb12f1955c6db0">ModelInstanceIndex</a> model_instance_index = ...;</div><div class="line">VectorX<T> u_instance(plant.num_actuated_dofs(model_instance_index));</div><div class="line"><span class="keywordtype">int</span> offset = 0;</div><div class="line"><span class="keywordflow">for</span> (<a class="code" href="namespacedrake_1_1multibody.html#acc810ff385ed4dede2e011b0b6fd3f2c">JointActuatorIndex</a> joint_actuator_index :</div><div class="line"> plant.GetJointActuatorIndices(model_instance_index)) {</div><div class="line"> <span class="keyword">const</span> JointActuator<T>& actuator = plant.get_joint_actuator(</div><div class="line"> joint_actuator_index);</div><div class="line"> <span class="keyword">const</span> Joint<T>& joint = actuator.joint();</div><div class="line"> VectorX<T> u_joint = ... my_actuation_logic_for(joint) ...;</div><div class="line"> ASSERT(u_joint.size() == joint_actuator.num_inputs());</div><div class="line"> u_instance.segment(offset, u_joint.size()) = u_joint;</div><div class="line"> offset += u_joint.size();</div><div class="line">}</div><div class="line">plant.get_actuation_input_port(model_instance_index).FixValue(</div><div class="line"> plant_context, u_instance);</div></div><!-- fragment --></dd> |
@@ -389,6 +393,7 @@ <h4>Net actuation</h4> |
389 | 393 | </ul> |
390 | 394 | </li> |
391 | 395 | </ul> |
| 396 | +<dl class="section warning"><dt>Warning</dt><dd>Subclassing <a class="el" href="classdrake_1_1multibody_1_1_multibody_plant.html" title="MultibodyPlant is a Drake system framework representation (see systems::System) for the model of a ph...">MultibodyPlant</a> is deprecated; it will be marked <code>final</code> or or after 2025-05-01.</dd></dl> |
392 | 397 | <p><a class="anchor" id="mbp_table_of_contents"></a> <a class="anchor" id="mbp_references"></a></p><h3>References</h3> |
393 | 398 | <ul> |
394 | 399 | <li>[Featherstone 2008] Featherstone, R., 2008. Rigid body dynamics algorithms. Springer.</li> |
|
0 commit comments