Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
drake-jenkins-bot committed Feb 11, 2025
1 parent cceea55 commit 6e792c1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 20 deletions.
4 changes: 2 additions & 2 deletions doxygen_cxx/classdrake_1_1_identifier.html
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
class drake::Identifier&lt; Tag &gt;</h3>

<p>A simple identifier class. </p>
<dl class="section note"><dt>Note</dt><dd>This is <em>purposely</em> a separate class from <a class="el" href="classdrake_1_1_type_safe_index.html">TypeSafeIndex</a>. For more explanatation, see <a class="el" href="classdrake_1_1_identifier.html#TypeSafeIndexVsIndentifier">this section</a>.</dd></dl>
<dl class="section note"><dt>Note</dt><dd>This is <em>purposely</em> a separate class from <a class="el" href="classdrake_1_1_type_safe_index.html">TypeSafeIndex</a>. For more explanation, see <a class="el" href="classdrake_1_1_identifier.html#TypeSafeIndexVsIdentifier">this section</a>.</dd></dl>
<p>This class serves as an upgrade to the standard practice of passing <code>int</code>s around as unique identifiers (or, as in this case, <code>int64_t</code>s). In the common practice, a method that takes identifiers to different types of objects would have an interface like:</p>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> foo(<a class="code" href="classint64__t.html">int64_t</a> bar_id, <a class="code" href="classint64__t.html">int64_t</a> thing_id);</div></div><!-- fragment --><p>It is possible for a programmer to accidentally switch the two ids in an invocation. This mistake would still be <em>syntactically</em> correct; it will successfully compile but lead to inscrutable run-time errors. This identifier class provides the same speed and efficiency of passing <code>int64_t</code>s, but enforces unique types and limits the valid operations, providing compile-time checking. The function would now look like:</p>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> foo(BarId bar_id, ThingId thing_id)</div></div><!-- fragment --><p>and the compiler will catch instances where the order is reversed.</p>
Expand All @@ -195,7 +195,7 @@
<p>It is the designed intent of this class, that ids derived from this class can be passed and returned by value. (Drake's typical calling convention requires passing input arguments by const reference, or by value when moved from. That convention does not apply to this class.)</p>
<p>The following alias will create a unique identifier type for class <code>Foo</code>: </p><div class="fragment"><div class="line"><span class="keyword">using</span> FooId = Identifier&lt;class FooTag&gt;;</div></div><!-- fragment --><p><b>Examples of valid and invalid operations</b></p>
<p>The Identifier guarantees that id instances of different types can't be compared or combined. Efforts to do so will cause a compile-time failure. For example:</p>
<div class="fragment"><div class="line"><span class="keyword">using</span> AId = Identifier&lt;class ATag&gt;;</div><div class="line"><span class="keyword">using</span> BId = Identifier&lt;class BTag&gt;;</div><div class="line">AId a1; <span class="comment">// Compiler error; there is no</span></div><div class="line"> <span class="comment">// default constructor.</span></div><div class="line">AId a2 = AId::get_new_id(); <span class="comment">// Ok.</span></div><div class="line">AId a3(a2); <span class="comment">// Ok.</span></div><div class="line">AId a4 = AId::get_new_id(); <span class="comment">// Ok.</span></div><div class="line">BId b = BId::get_new_id(); <span class="comment">// Ok.</span></div><div class="line"><span class="keywordflow">if</span> ( a2 == 1 ) { ... } <span class="comment">// Compiler error.</span></div><div class="line"><span class="keywordflow">if</span> ( a2 == a4 ) { ... } <span class="comment">// Ok, evaluates to false.</span></div><div class="line"><span class="keywordflow">if</span> ( a2 == a3 ) { ... } <span class="comment">// Ok, evaluates to true.</span></div><div class="line"><span class="keywordflow">if</span> ( a2 == b ) { ... } <span class="comment">// Compiler error.</span></div><div class="line">a4 = a2; <span class="comment">// Ok.</span></div><div class="line">a3 = 7; <span class="comment">// Compiler error.</span></div></div><!-- fragment --><p><a class="anchor" id="TypeSafeIndexVsIndentifier"></a><b><a class="el" href="classdrake_1_1_type_safe_index.html" title="A type-safe non-negative index class.">TypeSafeIndex</a> vs <a class="el" href="classdrake_1_1_identifier.html" title="A simple identifier class.">Identifier</a></b></p>
<div class="fragment"><div class="line"><span class="keyword">using</span> AId = Identifier&lt;class ATag&gt;;</div><div class="line"><span class="keyword">using</span> BId = Identifier&lt;class BTag&gt;;</div><div class="line">AId a1; <span class="comment">// Compiler error; there is no</span></div><div class="line"> <span class="comment">// default constructor.</span></div><div class="line">AId a2 = AId::get_new_id(); <span class="comment">// Ok.</span></div><div class="line">AId a3(a2); <span class="comment">// Ok.</span></div><div class="line">AId a4 = AId::get_new_id(); <span class="comment">// Ok.</span></div><div class="line">BId b = BId::get_new_id(); <span class="comment">// Ok.</span></div><div class="line"><span class="keywordflow">if</span> ( a2 == 1 ) { ... } <span class="comment">// Compiler error.</span></div><div class="line"><span class="keywordflow">if</span> ( a2 == a4 ) { ... } <span class="comment">// Ok, evaluates to false.</span></div><div class="line"><span class="keywordflow">if</span> ( a2 == a3 ) { ... } <span class="comment">// Ok, evaluates to true.</span></div><div class="line"><span class="keywordflow">if</span> ( a2 == b ) { ... } <span class="comment">// Compiler error.</span></div><div class="line">a4 = a2; <span class="comment">// Ok.</span></div><div class="line">a3 = 7; <span class="comment">// Compiler error.</span></div></div><!-- fragment --><p><a class="anchor" id="TypeSafeIndexVsIdentifier"></a><b><a class="el" href="classdrake_1_1_type_safe_index.html" title="A type-safe non-negative index class.">TypeSafeIndex</a> vs <a class="el" href="classdrake_1_1_identifier.html" title="A simple identifier class.">Identifier</a></b></p>
<p>In principle, the <em>identifier</em> is related to the <a class="el" href="classdrake_1_1_type_safe_index.html">TypeSafeIndex</a>. In some sense, both are "type-safe" <code>int</code>s. They differ in their semantics. We can consider <code>ints</code>, indices, and identifiers as a list of <code>int</code> types with <em>decreasing</em> functionality.</p>
<ul>
<li>The int, obviously, has the full range of C++ ints.</li>
Expand Down
2 changes: 1 addition & 1 deletion doxygen_cxx/classdrake_1_1_type_safe_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
class drake::TypeSafeIndex&lt; Tag &gt;</h3>

<p>A type-safe non-negative index class. </p>
<dl class="section note"><dt>Note</dt><dd>This is <em>purposely</em> a separate class from <a class="el" href="classdrake_1_1_identifier.html" title="A simple identifier class.">Identifier</a>. For more information, see <a class="el" href="classdrake_1_1_identifier.html#TypeSafeIndexVsIndentifier">this section</a>.</dd></dl>
<dl class="section note"><dt>Note</dt><dd>This is <em>purposely</em> a separate class from <a class="el" href="classdrake_1_1_identifier.html" title="A simple identifier class.">Identifier</a>. For more information, see <a class="el" href="classdrake_1_1_identifier.html#TypeSafeIndexVsIdentifier">this section</a>.</dd></dl>
<p>This class serves as an upgrade to the standard practice of passing <code>int</code>s around as indices. In the common practice, a method that takes indices into multiple collections would have an interface like:</p>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> foo(<span class="keywordtype">int</span> bar_index, <span class="keywordtype">int</span> thing_index);</div></div><!-- fragment --><p>It is possible for a programmer to accidentally switch the two index values in an invocation. This mistake would still be <em>syntactically</em> correct; it will successfully compile but lead to inscrutable run-time errors. The type-safe index provides the same speed and efficiency of passing <code>int</code>s, but provides compile-time checking. The function would now look like:</p>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> foo(BarIndex bar_index, ThingIndex thing_index);</div></div><!-- fragment --><p>and the compiler will catch instances where the order is reversed.</p>
Expand Down
2 changes: 1 addition & 1 deletion doxygen_cxx/classdrake_1_1geometry_1_1_scene_graph.html
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
</ul>
<h1><a class="anchor" id="geom_sys_inputs"></a>
Inputs</h1>
<p>of kinematics values (e.g., pose, velocity, acceleration, and configuration). If a source registers a frame or a deformable geometry, it must connect to the corresponding ports. Failure to connect to the ports (or to provide valid kinematics values) will lead to runtime exceptions.</p>
<p>For each registered geometry source, there is one input port for each order of kinematics values (i.e., pose and configuration). If a source registers a frame or a deformable geometry, it must connect to the corresponding ports. Failure to connect to the ports (or to provide valid kinematics values) will lead to runtime exceptions.</p>
<p><b>pose port</b>: An abstract-valued port providing an instance of FramePoseVector. For each registered frame, this "pose vector" maps the registered FrameId to a pose value. All registered frames must be accounted for and only frames registered by a source can be included in its output port. See the details in <a class="el" href="classdrake_1_1geometry_1_1_kinematics_vector.html" title="A KinematicsVector is a container class used to report kinematics data for registered frames and geom...">KinematicsVector</a> for details on how to provide values for this port.</p>
<p><b>configuration port</b>: An abstract-valued port providing an instance of GeometryConfigurationVector. For each registered deformable geometry, this "configuration vector" maps the registered <a class="el" href="classdrake_1_1geometry_1_1_geometry_id.html" title="Type used to identify geometry instances in SceneGraph.">GeometryId</a> to its world space configuration (i.e. the vertex positions of its mesh representation in the world frame). All registered deformable geometries must be accounted for and only geometries registered by a source can be included in its output port.</p>
<h1><a class="anchor" id="geom_sys_outputs"></a>
Expand Down
27 changes: 12 additions & 15 deletions pydrake/pydrake.geometry.html
Original file line number Diff line number Diff line change
Expand Up @@ -10521,11 +10521,10 @@ <h1>pydrake.geometry<a class="headerlink" href="#pydrake-geometry" title="Permal
- Implement appropriate <code class="docutils literal notranslate"><span class="pre">Calc*</span></code> methods on the geometry output ports to
update geometry pose/configuration values.</p>
<p>For each registered geometry source, there is one input port for each
order of kinematics values (e.g., pose, velocity, acceleration, and
configuration). If a source registers a frame or a deformable
geometry, it must connect to the corresponding ports. Failure to
connect to the ports (or to provide valid kinematics values) will lead
to runtime exceptions.</p>
order of kinematics values (i.e., pose and configuration). If a source
registers a frame or a deformable geometry, it must connect to the
corresponding ports. Failure to connect to the ports (or to provide
valid kinematics values) will lead to runtime exceptions.</p>
<p><strong>pose port</strong>: An abstract-valued port providing an instance of
FramePoseVector. For each registered frame, this “pose vector” maps
the registered FrameId to a pose value. All registered frames must be
Expand Down Expand Up @@ -11450,11 +11449,10 @@ <h1>pydrake.geometry<a class="headerlink" href="#pydrake-geometry" title="Permal
- Implement appropriate <code class="docutils literal notranslate"><span class="pre">Calc*</span></code> methods on the geometry output ports to
update geometry pose/configuration values.</p>
<p>For each registered geometry source, there is one input port for each
order of kinematics values (e.g., pose, velocity, acceleration, and
configuration). If a source registers a frame or a deformable
geometry, it must connect to the corresponding ports. Failure to
connect to the ports (or to provide valid kinematics values) will lead
to runtime exceptions.</p>
order of kinematics values (i.e., pose and configuration). If a source
registers a frame or a deformable geometry, it must connect to the
corresponding ports. Failure to connect to the ports (or to provide
valid kinematics values) will lead to runtime exceptions.</p>
<p><strong>pose port</strong>: An abstract-valued port providing an instance of
FramePoseVector. For each registered frame, this “pose vector” maps
the registered FrameId to a pose value. All registered frames must be
Expand Down Expand Up @@ -12368,11 +12366,10 @@ <h1>pydrake.geometry<a class="headerlink" href="#pydrake-geometry" title="Permal
- Implement appropriate <code class="docutils literal notranslate"><span class="pre">Calc*</span></code> methods on the geometry output ports to
update geometry pose/configuration values.</p>
<p>For each registered geometry source, there is one input port for each
order of kinematics values (e.g., pose, velocity, acceleration, and
configuration). If a source registers a frame or a deformable
geometry, it must connect to the corresponding ports. Failure to
connect to the ports (or to provide valid kinematics values) will lead
to runtime exceptions.</p>
order of kinematics values (i.e., pose and configuration). If a source
registers a frame or a deformable geometry, it must connect to the
corresponding ports. Failure to connect to the ports (or to provide
valid kinematics values) will lead to runtime exceptions.</p>
<p><strong>pose port</strong>: An abstract-valued port providing an instance of
FramePoseVector. For each registered frame, this “pose vector” maps
the registered FrameId to a pose value. All registered frames must be
Expand Down
2 changes: 1 addition & 1 deletion pydrake/searchindex.js

Large diffs are not rendered by default.

0 comments on commit 6e792c1

Please sign in to comment.