Reduce flex stiffness and bending memory size to the exact amount needed.
PiperOrigin-RevId: 911774147 Change-Id: I3b18eba23e75ec91ece8342945f25e0cd7c63a1a
This commit is contained in:
committed by
Copybara-Service
parent
b6aac76cc4
commit
0c05215e18
@@ -832,9 +832,14 @@ void mj_instantiateEquality(const mjModel* m, mjData* d) {
|
||||
|
||||
// read eigenmode data from flex_stiffness
|
||||
int ndof_elem = 3 * npe;
|
||||
const mjtNum* k_elem = m->flex_stiffness + m->flex_stiffnessadr[f]
|
||||
+ elem_idx * ndof_elem * ndof_elem;
|
||||
int neig = (int)k_elem[0];
|
||||
int stiffnessadr = m->flex_stiffnessadr[f];
|
||||
int neig = 0;
|
||||
const mjtNum* k_elem = NULL;
|
||||
if (stiffnessadr >= 0) {
|
||||
k_elem = m->flex_stiffness + stiffnessadr
|
||||
+ elem_idx * ndof_elem * ndof_elem;
|
||||
neig = (int)k_elem[0];
|
||||
}
|
||||
|
||||
// compute displacement in corotational frame
|
||||
mjtNum* displ_e = mjSTACKALLOC(d, ndof_elem, mjtNum);
|
||||
@@ -2387,9 +2392,12 @@ static int mj_ne(const mjModel* m, mjData* d, int* nnz) {
|
||||
|
||||
// read eigenmode count from flex_stiffness
|
||||
int ndof_elem = 3 * npe;
|
||||
const mjtNum* k_elem = m->flex_stiffness + m->flex_stiffnessadr[f]
|
||||
+ elem_idx * ndof_elem * ndof_elem;
|
||||
size = (int)k_elem[0]; // neig stored as first element
|
||||
size = 0;
|
||||
if (m->flex_stiffnessadr[f] >= 0) {
|
||||
const mjtNum* k_elem = m->flex_stiffness + m->flex_stiffnessadr[f]
|
||||
+ elem_idx * ndof_elem * ndof_elem;
|
||||
size = (int)k_elem[0]; // neig stored as first element
|
||||
}
|
||||
|
||||
if (nnz) {
|
||||
// get element node body IDs
|
||||
|
||||
@@ -951,7 +951,11 @@ static void mjd_flexInterp_kernel(const mjModel* m, mjData* d, mjtFlexOp op,
|
||||
}
|
||||
|
||||
// get stiffness and damping
|
||||
mjtNum* K = m->flex_stiffness + m->flex_stiffnessadr[f];
|
||||
int stiffnessadr = m->flex_stiffnessadr[f];
|
||||
if (stiffnessadr < 0) {
|
||||
continue;
|
||||
}
|
||||
mjtNum* K = m->flex_stiffness + stiffnessadr;
|
||||
|
||||
// skip if rigid or no stiffness
|
||||
if (m->flex_rigid[f] || K[0] == 0) {
|
||||
|
||||
@@ -62,7 +62,12 @@ static void inline GradSquaredLengths(mjtNum gradient[6][2][3],
|
||||
// passive forces for interpolated flex (stretch + bending)
|
||||
static void mj_flexPassiveInterp(const mjModel* m, mjData* d, int f,
|
||||
int enbl_spring, int enbl_damper) {
|
||||
mjtNum* k = m->flex_stiffness + m->flex_stiffnessadr[f];
|
||||
int stiffnessadr = m->flex_stiffnessadr[f];
|
||||
if (stiffnessadr < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
mjtNum* k = m->flex_stiffness + stiffnessadr;
|
||||
int nodenum = m->flex_nodenum[f];
|
||||
|
||||
int order = m->flex_interp[f];
|
||||
@@ -230,8 +235,17 @@ static inline mjtNum mju_dphi2D(mjtNum s0, int l0, mjtNum s1, int l1,
|
||||
// accuracy for elements with varying curvature.
|
||||
static void mj_flexPassiveBendInterp(const mjModel* m, mjData* d, int f,
|
||||
int enbl_spring, int enbl_damper) {
|
||||
if (m->flex_interp[f] >= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int bendingadr = m->flex_bendingadr[f];
|
||||
if (bendingadr < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// read bending edge data
|
||||
const mjtNum* bdata = m->flex_bending + m->flex_bendingadr[f];
|
||||
const mjtNum* bdata = m->flex_bending + bendingadr;
|
||||
int nedge = (int)bdata[0];
|
||||
if (nedge == 0) return;
|
||||
|
||||
@@ -398,10 +412,15 @@ static void mj_flexPassiveBend(const mjModel* m, mjData* d, int f,
|
||||
return;
|
||||
}
|
||||
|
||||
int bendingadr = m->flex_bendingadr[f];
|
||||
if (bendingadr < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int edgenum = m->flex_edgenum[f];
|
||||
mjtNum* xpos = d->flexvert_xpos + 3*m->flex_vertadr[f];
|
||||
int* bodyid = m->flex_vertbodyid + m->flex_vertadr[f];
|
||||
mjtNum* b = m->flex_bending + 17*m->flex_edgeadr[f];
|
||||
mjtNum* b = m->flex_bending + bendingadr;
|
||||
|
||||
for (int e = 0; e < edgenum; e++) {
|
||||
const int* edge = m->flex_edge + 2*(e+m->flex_edgeadr[f]);
|
||||
@@ -469,7 +488,11 @@ static void mj_flexPassiveBend(const mjModel* m, mjData* d, int f,
|
||||
// passive forces for flex stretch
|
||||
static void mj_flexPassiveStretch(const mjModel* m, mjData* d, int f,
|
||||
int enbl_spring, int enbl_damper) {
|
||||
mjtNum* k = m->flex_stiffness + m->flex_stiffnessadr[f];
|
||||
int stiffnessadr = m->flex_stiffnessadr[f];
|
||||
if (stiffnessadr < 0) {
|
||||
return;
|
||||
}
|
||||
mjtNum* k = m->flex_stiffness + stiffnessadr;
|
||||
if (k[0] == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -660,9 +683,7 @@ static void mj_springdamper(const mjModel* m, mjData* d) {
|
||||
mj_flexPassiveInterp(m, d, f, enbl_spring, enbl_damper);
|
||||
|
||||
// interpolated shell bending forces
|
||||
if (m->flex_interp[f] < 0) {
|
||||
mj_flexPassiveBendInterp(m, d, f, enbl_spring, enbl_damper);
|
||||
}
|
||||
mj_flexPassiveBendInterp(m, d, f, enbl_spring, enbl_damper);
|
||||
} else {
|
||||
// add bending forces
|
||||
mj_flexPassiveBend(m, d, f, enbl_spring, enbl_damper);
|
||||
|
||||
Reference in New Issue
Block a user