Optimize flexedge velocity computation.
Skip flexedge velocity calculation for rigid and interpolated flexes, as they are not used in those cases. The computation is now done per-flex, only for the edges within each non-rigid, non-interpolated flex. PiperOrigin-RevId: 915907396 Change-Id: I0beb1f98f0115c83da13fed184e89101f57563ab
This commit is contained in:
committed by
Copybara-Service
parent
7ca1bc6a56
commit
0ad77f1ddf
@@ -227,9 +227,16 @@ void mj_fwdVelocity(const mjModel* m, mjData* d) {
|
||||
d->flg_subtreevel = 0;
|
||||
d->flg_energyvel = 0;
|
||||
|
||||
// flexedge velocity: always sparse
|
||||
mju_mulMatVecSparse(d->flexedge_velocity, d->flexedge_J, d->qvel, m->nflexedge,
|
||||
m->flexedge_J_rownnz, m->flexedge_J_rowadr, m->flexedge_J_colind, NULL);
|
||||
// flexedge velocity: skip interp and rigid flexes (edge Jacobians are zero)
|
||||
mju_zero(d->flexedge_velocity, m->nflexedge);
|
||||
for (int f = 0; f < m->nflex; f++) {
|
||||
if (m->flex_rigid[f] || m->flex_interp[f]) continue;
|
||||
int adr = m->flex_edgeadr[f];
|
||||
int num = m->flex_edgenum[f];
|
||||
mju_mulMatVecSparse(d->flexedge_velocity + adr, d->flexedge_J, d->qvel, num,
|
||||
m->flexedge_J_rownnz + adr, m->flexedge_J_rowadr + adr,
|
||||
m->flexedge_J_colind, NULL);
|
||||
}
|
||||
|
||||
// tendon velocity: always sparse
|
||||
mju_mulMatVecSparse(d->ten_velocity, d->ten_J, d->qvel, m->ntendon,
|
||||
|
||||
Reference in New Issue
Block a user