Skip to content

Commit

Permalink
deploy: 281f9b0
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhoeller19 committed Nov 1, 2024
1 parent 7653c7f commit dc45451
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 70 deletions.
10 changes: 9 additions & 1 deletion main/_modules/omni/isaac/lab/actuators/actuator_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,7 @@ <h1>Source code for omni.isaac.lab.actuators.actuator_base</h1><div class="highl
<span class="sd"> TypeError: If the parameter value is not of the expected type.</span>
<span class="sd"> TypeError: If the default value is not of the expected type.</span>
<span class="sd"> ValueError: If the parameter value is None and no default value is provided.</span>
<span class="sd"> ValueError: If the default value tensor is the wrong shape.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># create parameter buffer</span>
<span class="n">param</span> <span class="o">=</span> <span class="n">torch</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_num_envs</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">num_joints</span><span class="p">,</span> <span class="n">device</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_device</span><span class="p">)</span>
Expand All @@ -729,7 +730,14 @@ <h1>Source code for omni.isaac.lab.actuators.actuator_base</h1><div class="highl
<span class="n">param</span><span class="p">[:]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">default_value</span><span class="p">)</span>
<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">default_value</span><span class="p">,</span> <span class="n">torch</span><span class="o">.</span><span class="n">Tensor</span><span class="p">):</span>
<span class="c1"># if tensor, then use the same tensor for all joints</span>
<span class="n">param</span><span class="p">[:]</span> <span class="o">=</span> <span class="n">default_value</span><span class="o">.</span><span class="n">float</span><span class="p">()</span>
<span class="k">if</span> <span class="n">default_value</span><span class="o">.</span><span class="n">shape</span> <span class="o">==</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_num_envs</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">num_joints</span><span class="p">):</span>
<span class="n">param</span> <span class="o">=</span> <span class="n">default_value</span><span class="o">.</span><span class="n">float</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
<span class="s2">&quot;Invalid default value tensor shape.</span><span class="se">\n</span><span class="s2">&quot;</span>
<span class="sa">f</span><span class="s2">&quot;Got: </span><span class="si">{</span><span class="n">default_value</span><span class="o">.</span><span class="n">shape</span><span class="si">}</span><span class="se">\n</span><span class="s2">&quot;</span>
<span class="sa">f</span><span class="s2">&quot;Expected: </span><span class="si">{</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_num_envs</span><span class="p">,</span><span class="w"> </span><span class="bp">self</span><span class="o">.</span><span class="n">num_joints</span><span class="p">)</span><span class="si">}</span><span class="s2">&quot;</span>
<span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Invalid type for default value: </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">default_value</span><span class="p">)</span><span class="si">}</span><span class="s2"> for &quot;</span>
Expand Down
33 changes: 13 additions & 20 deletions main/_modules/omni/isaac/lab/assets/articulation/articulation.html
Original file line number Diff line number Diff line change
Expand Up @@ -1604,12 +1604,10 @@ <h1>Source code for omni.isaac.lab.assets.articulation.articulation</h1><div cla
<span class="bp">self</span><span class="o">.</span><span class="n">_has_implicit_actuators</span> <span class="o">=</span> <span class="kc">False</span>

