Preparation for MIMO actuators: split actuator counts: nu (inputs), nactuator (objects), nout (outputs).
An actuator now owns a block of consecutive controls (actuator_ctrladr/ctrlnum, width defined by the actuator type) and a block of consecutive force outputs (actuator_outadr/outnum, width defined by the transmission type). Force outputs are the scalars of actuation space: one force, length, velocity and moment row each. nout = dim(actuator_force) is derived from transmission types; all current types have width 1, so all three counts coincide for every existing model and behavior is bit-exact. Array re-keying: ctrlrange/ctrllimited by nu; forcerange/forcelimited/gear/ acc0/length0/lengthrange and the moment row structure by nout; everything else per actuator. The mjModel actuator block is re-sorted by size key. Layout-breaking, not behavior-breaking: saved .mjb files are invalidated (size list changed) and recompilation is required. PiperOrigin-RevId: 948351772 Change-Id: Icbc196ffa083cb1eaa6f1a3710869c89d8f62540
This commit is contained in:
committed by
Copybara-Service
parent
06f12a9372
commit
d507e92198
@@ -239,9 +239,9 @@ typedef struct mjData_ {
|
||||
mjtNum* wrap_xpos; // Cartesian 3D points in all paths (nwrap x 6)
|
||||
|
||||
// computed by mj_fwdPosition/mj_transmission
|
||||
mjtNum* actuator_length; // actuator lengths (nu x 1)
|
||||
int* moment_rownnz; // number of non-zeros in actuator_moment row (nu x 1)
|
||||
int* moment_rowadr; // row start address in colind array (nu x 1)
|
||||
mjtNum* actuator_length; // actuator lengths, one per force output (nout x 1)
|
||||
int* moment_rownnz; // number of non-zeros in actuator_moment row (nout x 1)
|
||||
int* moment_rowadr; // row start address in colind array (nout x 1)
|
||||
int* moment_colind; // column indices in sparse Jacobian (nJmom x 1)
|
||||
mjtNum* actuator_moment; // actuator moments (nJmom x 1)
|
||||
|
||||
@@ -268,7 +268,7 @@ typedef struct mjData_ {
|
||||
// computed by mj_fwdVelocity
|
||||
mjtNum* flexedge_velocity; // flex edge velocities (nflexedge x 1)
|
||||
mjtNum* ten_velocity; // tendon velocities (ntendon x 1)
|
||||
mjtNum* actuator_velocity; // actuator velocities (nu x 1)
|
||||
mjtNum* actuator_velocity; // actuator velocities, one per force output (nout x 1)
|
||||
|
||||
// computed by mj_fwdVelocity/mj_comVel
|
||||
mjtNum* cvel; // com-based velocity (rot:lin) (nbody x 6)
|
||||
@@ -301,8 +301,8 @@ typedef struct mjData_ {
|
||||
//-------------------- POSITION, VELOCITY, CONTROL/ACCELERATION dependent
|
||||
|
||||
// computed by mj_fwdActuation
|
||||
mjtNum* actuator_force; // actuator force in actuation space (nu x 1)
|
||||
mjtNum* qfrc_actuator; // actuator force (nv x 1)
|
||||
mjtNum* actuator_force; // actuator force in actuation space (nout x 1)
|
||||
mjtNum* qfrc_actuator; // actuator force in joint space (nv x 1)
|
||||
|
||||
// computed by mj_fwdAcceleration
|
||||
mjtNum* qfrc_smooth; // net unconstrained force (nv x 1)
|
||||
|
||||
+37
-31
@@ -245,7 +245,9 @@ typedef struct mjModel_ {
|
||||
// sizes needed at mjModel construction
|
||||
mjtSize nq; // number of generalized coordinates = dim(qpos)
|
||||
mjtSize nv; // number of degrees of freedom = dim(qvel)
|
||||
mjtSize nu; // number of actuators/controls = dim(ctrl)
|
||||
mjtSize nu; // number of scalar controls = dim(ctrl)
|
||||
mjtSize nactuator; // number of actuators
|
||||
mjtSize nout; // number of force outputs, derived from transmission type
|
||||
mjtSize na; // number of activation states = dim(act)
|
||||
mjtSize nbody; // number of bodies
|
||||
mjtSize nbvh; // number of total bounding volumes in all bodies
|
||||
@@ -760,37 +762,41 @@ typedef struct mjModel_ {
|
||||
mjtNum* wrap_prm; // divisor, joint coef, or site id (nwrap x 1)
|
||||
|
||||
// actuators
|
||||
int* actuator_trntype; // transmission type (mjtTrn) (nu x 1)
|
||||
int* actuator_dyntype; // dynamics type (mjtDyn) (nu x 1)
|
||||
int* actuator_gaintype; // gain type (mjtGain) (nu x 1)
|
||||
int* actuator_biastype; // bias type (mjtBias) (nu x 1)
|
||||
int* actuator_trnid; // transmission id: joint, tendon, site (nu x 2)
|
||||
mjtNum* actuator_damping; // linear damping coefficient (nu x 1)
|
||||
mjtNum* actuator_dampingpoly; // high-order damping coefficients (nu x mjNPOLY)
|
||||
mjtNum* actuator_armature; // armature added to target (joint, tendon) (nu x 1)
|
||||
int* actuator_actadr; // first activation address; -1: stateless (nu x 1)
|
||||
int* actuator_actnum; // number of activation variables (nu x 1)
|
||||
int* actuator_group; // group for visibility (nu x 1)
|
||||
int* actuator_history; // history buffer: [nsample, interp] (nu x 2)
|
||||
int* actuator_historyadr; // address in history buffer; -1: none (nu x 1)
|
||||
mjtNum* actuator_delay; // delay time in seconds; 0: no delay (nu x 1)
|
||||
int* actuator_trntype; // transmission type (mjtTrn) (nactuator x 1)
|
||||
int* actuator_dyntype; // dynamics type (mjtDyn) (nactuator x 1)
|
||||
int* actuator_gaintype; // gain type (mjtGain) (nactuator x 1)
|
||||
int* actuator_biastype; // bias type (mjtBias) (nactuator x 1)
|
||||
int* actuator_ctrladr; // address of first control (nactuator x 1)
|
||||
int* actuator_ctrlnum; // number of controls (nactuator x 1)
|
||||
int* actuator_outadr; // address of first force output (nactuator x 1)
|
||||
int* actuator_outnum; // number of force outputs, from trntype (nactuator x 1)
|
||||
int* actuator_actadr; // first activation address; -1: stateless (nactuator x 1)
|
||||
int* actuator_actnum; // number of activation variables (nactuator x 1)
|
||||
int* actuator_trnid; // transmission id: joint, tendon, site (nactuator x 2)
|
||||
mjtNum* actuator_cranklength; // crank length for slider-crank (nactuator x 1)
|
||||
mjtNum* actuator_dynprm; // dynamics parameters (nactuator x mjNDYN)
|
||||
mjtNum* actuator_gainprm; // gain parameters (nactuator x mjNGAIN)
|
||||
mjtNum* actuator_biasprm; // bias parameters (nactuator x mjNBIAS)
|
||||
mjtBool* actuator_actlimited; // is activation limited (nactuator x 1)
|
||||
mjtNum* actuator_actrange; // range of activations (nactuator x 2)
|
||||
mjtBool* actuator_actearly; // step activation before force (nactuator x 1)
|
||||
int* actuator_history; // history buffer: [nsample, interp] (nactuator x 2)
|
||||
int* actuator_historyadr; // address in history buffer; -1: none (nactuator x 1)
|
||||
mjtNum* actuator_delay; // delay time; 0: no delay (nactuator x 1)
|
||||
mjtNum* actuator_damping; // linear damping coefficient (nactuator x 1)
|
||||
mjtNum* actuator_dampingpoly; // high-order damping coefficients (nactuator x mjNPOLY)
|
||||
mjtNum* actuator_armature; // armature added to target (joint, tendon) (nactuator x 1)
|
||||
int* actuator_group; // group for visibility (nactuator x 1)
|
||||
mjtNum* actuator_user; // user data (nactuator x nuser_actuator)
|
||||
int* actuator_plugin; // plugin instance id; -1: not a plugin (nactuator x 1)
|
||||
mjtBool* actuator_ctrllimited; // is control limited (nu x 1)
|
||||
mjtBool* actuator_forcelimited;// is force limited (nu x 1)
|
||||
mjtBool* actuator_actlimited; // is activation limited (nu x 1)
|
||||
mjtNum* actuator_dynprm; // dynamics parameters (nu x mjNDYN)
|
||||
mjtNum* actuator_gainprm; // gain parameters (nu x mjNGAIN)
|
||||
mjtNum* actuator_biasprm; // bias parameters (nu x mjNBIAS)
|
||||
mjtBool* actuator_actearly; // step activation before force (nu x 1)
|
||||
mjtNum* actuator_ctrlrange; // range of controls (nu x 2)
|
||||
mjtNum* actuator_forcerange; // range of forces (nu x 2)
|
||||
mjtNum* actuator_actrange; // range of activations (nu x 2)
|
||||
mjtNum* actuator_gear; // scale length and transmitted force (nu x 6)
|
||||
mjtNum* actuator_cranklength; // crank length for slider-crank (nu x 1)
|
||||
mjtNum* actuator_acc0; // acceleration from unit force in qpos0 (nu x 1)
|
||||
mjtNum* actuator_length0; // actuator length in qpos0 (nu x 1)
|
||||
mjtNum* actuator_lengthrange; // feasible actuator length range (nu x 2)
|
||||
mjtNum* actuator_user; // user data (nu x nuser_actuator)
|
||||
int* actuator_plugin; // plugin instance id; -1: not a plugin (nu x 1)
|
||||
mjtNum* actuator_gear; // scale length and transmitted force (nout x 6)
|
||||
mjtBool* actuator_forcelimited;// is force limited (nout x 1)
|
||||
mjtNum* actuator_forcerange; // range of forces (nout x 2)
|
||||
mjtNum* actuator_acc0; // acceleration from unit force in qpos0 (nout x 1)
|
||||
mjtNum* actuator_length0; // actuator length in qpos0 (nout x 1)
|
||||
mjtNum* actuator_lengthrange; // feasible actuator length range (nout x 2)
|
||||
|
||||
// sensors
|
||||
int* sensor_type; // sensor type (mjtSensor) (nsensor x 1)
|
||||
@@ -862,7 +868,7 @@ typedef struct mjModel_ {
|
||||
int* name_excludeadr; // exclude name pointers (nexclude x 1)
|
||||
int* name_eqadr; // equality constraint name pointers (neq x 1)
|
||||
int* name_tendonadr; // tendon name pointers (ntendon x 1)
|
||||
int* name_actuatoradr; // actuator name pointers (nu x 1)
|
||||
int* name_actuatoradr; // actuator name pointers (nactuator x 1)
|
||||
int* name_sensoradr; // sensor name pointers (nsensor x 1)
|
||||
int* name_numericadr; // numeric name pointers (nnumeric x 1)
|
||||
int* name_textadr; // text name pointers (ntext x 1)
|
||||
|
||||
+41
-35
@@ -163,6 +163,8 @@
|
||||
X( nq ) \
|
||||
X( nv ) \
|
||||
X( nu ) \
|
||||
X( nactuator ) \
|
||||
X( nout ) \
|
||||
X( na ) \
|
||||
X( nbody ) \
|
||||
X( nbvh ) \
|
||||
@@ -666,37 +668,41 @@
|
||||
X ( float, tendon_rgba, ntendon, 4 )
|
||||
|
||||
#define MJMODEL_POINTERS_ACTUATOR \
|
||||
X ( int, actuator_trntype, nu, 1 ) \
|
||||
X ( int, actuator_dyntype, nu, 1 ) \
|
||||
X ( int, actuator_gaintype, nu, 1 ) \
|
||||
X ( int, actuator_biastype, nu, 1 ) \
|
||||
X ( int, actuator_trnid, nu, 2 ) \
|
||||
X ( mjtNum, actuator_damping, nu, 1 ) \
|
||||
X ( mjtNum, actuator_dampingpoly, nu, mjNPOLY ) \
|
||||
X ( mjtNum, actuator_armature, nu, 1 ) \
|
||||
X ( int, actuator_actadr, nu, 1 ) \
|
||||
X ( int, actuator_actnum, nu, 1 ) \
|
||||
X ( int, actuator_group, nu, 1 ) \
|
||||
X ( int, actuator_history, nu, 2 ) \
|
||||
X ( int, actuator_historyadr, nu, 1 ) \
|
||||
X ( mjtNum, actuator_delay, nu, 1 ) \
|
||||
X ( int, actuator_trntype, nactuator, 1 ) \
|
||||
X ( int, actuator_dyntype, nactuator, 1 ) \
|
||||
X ( int, actuator_gaintype, nactuator, 1 ) \
|
||||
X ( int, actuator_biastype, nactuator, 1 ) \
|
||||
X ( int, actuator_ctrladr, nactuator, 1 ) \
|
||||
X ( int, actuator_ctrlnum, nactuator, 1 ) \
|
||||
X ( int, actuator_outadr, nactuator, 1 ) \
|
||||
X ( int, actuator_outnum, nactuator, 1 ) \
|
||||
X ( int, actuator_actadr, nactuator, 1 ) \
|
||||
X ( int, actuator_actnum, nactuator, 1 ) \
|
||||
X ( int, actuator_trnid, nactuator, 2 ) \
|
||||
X ( mjtNum, actuator_cranklength, nactuator, 1 ) \
|
||||
X ( mjtNum, actuator_dynprm, nactuator, mjNDYN ) \
|
||||
X ( mjtNum, actuator_gainprm, nactuator, mjNGAIN ) \
|
||||
X ( mjtNum, actuator_biasprm, nactuator, mjNBIAS ) \
|
||||
X ( mjtBool, actuator_actlimited, nactuator, 1 ) \
|
||||
X ( mjtNum, actuator_actrange, nactuator, 2 ) \
|
||||
X ( mjtBool, actuator_actearly, nactuator, 1 ) \
|
||||
X ( int, actuator_history, nactuator, 2 ) \
|
||||
X ( int, actuator_historyadr, nactuator, 1 ) \
|
||||
X ( mjtNum, actuator_delay, nactuator, 1 ) \
|
||||
X ( mjtNum, actuator_damping, nactuator, 1 ) \
|
||||
X ( mjtNum, actuator_dampingpoly, nactuator, mjNPOLY ) \
|
||||
X ( mjtNum, actuator_armature, nactuator, 1 ) \
|
||||
X ( int, actuator_group, nactuator, 1 ) \
|
||||
X ( mjtNum, actuator_user, nactuator, MJ_M(nuser_actuator) ) \
|
||||
X ( int, actuator_plugin, nactuator, 1 ) \
|
||||
X ( mjtBool, actuator_ctrllimited, nu, 1 ) \
|
||||
X ( mjtBool, actuator_forcelimited, nu, 1 ) \
|
||||
X ( mjtBool, actuator_actlimited, nu, 1 ) \
|
||||
X ( mjtNum, actuator_dynprm, nu, mjNDYN ) \
|
||||
X ( mjtNum, actuator_gainprm, nu, mjNGAIN ) \
|
||||
X ( mjtNum, actuator_biasprm, nu, mjNBIAS ) \
|
||||
X ( mjtBool, actuator_actearly, nu, 1 ) \
|
||||
X ( mjtNum, actuator_ctrlrange, nu, 2 ) \
|
||||
X ( mjtNum, actuator_forcerange, nu, 2 ) \
|
||||
X ( mjtNum, actuator_actrange, nu, 2 ) \
|
||||
X ( mjtNum, actuator_gear, nu, 6 ) \
|
||||
X ( mjtNum, actuator_cranklength, nu, 1 ) \
|
||||
X ( mjtNum, actuator_acc0, nu, 1 ) \
|
||||
X ( mjtNum, actuator_length0, nu, 1 ) \
|
||||
X ( mjtNum, actuator_lengthrange, nu, 2 ) \
|
||||
X ( mjtNum, actuator_user, nu, MJ_M(nuser_actuator) ) \
|
||||
X ( int, actuator_plugin, nu, 1 )
|
||||
X ( mjtNum, actuator_gear, nout, 6 ) \
|
||||
X ( mjtBool, actuator_forcelimited, nout, 1 ) \
|
||||
X ( mjtNum, actuator_forcerange, nout, 2 ) \
|
||||
X ( mjtNum, actuator_acc0, nout, 1 ) \
|
||||
X ( mjtNum, actuator_length0, nout, 1 ) \
|
||||
X ( mjtNum, actuator_lengthrange, nout, 2 )
|
||||
|
||||
#define MJMODEL_POINTERS_SENSOR \
|
||||
X ( int, sensor_type, nsensor, 1 ) \
|
||||
@@ -791,7 +797,7 @@
|
||||
X ( int, name_excludeadr, nexclude, 1 ) \
|
||||
X ( int, name_eqadr, neq, 1 ) \
|
||||
X ( int, name_tendonadr, ntendon, 1 ) \
|
||||
X ( int, name_actuatoradr, nu, 1 ) \
|
||||
X ( int, name_actuatoradr, nactuator, 1 ) \
|
||||
X ( int, name_sensoradr, nsensor, 1 ) \
|
||||
X ( int, name_numericadr, nnumeric, 1 ) \
|
||||
X ( int, name_textadr, ntext, 1 ) \
|
||||
@@ -871,9 +877,9 @@
|
||||
X ( mjtNum, ten_length, ntendon, 1 ) \
|
||||
X ( int, wrap_obj, nwrap, 2 ) \
|
||||
X ( mjtNum, wrap_xpos, nwrap, 6 ) \
|
||||
X ( mjtNum, actuator_length, nu, 1 ) \
|
||||
X ( int, moment_rownnz, nu, 1 ) \
|
||||
X ( int, moment_rowadr, nu, 1 ) \
|
||||
X ( mjtNum, actuator_length, nout, 1 ) \
|
||||
X ( int, moment_rownnz, nout, 1 ) \
|
||||
X ( int, moment_rowadr, nout, 1 ) \
|
||||
X ( int, moment_colind, nJmom, 1 ) \
|
||||
X ( mjtNum, actuator_moment, nJmom, 1 ) \
|
||||
XNV ( mjtNum, crb, nbody, 10 ) \
|
||||
@@ -888,7 +894,7 @@
|
||||
X ( int, dof_awake_ind, nv, 1 ) \
|
||||
X ( mjtNum, flexedge_velocity, nflexedge, 1 ) \
|
||||
X ( mjtNum, ten_velocity, ntendon, 1 ) \
|
||||
X ( mjtNum, actuator_velocity, nu, 1 ) \
|
||||
X ( mjtNum, actuator_velocity, nout, 1 ) \
|
||||
X ( mjtNum, cvel, nbody, 6 ) \
|
||||
X ( mjtNum, cdof_dot, nv, 6 ) \
|
||||
X ( mjtNum, qfrc_bias, nv, 1 ) \
|
||||
@@ -903,7 +909,7 @@
|
||||
X ( mjtNum, qHDiagInv, nv, 1 ) \
|
||||
XNV ( mjtNum, qDeriv, nD, 1 ) \
|
||||
XNV ( mjtNum, qLU, nD, 1 ) \
|
||||
X ( mjtNum, actuator_force, nu, 1 ) \
|
||||
X ( mjtNum, actuator_force, nout, 1 ) \
|
||||
X ( mjtNum, qfrc_actuator, nv, 1 ) \
|
||||
X ( mjtNum, qfrc_smooth, nv, 1 ) \
|
||||
X ( mjtNum, qacc_smooth, nv, 1 ) \
|
||||
|
||||
Reference in New Issue
Block a user