Add inheritrange attribute to position and intvelocity actuators.
PiperOrigin-RevId: 607650147 Change-Id: Ibc1846f89179786d4f93435c3924687b4c5d1432
This commit is contained in:
committed by
Copybara-Service
parent
5e353efaaf
commit
05150546e3
+25
-1
@@ -5430,6 +5430,20 @@ This element has one custom attribute in addition to the common attributes:
|
|||||||
Damping applied by the actuator.
|
Damping applied by the actuator.
|
||||||
When using this attribute, it is recommended to use the implicitfast or implicit :ref:`integrators<geIntegration>`.
|
When using this attribute, it is recommended to use the implicitfast or implicit :ref:`integrators<geIntegration>`.
|
||||||
|
|
||||||
|
.. _actuator-position-inheritrange:
|
||||||
|
|
||||||
|
:at:`inheritrange`: :at-val:`real, "0"`
|
||||||
|
Automatically set the actuator's :at:`ctrlrange` to match the transmission target's :at:`range`. The default value
|
||||||
|
means "disabled". A positive value :at-val:`X` sets the :at:`ctrlrange` around the midpoint of the target range,
|
||||||
|
scaled by :at-val:`X`. For example if the target joint has :at:`range` of :at-val:`[0, 1]`, then a value of
|
||||||
|
:at-val:`1.0` will set :at:`ctrlrange` to :at-val:`[0, 1]`; values of :at-val:`0.8` and :at-val:`1.2` will set the
|
||||||
|
:at:`ctrlrange` to :at-val:`[0.1, 0.9]` and :at-val:`[-0.1, 1.1]`, respectively. Values smaller than 1 are useful for
|
||||||
|
not hitting the limits; values larger than 1 are useful for maintaining control authority at the limits (being able
|
||||||
|
to push on them). This attribute is exclusive with :at:`ctrlrange` and available only for joint and tendon
|
||||||
|
transmissions which have :at:`range` defined. Note that while :at:`inheritrange` is available both as a
|
||||||
|
:ref:`position<actuator-position>` attribute and in the :ref:`default class<default-position-inheritrange>`,
|
||||||
|
saved XMLs always convert it to explicit :at:`ctrlrange` at the actuator.
|
||||||
|
|
||||||
.. _actuator-velocity:
|
.. _actuator-velocity:
|
||||||
|
|
||||||
:el-prefix:`actuator/` |-| **velocity** (*)
|
:el-prefix:`actuator/` |-| **velocity** (*)
|
||||||
@@ -5578,10 +5592,16 @@ This element has one custom attribute in addition to the common attributes:
|
|||||||
Damping applied by the actuator.
|
Damping applied by the actuator.
|
||||||
When using this attribute, it is recommended to use the implicitfast or implicit :ref:`integrators<geIntegration>`.
|
When using this attribute, it is recommended to use the implicitfast or implicit :ref:`integrators<geIntegration>`.
|
||||||
|
|
||||||
|
.. _actuator-intvelocity-inheritrange:
|
||||||
|
|
||||||
|
:at:`inheritrange`: :at-val:`real, "0"`
|
||||||
|
Identical to :ref:`position/inheritrange<actuator-position-inheritrange>`, but sets :at:`actrange` (which has the same
|
||||||
|
length semantics as the transmission target) rather than :at:`ctrlrange` (which has velocity semantics).
|
||||||
|
|
||||||
.. _actuator-damper:
|
.. _actuator-damper:
|
||||||
|
|
||||||
:el-prefix:`actuator/` |-| **damper** (*)
|
:el-prefix:`actuator/` |-| **damper** (*)
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
This element is an active damper which produces a force proportional to both velocity and control: ``F = - kv * velocity
|
This element is an active damper which produces a force proportional to both velocity and control: ``F = - kv * velocity
|
||||||
* control``, where ``kv`` must be nonnegative. :at:`ctrlrange` is required and must also be nonnegative.
|
* control``, where ``kv`` must be nonnegative. :at:`ctrlrange` is required and must also be nonnegative.
|
||||||
@@ -7728,6 +7748,8 @@ tendon, slidersite, cranksite.
|
|||||||
|
|
||||||
.. _default-position-ctrlrange:
|
.. _default-position-ctrlrange:
|
||||||
|
|
||||||
|
.. _default-position-inheritrange:
|
||||||
|
|
||||||
.. _default-position-forcerange:
|
.. _default-position-forcerange:
|
||||||
|
|
||||||
.. _default-position-gear:
|
.. _default-position-gear:
|
||||||
@@ -7788,6 +7810,8 @@ refsite, tendon, slidersite, cranksite.
|
|||||||
|
|
||||||
.. _default-intvelocity-actrange:
|
.. _default-intvelocity-actrange:
|
||||||
|
|
||||||
|
.. _default-intvelocity-inheritrange:
|
||||||
|
|
||||||
.. _default-intvelocity-gear:
|
.. _default-intvelocity-gear:
|
||||||
|
|
||||||
.. _default-intvelocity-cranklength:
|
.. _default-intvelocity-cranklength:
|
||||||
|
|||||||
+15
-13
@@ -774,13 +774,15 @@
|
|||||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||||
| | | | :ref:`name<actuator-position-name>` | :ref:`class<actuator-position-class>` | :ref:`group<actuator-position-group>` | :ref:`ctrllimited<actuator-position-ctrllimited>` | |
|
| | | | :ref:`name<actuator-position-name>` | :ref:`class<actuator-position-class>` | :ref:`group<actuator-position-group>` | :ref:`ctrllimited<actuator-position-ctrllimited>` | |
|
||||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||||
| | | | :ref:`forcelimited<actuator-position-forcelimited>` | :ref:`ctrlrange<actuator-position-ctrlrange>` | :ref:`forcerange<actuator-position-forcerange>` | :ref:`lengthrange<actuator-position-lengthrange>` | |
|
| | | | :ref:`forcelimited<actuator-position-forcelimited>` | :ref:`ctrlrange<actuator-position-ctrlrange>` | :ref:`inheritrange<actuator-position-inheritrange>` | :ref:`forcerange<actuator-position-forcerange>` | |
|
||||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||||
| | | | :ref:`gear<actuator-position-gear>` | :ref:`cranklength<actuator-position-cranklength>` | :ref:`user<actuator-position-user>` | :ref:`joint<actuator-position-joint>` | |
|
| | | | :ref:`lengthrange<actuator-position-lengthrange>` | :ref:`gear<actuator-position-gear>` | :ref:`cranklength<actuator-position-cranklength>` | :ref:`user<actuator-position-user>` | |
|
||||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||||
| | | | :ref:`jointinparent<actuator-position-jointinparent>` | :ref:`tendon<actuator-position-tendon>` | :ref:`slidersite<actuator-position-slidersite>` | :ref:`cranksite<actuator-position-cranksite>` | |
|
| | | | :ref:`joint<actuator-position-joint>` | :ref:`jointinparent<actuator-position-jointinparent>` | :ref:`tendon<actuator-position-tendon>` | :ref:`slidersite<actuator-position-slidersite>` | |
|
||||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||||
| | | | :ref:`site<actuator-position-site>` | :ref:`refsite<actuator-position-refsite>` | :ref:`kp<actuator-position-kp>` | :ref:`kv<actuator-position-kv>` | |
|
| | | | :ref:`cranksite<actuator-position-cranksite>` | :ref:`site<actuator-position-site>` | :ref:`refsite<actuator-position-refsite>` | :ref:`kp<actuator-position-kp>` | |
|
||||||
|
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||||
|
| | | | :ref:`kv<actuator-position-kv>` | | | | |
|
||||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||||
+------------------------------------+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
+------------------------------------+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||||
| |_| actuator |br| |_| |L| | | .. table:: |
|
| |_| actuator |br| |_| |L| | | .. table:: |
|
||||||
@@ -806,13 +808,13 @@
|
|||||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||||
| | | | :ref:`forcelimited<actuator-intvelocity-forcelimited>` | :ref:`ctrlrange<actuator-intvelocity-ctrlrange>` | :ref:`forcerange<actuator-intvelocity-forcerange>` | :ref:`actrange<actuator-intvelocity-actrange>` | |
|
| | | | :ref:`forcelimited<actuator-intvelocity-forcelimited>` | :ref:`ctrlrange<actuator-intvelocity-ctrlrange>` | :ref:`forcerange<actuator-intvelocity-forcerange>` | :ref:`actrange<actuator-intvelocity-actrange>` | |
|
||||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||||
| | | | :ref:`lengthrange<actuator-intvelocity-lengthrange>` | :ref:`gear<actuator-intvelocity-gear>` | :ref:`cranklength<actuator-intvelocity-cranklength>` | :ref:`user<actuator-intvelocity-user>` | |
|
| | | | :ref:`inheritrange<actuator-intvelocity-inheritrange>` | :ref:`lengthrange<actuator-intvelocity-lengthrange>` | :ref:`gear<actuator-intvelocity-gear>` | :ref:`cranklength<actuator-intvelocity-cranklength>` | |
|
||||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||||
| | | | :ref:`joint<actuator-intvelocity-joint>` | :ref:`jointinparent<actuator-intvelocity-jointinparent>` | :ref:`tendon<actuator-intvelocity-tendon>` | :ref:`slidersite<actuator-intvelocity-slidersite>` | |
|
| | | | :ref:`user<actuator-intvelocity-user>` | :ref:`joint<actuator-intvelocity-joint>` | :ref:`jointinparent<actuator-intvelocity-jointinparent>` | :ref:`tendon<actuator-intvelocity-tendon>` | |
|
||||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||||
| | | | :ref:`cranksite<actuator-intvelocity-cranksite>` | :ref:`site<actuator-intvelocity-site>` | :ref:`refsite<actuator-intvelocity-refsite>` | :ref:`kp<actuator-intvelocity-kp>` | |
|
| | | | :ref:`slidersite<actuator-intvelocity-slidersite>` | :ref:`cranksite<actuator-intvelocity-cranksite>` | :ref:`site<actuator-intvelocity-site>` | :ref:`refsite<actuator-intvelocity-refsite>` | |
|
||||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||||
| | | | :ref:`kv<actuator-intvelocity-kv>` | | | | |
|
| | | | :ref:`kp<actuator-intvelocity-kp>` | :ref:`kv<actuator-intvelocity-kv>` | | | |
|
||||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||||
+------------------------------------+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
+------------------------------------+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||||
| |_| actuator |br| |_| |L| | | .. table:: |
|
| |_| actuator |br| |_| |L| | | .. table:: |
|
||||||
@@ -1440,11 +1442,11 @@
|
|||||||
| :ref:`position | ? | :class: mjcf-attributes |
|
| :ref:`position | ? | :class: mjcf-attributes |
|
||||||
| <default-position>` | | |
|
| <default-position>` | | |
|
||||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||||
| | | | :ref:`ctrllimited<default-position-ctrllimited>` | :ref:`forcelimited<default-position-forcelimited>` | :ref:`ctrlrange<default-position-ctrlrange>` | :ref:`forcerange<default-position-forcerange>` | |
|
| | | | :ref:`ctrllimited<default-position-ctrllimited>` | :ref:`forcelimited<default-position-forcelimited>` | :ref:`ctrlrange<default-position-ctrlrange>` | :ref:`inheritrange<default-position-inheritrange>` | |
|
||||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||||
| | | | :ref:`gear<default-position-gear>` | :ref:`cranklength<default-position-cranklength>` | :ref:`user<default-position-user>` | :ref:`group<default-position-group>` | |
|
| | | | :ref:`forcerange<default-position-forcerange>` | :ref:`gear<default-position-gear>` | :ref:`cranklength<default-position-cranklength>` | :ref:`user<default-position-user>` | |
|
||||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||||
| | | | :ref:`kp<default-position-kp>` | :ref:`kv<default-position-kv>` | | | |
|
| | | | :ref:`group<default-position-group>` | :ref:`kp<default-position-kp>` | :ref:`kv<default-position-kv>` | | |
|
||||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||||
+------------------------------------+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
+------------------------------------+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||||
| |_| default |br| |_| |L| | | .. table:: |
|
| |_| default |br| |_| |L| | | .. table:: |
|
||||||
@@ -1464,9 +1466,9 @@
|
|||||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||||
| | | | :ref:`ctrllimited<default-intvelocity-ctrllimited>` | :ref:`forcelimited<default-intvelocity-forcelimited>` | :ref:`ctrlrange<default-intvelocity-ctrlrange>` | :ref:`forcerange<default-intvelocity-forcerange>` | |
|
| | | | :ref:`ctrllimited<default-intvelocity-ctrllimited>` | :ref:`forcelimited<default-intvelocity-forcelimited>` | :ref:`ctrlrange<default-intvelocity-ctrlrange>` | :ref:`forcerange<default-intvelocity-forcerange>` | |
|
||||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||||
| | | | :ref:`actrange<default-intvelocity-actrange>` | :ref:`gear<default-intvelocity-gear>` | :ref:`cranklength<default-intvelocity-cranklength>` | :ref:`user<default-intvelocity-user>` | |
|
| | | | :ref:`actrange<default-intvelocity-actrange>` | :ref:`inheritrange<default-intvelocity-inheritrange>` | :ref:`gear<default-intvelocity-gear>` | :ref:`cranklength<default-intvelocity-cranklength>` | |
|
||||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||||
| | | | :ref:`group<default-intvelocity-group>` | :ref:`kp<default-intvelocity-kp>` | :ref:`kv<default-intvelocity-kv>` | | |
|
| | | | :ref:`user<default-intvelocity-user>` | :ref:`group<default-intvelocity-group>` | :ref:`kp<default-intvelocity-kp>` | :ref:`kv<default-intvelocity-kv>` | |
|
||||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||||
+------------------------------------+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
+------------------------------------+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||||
| |_| default |br| |_| |L| | | .. table:: |
|
| |_| default |br| |_| |L| | | .. table:: |
|
||||||
|
|||||||
+13
-6
@@ -5,20 +5,27 @@ Changelog
|
|||||||
Upcoming version (not yet released)
|
Upcoming version (not yet released)
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
|
|
||||||
|
General
|
||||||
|
^^^^^^^
|
||||||
|
1. Added the :at:`inheritrange` attribute to :ref:`position<actuator-position>` and
|
||||||
|
:ref:`intvelocity<actuator-intvelocity>` actuators, allowing convenient setting of the actuator's
|
||||||
|
:at:`ctrlrange` or :at:`actrange` (respectively), according to the range of the transmission
|
||||||
|
target (joint or tendon). See :ref:`position/inheritrange<actuator-position-inheritrange>` for
|
||||||
|
details.
|
||||||
|
|
||||||
MJX
|
MJX
|
||||||
^^^
|
^^^
|
||||||
|
2. Improved performance of getting and putting device data.
|
||||||
1. Improved performance of getting and putting device data.
|
|
||||||
|
|
||||||
- Use ``tobytes()`` for numpy array serialization, which is orders of magnitude faster than converting to tuples.
|
- Use ``tobytes()`` for numpy array serialization, which is orders of magnitude faster than converting to tuples.
|
||||||
- Avoid reallocating host ``mjData`` arrays when array shapes are unchanged.
|
- Avoid reallocating host ``mjData`` arrays when array shapes are unchanged.
|
||||||
- Speed up calculation of ``mjx.ncon`` for models with many geoms.
|
- Speed up calculation of ``mjx.ncon`` for models with many geoms.
|
||||||
- Avoid calling ``mjx.ncon`` in ``mjx.get_data_into`` when ``nc`` can be derived from ``mjx.Data``.
|
- Avoid calling ``mjx.ncon`` in ``mjx.get_data_into`` when ``nc`` can be derived from ``mjx.Data``.
|
||||||
2. Fixed a bug in ``mjx-viewer`` that prevented it from running. Updated ``mjx-viewer`` to use newer
|
3. Fixed a bug in ``mjx-viewer`` that prevented it from running. Updated ``mjx-viewer`` to use newer
|
||||||
``mjx.get_data_into`` function call.
|
``mjx.get_data_into`` function call.
|
||||||
3. Fixed a bug in ``mjx.euler`` that applied incorrect damping when using dense mass matrices.
|
4. Fixed a bug in ``mjx.euler`` that applied incorrect damping when using dense mass matrices.
|
||||||
4. Fixed a bug in ``mjx.solve`` that was causing slow convergence when using ``mjSOL_NEWTON`` in :ref:`mjtSolver`.
|
5. Fixed a bug in ``mjx.solve`` that was causing slow convergence when using ``mjSOL_NEWTON`` in :ref:`mjtSolver`.
|
||||||
5. Added support for :ref:`mjOption.impratio<mjOption>` to ``mjx.Model``.
|
6. Added support for :ref:`mjOption.impratio<mjOption>` to ``mjx.Model``.
|
||||||
|
|
||||||
Version 3.1.2 (February 05, 2024)
|
Version 3.1.2 (February 05, 2024)
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
|
|||||||
+2
-2
@@ -118,7 +118,7 @@ SHARED_CSS_VARIABLES = {
|
|||||||
html_theme_options = {
|
html_theme_options = {
|
||||||
'light_css_variables': {
|
'light_css_variables': {
|
||||||
'font-stack--monospace': 'Inconsolata,Consolas,ui-monospace,monospace',
|
'font-stack--monospace': 'Inconsolata,Consolas,ui-monospace,monospace',
|
||||||
'at-color': '#bc103e',
|
'at-color': '#830b2b',
|
||||||
'at-val-color': '#bc103e',
|
'at-val-color': '#bc103e',
|
||||||
'body-color': '#14234b',
|
'body-color': '#14234b',
|
||||||
'color-highlight-on-target': '#e5e8ed',
|
'color-highlight-on-target': '#e5e8ed',
|
||||||
@@ -131,7 +131,7 @@ html_theme_options = {
|
|||||||
'wy-nav-side-background-color': '#0053d6',
|
'wy-nav-side-background-color': '#0053d6',
|
||||||
},
|
},
|
||||||
'dark_css_variables': {
|
'dark_css_variables': {
|
||||||
'at-color': '#ff95a6',
|
'at-color': '#ffaab7',
|
||||||
'at-val-color': '#ff95a6',
|
'at-val-color': '#ff95a6',
|
||||||
'body-color': '#14234b',
|
'body-color': '#14234b',
|
||||||
'color-admonition-background': '#1e1e21',
|
'color-admonition-background': '#1e1e21',
|
||||||
|
|||||||
@@ -559,6 +559,7 @@ typedef struct _mjmActuator { // actuator specification
|
|||||||
mjString slidersite; // site defining cylinder, for slider-crank
|
mjString slidersite; // site defining cylinder, for slider-crank
|
||||||
double cranklength; // crank length, for slider-crank
|
double cranklength; // crank length, for slider-crank
|
||||||
double lengthrange[2]; // transmission length range
|
double lengthrange[2]; // transmission length range
|
||||||
|
double inheritrange; // automatic range setting for position and intvelocity
|
||||||
|
|
||||||
// input/output clamping
|
// input/output clamping
|
||||||
int ctrllimited; // are control limits defined (mjtLimited)
|
int ctrllimited; // are control limits defined (mjtLimited)
|
||||||
|
|||||||
+123
-79
@@ -4272,85 +4272,6 @@ void mjCActuator::Compile(void) {
|
|||||||
}
|
}
|
||||||
userdata_.resize(model->nuser_actuator);
|
userdata_.resize(model->nuser_actuator);
|
||||||
|
|
||||||
// if limited is auto, check for inconsistency wrt to autolimits
|
|
||||||
if (forcelimited == mjLIMITED_AUTO) {
|
|
||||||
bool hasrange = !(forcerange[0]==0 && forcerange[1]==0);
|
|
||||||
checklimited(this, model->autolimits, "actuator", "force", forcelimited, hasrange);
|
|
||||||
}
|
|
||||||
if (ctrllimited == mjLIMITED_AUTO) {
|
|
||||||
bool hasrange = !(ctrlrange[0]==0 && ctrlrange[1]==0);
|
|
||||||
checklimited(this, model->autolimits, "actuator", "ctrl", ctrllimited, hasrange);
|
|
||||||
}
|
|
||||||
if (actlimited == mjLIMITED_AUTO) {
|
|
||||||
bool hasrange = !(actrange[0]==0 && actrange[1]==0);
|
|
||||||
checklimited(this, model->autolimits, "actuator", "act", actlimited, hasrange);
|
|
||||||
}
|
|
||||||
|
|
||||||
// check limits
|
|
||||||
if (forcerange[0]>=forcerange[1] && is_forcelimited()) {
|
|
||||||
throw mjCError(this, "invalid force range for actuator '%s' (id = %d)", name.c_str(), id);
|
|
||||||
}
|
|
||||||
if (ctrlrange[0]>=ctrlrange[1] && is_ctrllimited()) {
|
|
||||||
throw mjCError(this, "invalid control range for actuator '%s' (id = %d)", name.c_str(), id);
|
|
||||||
}
|
|
||||||
if (actrange[0]>=actrange[1] && is_actlimited()) {
|
|
||||||
throw mjCError(this, "invalid actrange for actuator '%s' (id = %d)", name.c_str(), id);
|
|
||||||
}
|
|
||||||
if (is_actlimited() && dyntype == mjDYN_NONE) {
|
|
||||||
throw mjCError(this, "actrange specified but dyntype is 'none' in actuator '%s' (id = %d)",
|
|
||||||
name.c_str(), id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// check and set actdim
|
|
||||||
if (actdim > 1 && dyntype != mjDYN_USER) {
|
|
||||||
throw mjCError(this, "actdim > 1 is only allowed for dyntype 'user' in actuator '%s' (id = %d)",
|
|
||||||
name.c_str(), id);
|
|
||||||
}
|
|
||||||
if (actdim == 1 && dyntype == mjDYN_NONE) {
|
|
||||||
throw mjCError(this, "invalid actdim 1 in stateless actuator '%s' (id = %d)", name.c_str(), id);
|
|
||||||
}
|
|
||||||
if (actdim == 0 && dyntype != mjDYN_NONE) {
|
|
||||||
throw mjCError(this, "invalid actdim 0 in stateful actuator '%s' (id = %d)", name.c_str(), id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// set actdim
|
|
||||||
if (actdim < 0) {
|
|
||||||
actdim = (dyntype != mjDYN_NONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// check muscle parameters
|
|
||||||
for (int i=0; i<2; i++) {
|
|
||||||
// select gain or bias
|
|
||||||
double* prm = NULL;
|
|
||||||
if (i==0 && gaintype==mjGAIN_MUSCLE) {
|
|
||||||
prm = gainprm;
|
|
||||||
} else if (i==1 && biastype==mjBIAS_MUSCLE) {
|
|
||||||
prm = biasprm;
|
|
||||||
}
|
|
||||||
|
|
||||||
// nothing to check
|
|
||||||
if (!prm) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// range
|
|
||||||
if (prm[0]>=prm[1]) {
|
|
||||||
throw mjCError(this, "range[0]<range[1] required in muscle '%s' (id = %d)", name.c_str(), id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// lmin<1<lmax
|
|
||||||
if (prm[4]>=1 || prm[5]<=1) {
|
|
||||||
throw mjCError(this, "lmin<1<lmax required in muscle '%s' (id = %d)", name.c_str(), id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// scale, vmax, fpmax, fvmax>0
|
|
||||||
if (prm[3]<=0 || prm[6]<=0 || prm[7]<=0 || prm[8]<=0) {
|
|
||||||
throw mjCError(this,
|
|
||||||
"positive scale, vmax, fpmax, fvmax required in muscle '%s' (id = %d)",
|
|
||||||
name.c_str(), id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// check for missing target name
|
// check for missing target name
|
||||||
if (target_.empty()) {
|
if (target_.empty()) {
|
||||||
throw mjCError(this,
|
throw mjCError(this,
|
||||||
@@ -4434,6 +4355,129 @@ void mjCActuator::Compile(void) {
|
|||||||
trnid[0] = ptarget->id;
|
trnid[0] = ptarget->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handle inheritrange
|
||||||
|
if (gaintype == mjGAIN_FIXED && biastype == mjBIAS_AFFINE &&
|
||||||
|
gainprm[0] == -biasprm[1] && inheritrange > 0) {
|
||||||
|
// semantic of actuator is the same as transmission, inheritrange is applicable
|
||||||
|
double* range;
|
||||||
|
if (dyntype == mjDYN_NONE) {
|
||||||
|
// position actuator
|
||||||
|
range = ctrlrange;
|
||||||
|
} else if (dyntype == mjDYN_INTEGRATOR) {
|
||||||
|
// intvelocity actuator
|
||||||
|
range = actrange;
|
||||||
|
} else {
|
||||||
|
throw mjCError(this, "inheritrange only available for position "
|
||||||
|
"and intvelocity actuators '%s' (id = %d)", name.c_str(), id);
|
||||||
|
}
|
||||||
|
|
||||||
|
const double* target_range;
|
||||||
|
if (trntype == mjTRN_JOINT) {
|
||||||
|
pjnt = (mjCJoint*) ptarget;
|
||||||
|
if (pjnt->spec.type != mjJNT_HINGE && pjnt->spec.type != mjJNT_SLIDE) {
|
||||||
|
throw mjCError(this, "inheritrange can only be used with hinge and slide joints, "
|
||||||
|
"actuator '%s' (id = %d)", name.c_str(), id);
|
||||||
|
}
|
||||||
|
target_range = pjnt->get_range();
|
||||||
|
} else if (trntype == mjTRN_TENDON) {
|
||||||
|
mjCTendon* pten = (mjCTendon*) ptarget;
|
||||||
|
target_range = pten->get_range();
|
||||||
|
} else {
|
||||||
|
throw mjCError(this, "inheritrange can only be used with joint and tendon transmission, "
|
||||||
|
"actuator '%s' (id = %d)", name.c_str(), id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target_range[0] == target_range[1]) {
|
||||||
|
throw mjCError(this, "inheritrange used but target '%s' has no range defined in actuator %d",
|
||||||
|
target_.c_str(), id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set range automatically
|
||||||
|
double mean = 0.5*(target_range[1] + target_range[0]);
|
||||||
|
double radius = 0.5*(target_range[1] - target_range[0]) * inheritrange;
|
||||||
|
range[0] = mean - radius;
|
||||||
|
range[1] = mean + radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if limited is auto, check for inconsistency wrt to autolimits
|
||||||
|
if (forcelimited == mjLIMITED_AUTO) {
|
||||||
|
bool hasrange = !(forcerange[0]==0 && forcerange[1]==0);
|
||||||
|
checklimited(this, model->autolimits, "actuator", "force", forcelimited, hasrange);
|
||||||
|
}
|
||||||
|
if (ctrllimited == mjLIMITED_AUTO) {
|
||||||
|
bool hasrange = !(ctrlrange[0]==0 && ctrlrange[1]==0);
|
||||||
|
checklimited(this, model->autolimits, "actuator", "ctrl", ctrllimited, hasrange);
|
||||||
|
}
|
||||||
|
if (actlimited == mjLIMITED_AUTO) {
|
||||||
|
bool hasrange = !(actrange[0]==0 && actrange[1]==0);
|
||||||
|
checklimited(this, model->autolimits, "actuator", "act", actlimited, hasrange);
|
||||||
|
}
|
||||||
|
|
||||||
|
// check limits
|
||||||
|
if (forcerange[0]>=forcerange[1] && is_forcelimited()) {
|
||||||
|
throw mjCError(this, "invalid force range for actuator '%s' (id = %d)", name.c_str(), id);
|
||||||
|
}
|
||||||
|
if (ctrlrange[0]>=ctrlrange[1] && is_ctrllimited()) {
|
||||||
|
throw mjCError(this, "invalid control range for actuator '%s' (id = %d)", name.c_str(), id);
|
||||||
|
}
|
||||||
|
if (actrange[0]>=actrange[1] && is_actlimited()) {
|
||||||
|
throw mjCError(this, "invalid actrange for actuator '%s' (id = %d)", name.c_str(), id);
|
||||||
|
}
|
||||||
|
if (is_actlimited() && dyntype == mjDYN_NONE) {
|
||||||
|
throw mjCError(this, "actrange specified but dyntype is 'none' in actuator '%s' (id = %d)",
|
||||||
|
name.c_str(), id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// check and set actdim
|
||||||
|
if (actdim > 1 && dyntype != mjDYN_USER) {
|
||||||
|
throw mjCError(this, "actdim > 1 is only allowed for dyntype 'user' in actuator '%s' (id = %d)",
|
||||||
|
name.c_str(), id);
|
||||||
|
}
|
||||||
|
if (actdim == 1 && dyntype == mjDYN_NONE) {
|
||||||
|
throw mjCError(this, "invalid actdim 1 in stateless actuator '%s' (id = %d)", name.c_str(), id);
|
||||||
|
}
|
||||||
|
if (actdim == 0 && dyntype != mjDYN_NONE) {
|
||||||
|
throw mjCError(this, "invalid actdim 0 in stateful actuator '%s' (id = %d)", name.c_str(), id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set actdim
|
||||||
|
if (actdim < 0) {
|
||||||
|
actdim = (dyntype != mjDYN_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// check muscle parameters
|
||||||
|
for (int i=0; i<2; i++) {
|
||||||
|
// select gain or bias
|
||||||
|
double* prm = NULL;
|
||||||
|
if (i==0 && gaintype==mjGAIN_MUSCLE) {
|
||||||
|
prm = gainprm;
|
||||||
|
} else if (i==1 && biastype==mjBIAS_MUSCLE) {
|
||||||
|
prm = biasprm;
|
||||||
|
}
|
||||||
|
|
||||||
|
// nothing to check
|
||||||
|
if (!prm) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// range
|
||||||
|
if (prm[0]>=prm[1]) {
|
||||||
|
throw mjCError(this, "range[0]<range[1] required in muscle '%s' (id = %d)", name.c_str(), id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// lmin<1<lmax
|
||||||
|
if (prm[4]>=1 || prm[5]<=1) {
|
||||||
|
throw mjCError(this, "lmin<1<lmax required in muscle '%s' (id = %d)", name.c_str(), id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// scale, vmax, fpmax, fvmax>0
|
||||||
|
if (prm[3]<=0 || prm[6]<=0 || prm[7]<=0 || prm[8]<=0) {
|
||||||
|
throw mjCError(this,
|
||||||
|
"positive scale, vmax, fpmax, fvmax required in muscle '%s' (id = %d)",
|
||||||
|
name.c_str(), id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// plugin
|
// plugin
|
||||||
if (plugin.active) {
|
if (plugin.active) {
|
||||||
if (plugin_name.empty() && plugin_instance_name.empty()) {
|
if (plugin_name.empty() && plugin_instance_name.empty()) {
|
||||||
|
|||||||
@@ -336,6 +336,7 @@ class mjCJoint : public mjCBase, private mjmJoint {
|
|||||||
|
|
||||||
// used by mjXWriter and mjCModel
|
// used by mjXWriter and mjCModel
|
||||||
const std::vector<double>& get_userdata() { return userdata_; }
|
const std::vector<double>& get_userdata() { return userdata_; }
|
||||||
|
const double* get_range() { return range; }
|
||||||
|
|
||||||
bool is_limited() const;
|
bool is_limited() const;
|
||||||
bool is_actfrclimited() const;
|
bool is_actfrclimited() const;
|
||||||
@@ -1102,6 +1103,7 @@ class mjCTendon : public mjCBase, private mjmTendon {
|
|||||||
|
|
||||||
// used by mjXWriter and mjCModel
|
// used by mjXWriter and mjCModel
|
||||||
const std::vector<double>& get_userdata() { return userdata_; }
|
const std::vector<double>& get_userdata() { return userdata_; }
|
||||||
|
const double* get_range() { return range; }
|
||||||
|
|
||||||
void CopyFromSpec();
|
void CopyFromSpec();
|
||||||
void PointToLocal();
|
void PointToLocal();
|
||||||
|
|||||||
@@ -168,14 +168,14 @@ const char* MJCF[nMJCF][mjXATTRNUM] = {
|
|||||||
"dyntype", "gaintype", "biastype", "dynprm", "gainprm", "biasprm", "actearly"},
|
"dyntype", "gaintype", "biastype", "dynprm", "gainprm", "biasprm", "actearly"},
|
||||||
{"motor", "?", "8", "ctrllimited", "forcelimited", "ctrlrange", "forcerange",
|
{"motor", "?", "8", "ctrllimited", "forcelimited", "ctrlrange", "forcerange",
|
||||||
"gear", "cranklength", "user", "group"},
|
"gear", "cranklength", "user", "group"},
|
||||||
{"position", "?", "10", "ctrllimited", "forcelimited", "ctrlrange", "forcerange",
|
{"position", "?", "11", "ctrllimited", "forcelimited", "ctrlrange", "inheritrange",
|
||||||
"gear", "cranklength", "user", "group",
|
"forcerange", "gear", "cranklength", "user", "group",
|
||||||
"kp", "kv"},
|
"kp", "kv"},
|
||||||
{"velocity", "?", "9", "ctrllimited", "forcelimited", "ctrlrange", "forcerange",
|
{"velocity", "?", "9", "ctrllimited", "forcelimited", "ctrlrange", "forcerange",
|
||||||
"gear", "cranklength", "user", "group",
|
"gear", "cranklength", "user", "group",
|
||||||
"kv"},
|
"kv"},
|
||||||
{"intvelocity", "?", "11", "ctrllimited", "forcelimited",
|
{"intvelocity", "?", "12", "ctrllimited", "forcelimited",
|
||||||
"ctrlrange", "forcerange", "actrange",
|
"ctrlrange", "forcerange", "actrange", "inheritrange",
|
||||||
"gear", "cranklength", "user", "group",
|
"gear", "cranklength", "user", "group",
|
||||||
"kp", "kv"},
|
"kp", "kv"},
|
||||||
{"damper", "?", "8", "forcelimited", "ctrlrange", "forcerange",
|
{"damper", "?", "8", "forcelimited", "ctrlrange", "forcerange",
|
||||||
@@ -381,8 +381,8 @@ const char* MJCF[nMJCF][mjXATTRNUM] = {
|
|||||||
"ctrllimited", "forcelimited", "ctrlrange", "forcerange",
|
"ctrllimited", "forcelimited", "ctrlrange", "forcerange",
|
||||||
"lengthrange", "gear", "cranklength", "user",
|
"lengthrange", "gear", "cranklength", "user",
|
||||||
"joint", "jointinparent", "tendon", "slidersite", "cranksite", "site", "refsite"},
|
"joint", "jointinparent", "tendon", "slidersite", "cranksite", "site", "refsite"},
|
||||||
{"position", "*", "20", "name", "class", "group",
|
{"position", "*", "21", "name", "class", "group",
|
||||||
"ctrllimited", "forcelimited", "ctrlrange", "forcerange",
|
"ctrllimited", "forcelimited", "ctrlrange", "inheritrange", "forcerange",
|
||||||
"lengthrange", "gear", "cranklength", "user",
|
"lengthrange", "gear", "cranklength", "user",
|
||||||
"joint", "jointinparent", "tendon", "slidersite", "cranksite", "site", "refsite",
|
"joint", "jointinparent", "tendon", "slidersite", "cranksite", "site", "refsite",
|
||||||
"kp", "kv"},
|
"kp", "kv"},
|
||||||
@@ -391,9 +391,9 @@ const char* MJCF[nMJCF][mjXATTRNUM] = {
|
|||||||
"lengthrange", "gear", "cranklength", "user",
|
"lengthrange", "gear", "cranklength", "user",
|
||||||
"joint", "jointinparent", "tendon", "slidersite", "cranksite", "site", "refsite",
|
"joint", "jointinparent", "tendon", "slidersite", "cranksite", "site", "refsite",
|
||||||
"kv"},
|
"kv"},
|
||||||
{"intvelocity", "*", "21", "name", "class", "group",
|
{"intvelocity", "*", "22", "name", "class", "group",
|
||||||
"ctrllimited", "forcelimited",
|
"ctrllimited", "forcelimited",
|
||||||
"ctrlrange", "forcerange", "actrange", "lengthrange",
|
"ctrlrange", "forcerange", "actrange", "inheritrange", "lengthrange",
|
||||||
"gear", "cranklength", "user",
|
"gear", "cranklength", "user",
|
||||||
"joint", "jointinparent", "tendon", "slidersite", "cranksite", "site", "refsite",
|
"joint", "jointinparent", "tendon", "slidersite", "cranksite", "site", "refsite",
|
||||||
"kp", "kv"},
|
"kp", "kv"},
|
||||||
@@ -2085,6 +2085,19 @@ void mjXReader::OneActuator(XMLElement* elem, mjmActuator* pact) {
|
|||||||
pact->biasprm[2] *= -1;
|
pact->biasprm[2] *= -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReadAttr(elem, "inheritrange", 1, &pact->inheritrange, text);
|
||||||
|
if (pact->inheritrange > 0) {
|
||||||
|
if (type == "position") {
|
||||||
|
if (pact->ctrlrange[0] || pact->ctrlrange[1]) {
|
||||||
|
throw mjXError(elem, "ctrlrange and inheritrange cannot both be defined");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (pact->actrange[0] || pact->actrange[1]) {
|
||||||
|
throw mjXError(elem, "actrange and inheritrange cannot both be defined");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// implied parameters
|
// implied parameters
|
||||||
pact->gaintype = mjGAIN_FIXED;
|
pact->gaintype = mjGAIN_FIXED;
|
||||||
pact->biastype = mjBIAS_AFFINE;
|
pact->biastype = mjBIAS_AFFINE;
|
||||||
@@ -2122,7 +2135,6 @@ void mjXReader::OneActuator(XMLElement* elem, mjmActuator* pact) {
|
|||||||
pact->gainprm[2] = -pact->gainprm[2];
|
pact->gainprm[2] = -pact->gainprm[2];
|
||||||
|
|
||||||
// require nonnegative range
|
// require nonnegative range
|
||||||
ReadAttr(elem, "ctrlrange", 2, pact->ctrlrange, text);
|
|
||||||
if (pact->ctrlrange[0]<0 || pact->ctrlrange[1]<0) {
|
if (pact->ctrlrange[0]<0 || pact->ctrlrange[1]<0) {
|
||||||
throw mjXError(elem, "damper control range cannot be negative");
|
throw mjXError(elem, "damper control range cannot be negative");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -909,6 +909,55 @@ TEST_F(ActuatorTest, ActuatorOrderDoesntMatter) {
|
|||||||
mj_deleteModel(model1);
|
mj_deleteModel(model1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------- test inheritrange attribute ----------------------------------
|
||||||
|
|
||||||
|
using InheritrangeTest = MujocoTest;
|
||||||
|
|
||||||
|
TEST_F(InheritrangeTest, ErrorIfTargetMissingRange) {
|
||||||
|
static constexpr char xml[] = R"(
|
||||||
|
<mujoco>
|
||||||
|
<worldbody>
|
||||||
|
<body>
|
||||||
|
<joint name="jnt"/>
|
||||||
|
<geom size="1"/>
|
||||||
|
</body>
|
||||||
|
</worldbody>
|
||||||
|
<actuator>
|
||||||
|
<position joint="jnt" inheritrange="1"/>
|
||||||
|
</actuator>
|
||||||
|
</mujoco>
|
||||||
|
|
||||||
|
)";
|
||||||
|
std::array<char, 1024> error;
|
||||||
|
mjModel* model = LoadModelFromString(xml, error.data(), error.size());
|
||||||
|
ASSERT_THAT(model, IsNull());
|
||||||
|
EXPECT_THAT(error.data(), HasSubstr("target 'jnt' has no range defined"));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(InheritrangeTest, WorksForDegrees) {
|
||||||
|
static constexpr char xml[] = R"(
|
||||||
|
<mujoco>
|
||||||
|
<worldbody>
|
||||||
|
<body>
|
||||||
|
<joint name="jnt" range="90 180"/>
|
||||||
|
<geom size="1"/>
|
||||||
|
</body>
|
||||||
|
</worldbody>
|
||||||
|
<actuator>
|
||||||
|
<position joint="jnt" inheritrange="1"/>
|
||||||
|
</actuator>
|
||||||
|
</mujoco>
|
||||||
|
|
||||||
|
)";
|
||||||
|
std::array<char, 1024> error;
|
||||||
|
mjModel* model = LoadModelFromString(xml, error.data(), error.size());
|
||||||
|
ASSERT_THAT(model, NotNull()) << error.data();
|
||||||
|
EXPECT_DOUBLE_EQ(model->actuator_ctrlrange[0], mjPI/2);
|
||||||
|
EXPECT_DOUBLE_EQ(model->actuator_ctrlrange[1], mjPI);
|
||||||
|
|
||||||
|
mj_deleteModel(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------- test actlimited and actrange fields ---------------------------
|
// ------------- test actlimited and actrange fields ---------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -1065,10 +1065,10 @@ TEST_F(ActuatorParseTest, PositionIntvelocityVelocityDefaultsPropagate) {
|
|||||||
<mujoco>
|
<mujoco>
|
||||||
<default>
|
<default>
|
||||||
<default class="position">
|
<default class="position">
|
||||||
<position kp="3" kv="4"/>
|
<position kp="3" kv="4" inheritrange="2"/>
|
||||||
</default>
|
</default>
|
||||||
<default class="intvelocity">
|
<default class="intvelocity">
|
||||||
<intvelocity kp="5" kv="6" actrange="-1 1"/>
|
<intvelocity kp="5" kv="6" inheritrange="0.5"/>
|
||||||
</default>
|
</default>
|
||||||
<default class="velocity">
|
<default class="velocity">
|
||||||
<velocity kv="7"/>
|
<velocity kv="7"/>
|
||||||
@@ -1077,7 +1077,7 @@ TEST_F(ActuatorParseTest, PositionIntvelocityVelocityDefaultsPropagate) {
|
|||||||
<worldbody>
|
<worldbody>
|
||||||
<body>
|
<body>
|
||||||
<geom size="1"/>
|
<geom size="1"/>
|
||||||
<joint name="jnt" type="slide" axis="1 0 0"/>
|
<joint name="jnt" type="slide" axis="1 0 0" range="0 2"/>
|
||||||
</body>
|
</body>
|
||||||
</worldbody>
|
</worldbody>
|
||||||
<actuator>
|
<actuator>
|
||||||
@@ -1107,6 +1107,10 @@ TEST_F(ActuatorParseTest, PositionIntvelocityVelocityDefaultsPropagate) {
|
|||||||
EXPECT_EQ(model->actuator_gainprm[i*mjNGAIN + j], 0.0);
|
EXPECT_EQ(model->actuator_gainprm[i*mjNGAIN + j], 0.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
EXPECT_EQ(model->actuator_ctrlrange[0*2 + 0], -1.0);
|
||||||
|
EXPECT_EQ(model->actuator_ctrlrange[0*2 + 1], 3.0);
|
||||||
|
EXPECT_EQ(model->actuator_actrange[1*2 + 0], 0.5);
|
||||||
|
EXPECT_EQ(model->actuator_actrange[1*2 + 1], 1.5);
|
||||||
mj_deleteModel(model);
|
mj_deleteModel(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1025,6 +1025,66 @@ TEST_F(XMLWriterTest, TrimsDefaults) {
|
|||||||
mj_deleteModel(model);
|
mj_deleteModel(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(XMLWriterTest, InheritrangeSavedAsRange) {
|
||||||
|
static constexpr char xml[] = R"(
|
||||||
|
<mujoco>
|
||||||
|
<compiler angle="radian"/>
|
||||||
|
<worldbody>
|
||||||
|
<body>
|
||||||
|
<geom size="1"/>
|
||||||
|
<joint name="slide" type="slide" range="0 2"/>
|
||||||
|
</body>
|
||||||
|
<body>
|
||||||
|
<geom size="1"/>
|
||||||
|
<joint name="hinge" type="hinge" range="-2 0"/>
|
||||||
|
</body>
|
||||||
|
</worldbody>
|
||||||
|
<actuator>
|
||||||
|
<position joint="slide" inheritrange="2"/>
|
||||||
|
<intvelocity joint="hinge" inheritrange="0.5"/>
|
||||||
|
</actuator>
|
||||||
|
</mujoco>
|
||||||
|
)";
|
||||||
|
mjModel* model = LoadModelFromString(xml);
|
||||||
|
ASSERT_THAT(model, NotNull());
|
||||||
|
std::string saved_xml = SaveAndReadXml(model);
|
||||||
|
EXPECT_THAT(saved_xml, HasSubstr("ctrlrange=\"-1 3\""));
|
||||||
|
EXPECT_THAT(saved_xml, HasSubstr("actrange=\"-1.5 -0.5\""));
|
||||||
|
mj_deleteModel(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(XMLWriterTest, InheritedInheritrangeSavedAsRange) {
|
||||||
|
static constexpr char xml[] = R"(
|
||||||
|
<mujoco>
|
||||||
|
<default>
|
||||||
|
<default class="position">
|
||||||
|
<position kp="3" kv="4" inheritrange="2"/>
|
||||||
|
</default>
|
||||||
|
<default class="intvelocity">
|
||||||
|
<intvelocity kp="5" kv="6" inheritrange="0.5"/>
|
||||||
|
</default>
|
||||||
|
</default>
|
||||||
|
<worldbody>
|
||||||
|
<body>
|
||||||
|
<geom size="1"/>
|
||||||
|
<joint name="jnt" type="slide" range="0 2"/>
|
||||||
|
</body>
|
||||||
|
</worldbody>
|
||||||
|
<actuator>
|
||||||
|
<position joint="jnt" class="position"/>
|
||||||
|
<intvelocity joint="jnt" class="intvelocity"/>
|
||||||
|
</actuator>
|
||||||
|
</mujoco>
|
||||||
|
)";
|
||||||
|
mjModel* model = LoadModelFromString(xml);
|
||||||
|
ASSERT_THAT(model, NotNull());
|
||||||
|
std::string saved_xml = SaveAndReadXml(model);
|
||||||
|
EXPECT_THAT(saved_xml, Not(HasSubstr("inheritrange")));
|
||||||
|
EXPECT_THAT(saved_xml, HasSubstr("ctrlrange=\"-1 3\""));
|
||||||
|
EXPECT_THAT(saved_xml, HasSubstr("actrange=\"0.5 1.5\""));
|
||||||
|
mj_deleteModel(model);
|
||||||
|
}
|
||||||
|
|
||||||
// check that no precision is lost when saving XMLs with FullFloatPrecision
|
// check that no precision is lost when saving XMLs with FullFloatPrecision
|
||||||
TEST_F(XMLWriterTest, SetPrecision) {
|
TEST_F(XMLWriterTest, SetPrecision) {
|
||||||
static constexpr char xml[] = R"(
|
static constexpr char xml[] = R"(
|
||||||
|
|||||||
Reference in New Issue
Block a user