<span class="c1"># cache the values coming from the usd</span>
<span class="n">usd_stiffness</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">root_physx_view</span><span class="o">.</span><span class="n">get_dof_stiffnesses</span><span class="p">()</span><span class="o">.</span><span class="n">clone</span><span class="p">()</span>
<span class="n">usd_damping</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">root_physx_view</span><span class="o">.</span><span class="n">get_dof_dampings</span><span class="p">()</span><span class="o">.</span><span class="n">clone</span><span class="p">()</span>
<span class="n">usd_armature</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">root_physx_view</span><span class="o">.</span><span class="n">get_dof_armatures</span><span class="p">()</span><span class="o">.</span><span class="n">clone</span><span class="p">()</span>
<span class="n">usd_friction</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">root_physx_view</span><span class="o">.</span><span class="n">get_dof_friction_coefficients</span><span class="p">()</span><span class="o">.</span><span class="n">clone</span><span class="p">()</span>
<span class="n">usd_effort_limit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">root_physx_view</span><span class="o">.</span><span class="n">get_dof_max_forces</span><span class="p">()</span><span class="o">.</span><span class="n">clone</span><span class="p">()</span>
<span class="n">usd_velocity_limit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">root_physx_view</span><span class="o">.</span><span class="n">get_dof_max_velocities</span><span class="p">()</span><span class="o">.</span><span class="n">clone</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="o">.</span><span class="n">default_joint_stiffness</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">root_physx_view</span><span class="o">.</span><span class="n">get_dof_stiffnesses</span><span class="p">()</span><span class="o">.</span><span class="n">to</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">device</span><span class="p">)</span><span class="o">.</span><span class="n">clone</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="o">.</span><span class="n">default_joint_damping</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">root_physx_view</span><span class="o">.</span><span class="n">get_dof_dampings</span><span class="p">()</span><span class="o">.</span><span class="n">to</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">device</span><span class="p">)</span><span class="o">.</span><span class="n">clone</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="o">.</span><span class="n">default_joint_armature</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">root_physx_view</span><span class="o">.</span><span class="n">get_dof_armatures</span><span class="p">()</span><span class="o">.</span><span class="n">to</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">device</span><span class="p">)</span><span class="o">.</span><span class="n">clone</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="o">.</span><span class="n">default_joint_friction</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">root_physx_view</span><span class="o">.</span><span class="n">get_dof_friction_coefficients</span><span class="p">()</span><span class="o">.</span><span class="n">to</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">device</span><span class="p">)</span><span class="o">.</span><span class="n">clone</span><span class="p">()</span>

