Allow actuators to add damping and armature to joint and tendon transmissions.
PiperOrigin-RevId: 886899849 Change-Id: I02200ee0d4f7c96096d8188b95f823b566562a30
This commit is contained in:
committed by
Copybara-Service
parent
f7bd6d15f7
commit
510d75f4cf
@@ -3871,6 +3871,9 @@ void mjCModel::CopyObjects(mjModel* m) {
|
||||
m->actuator_actearly[i] = pac->actearly;
|
||||
m->actuator_cranklength[i] = (mjtNum)pac->cranklength;
|
||||
mjuu_copyvec(m->actuator_gear + 6*i, pac->gear, 6);
|
||||
m->actuator_damping[i] = (mjtNum)pac->damping[0];
|
||||
mjuu_copyvec(m->actuator_dampingpoly + mjNPOLY*i, pac->damping + 1, mjNPOLY);
|
||||
m->actuator_armature[i] = (mjtNum)pac->armature;
|
||||
mjuu_copyvec(m->actuator_dynprm + mjNDYN*i, pac->dynprm, mjNDYN);
|
||||
mjuu_copyvec(m->actuator_gainprm + mjNGAIN*i, pac->gainprm, mjNGAIN);
|
||||
mjuu_copyvec(m->actuator_biasprm + mjNBIAS*i, pac->biasprm, mjNBIAS);
|
||||
@@ -5712,6 +5715,9 @@ bool mjCModel::CopyBack(const mjModel* m) {
|
||||
mjuu_copyvec(pa->actrange, m->actuator_actrange+2*i, 2);
|
||||
mjuu_copyvec(pa->lengthrange, m->actuator_lengthrange+2*i, 2);
|
||||
mjuu_copyvec(pa->gear, m->actuator_gear+6*i, 6);
|
||||
pa->damping[0] = (double)m->actuator_damping[i];
|
||||
mjuu_copyvec(pa->damping + 1, m->actuator_dampingpoly + mjNPOLY*i, mjNPOLY);
|
||||
pa->armature = (double)m->actuator_armature[i];
|
||||
pa->cranklength = (double)m->actuator_cranklength[i];
|
||||
|
||||
if (nuser_actuator) {
|
||||
|
||||
@@ -7126,6 +7126,27 @@ void mjCActuator::Compile(void) {
|
||||
// find transmission target in object arrays
|
||||
ResolveReferences(model);
|
||||
|
||||
// check damping/armature only valid for joint and tendon transmission
|
||||
bool has_damping = false;
|
||||
for (int i = 0; i < mjNPOLY+1; i++) {
|
||||
if (damping[i] != 0) {
|
||||
has_damping = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (has_damping &&
|
||||
trntype != mjTRN_JOINT && trntype != mjTRN_JOINTINPARENT && trntype != mjTRN_TENDON) {
|
||||
throw mjCError(this,
|
||||
"damping requires joint or tendon transmission in actuator '%s' (id = %d)",
|
||||
name.c_str(), id);
|
||||
}
|
||||
if (armature != 0 &&
|
||||
trntype != mjTRN_JOINT && trntype != mjTRN_JOINTINPARENT && trntype != mjTRN_TENDON) {
|
||||
throw mjCError(this,
|
||||
"armature requires joint or tendon transmission in actuator '%s' (id = %d)",
|
||||
name.c_str(), id);
|
||||
}
|
||||
|
||||
// handle inheritrange
|
||||
if (gaintype == mjGAIN_FIXED && biastype == mjBIAS_AFFINE &&
|
||||
gainprm[0] == -biasprm[1] && inheritrange > 0) {
|
||||
|
||||
Reference in New Issue
Block a user