<span class="c1"># iterate over all actuator configurations</span>
<span class="k">for</span> <span class="n">actuator_name</span><span class="p">,</span> <span class="n">actuator_cfg</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">cfg</span><span class="o">.</span><span class="n">actuators</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
Expand All @@ -1633,12 +1631,12 @@ <h1>Source code for omni.isaac.lab.assets.articulation.articulation</h1><div cla
<span class="p">),</span>
<span class="n">num_envs</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">num_instances</span><span class="p">,</span>
<span class="n">device</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">device</span><span class="p">,</span>
<span class="n">stiffness</span><span class="o">=</span><span class="n">usd_stiffness</span><span class="p">[:,</span> <span class="n">joint_ids</span><span class="p">],</span>
<span class="n">damping</span><span class="o">=</span><span class="n">usd_damping</span><span class="p">[:,</span> <span class="n">joint_ids</span><span class="p">],</span>
<span class="n">armature</span><span class="o">=</span><span class="n">usd_armature</span><span class="p">[:,</span> <span class="n">joint_ids</span><span class="p">],</span>
<span class="n">friction</span><span class="o">=</span><span class="n">usd_friction</span><span class="p">[:,</span> <span class="n">joint_ids</span><span class="p">],</span>
<span class="n">effort_limit</span><span class="o">=</span><span class="n">usd_effort_limit</span><span class="p">[:,</span> <span class="n">joint_ids</span><span class="p">],</span>
<span class="n">velocity_limit</span><span class="o">=</span><span class="n">usd_velocity_limit</span><span class="p">[:,</span> <span class="n">joint_ids</span><span class="p">],</span>
<span class="n">stiffness</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="o">.</span><span class="n">default_joint_stiffness</span><span class="p">[:,</span> <span class="n">joint_ids</span><span class="p">],</span>
<span class="n">damping</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="o">.</span><span class="n">default_joint_damping</span><span class="p">[:,</span> <span class="n">joint_ids</span><span class="p">],</span>
<span class="n">armature</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="o">.</span><span class="n">default_joint_armature</span><span class="p">[:,</span> <span class="n">joint_ids</span><span class="p">],</span>
<span class="n">friction</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="o">.</span><span class="n">default_joint_friction</span><span class="p">[:,</span> <span class="n">joint_ids</span><span class="p">],</span>
<span class="n">effort_limit</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">root_physx_view</span><span class="o">.</span><span class="n">get_dof_max_forces</span><span class="p">()</span><span class="o">.</span><span class="n">to</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">device</span><span class="p">)</span><span class="o">.</span><span class="n">clone</span><span class="p">()[:,</span> <span class="n">joint_ids</span><span class="p">],</span>
<span class="n">velocity_limit</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">root_physx_view</span><span class="o">.</span><span class="n">get_dof_max_velocities</span><span class="p">()</span><span class="o">.</span><span class="n">to</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">device</span><span class="p">)</span><span class="o">.</span><span class="n">clone</span><span class="p">()[:,</span> <span class="n">joint_ids</span><span class="p">],</span>
<span class="p">)</span>
<span class="c1"># log information on actuator groups</span>
<span class="n">omni</span><span class="o">.</span><span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span>
Expand All @@ -1664,14 +1662,9 @@ <h1>Source code for omni.isaac.lab.assets.articulation.articulation</h1><div cla
<span class="bp">self</span><span class="o">.</span><span class="n">write_joint_effort_limit_to_sim</span><span class="p">(</span><span class="mf">1.0e9</span><span class="p">,</span> <span class="n">joint_ids</span><span class="o">=</span><span class="n">actuator</span><span class="o">.</span><span class="n">joint_indices</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">write_joint_armature_to_sim</span><span class="p">(</span><span class="n">actuator</span><span class="o">.</span><span class="n">armature</span><span class="p">,</span> <span class="n">joint_ids</span><span class="o">=</span><span class="n">actuator</span><span class="o">.</span><span class="n">joint_indices</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">write_joint_friction_to_sim</span><span class="p">(</span><span class="n">actuator</span><span class="o">.</span><span class="n">friction</span><span class="p">,</span> <span class="n">joint_ids</span><span class="o">=</span><span class="n">actuator</span><span class="o">.</span><span class="n">joint_indices</span><span class="p">)</span>

<span class="c1"># set the default joint parameters based on the changes from the actuators</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="o">.</span><span class="n">default_joint_stiffness</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">root_physx_view</span><span class="o">.</span><span class="n">get_dof_stiffnesses</span><span class="p">()</span><span class="o">.</span><span class="n">to</span><span class="p">(</span><span class="n">device</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">device</span><span class="p">)</span><span class="o">.</span><span class="n">clone</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="o">.</span><span class="n">default_joint_damping</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">root_physx_view</span><span class="o">.</span><span class="n">get_dof_dampings</span><span class="p">()</span><span class="o">.</span><span class="n">to</span><span class="p">(</span><span class="n">device</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">device</span><span class="p">)</span><span class="o">.</span><span class="n">clone</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="o">.</span><span class="n">default_joint_armature</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">root_physx_view</span><span class="o">.</span><span class="n">get_dof_armatures</span><span class="p">()</span><span class="o">.</span><span class="n">to</span><span class="p">(</span><span class="n">device</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">device</span><span class="p">)</span><span class="o">.</span><span class="n">clone</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="o">.</span><span class="n">default_joint_friction</span> <span class="o">=</span> <span class="p">(</span>
<span class="bp">self</span><span class="o">.</span><span class="n">root_physx_view</span><span class="o">.</span><span class="n">get_dof_friction_coefficients</span><span class="p">()</span><span class="o">.</span><span class="n">to</span><span class="p">(</span><span class="n">device</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">device</span><span class="p">)</span><span class="o">.</span><span class="n">clone</span><span class="p">()</span>
<span class="p">)</span>
<span class="c1"># Store the actual default stiffness and damping values for explicit actuators (not written the sim)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="o">.</span><span class="n">default_joint_stiffness</span><span class="p">[:,</span> <span class="n">actuator</span><span class="o">.</span><span class="n">joint_indices</span><span class="p">]</span> <span class="o">=</span> <span class="n">actuator</span><span class="o">.</span><span class="n">stiffness</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="o">.</span><span class="n">default_joint_damping</span><span class="p">[:,</span> <span class="n">actuator</span><span class="o">.</span><span class="n">joint_indices</span><span class="p">]</span> <span class="o">=</span> <span class="n">actuator</span><span class="o">.</span><span class="n">damping</span>

<span class="c1"># perform some sanity checks to ensure actuators are prepared correctly</span>
<span class="n">total_act_joints</span> <span class="o">=</span> <span class="nb">sum</span><span class="p">(</span><span class="n">actuator</span><span class="o">.</span><span class="n">num_joints</span> <span class="k">for</span> <span class="n">actuator</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">actuators</span><span class="o">.</span><span class="n">values</span><span class="p">())</span>
Expand Down
Loading

0 comments on commit dc45451

Please sign in to comment.