Delete sparsity structures from mjData, use the ones in mjModel

PiperOrigin-RevId: 795067950
Change-Id: If4f52e40ac49f7c6986b33ef9c8b534199dfd21a
This commit is contained in:
Yuval Tassa
2025-08-14 09:11:47 -07:00
committed by Copybara-Service
parent 7eb13777f8
commit 977f94e9df
25 changed files with 120 additions and 349 deletions
+5 -5
View File
@@ -204,8 +204,8 @@ void mjd_passive_velFD(const mjModel* m, mjData* d, mjtNum eps) {
// copy to i-th column of qDeriv
for (int j=0; j < nv; j++) {
int adr = d->D_rowadr[j] + cnt[j];
if (cnt[j] < d->D_rownnz[j] && d->D_colind[adr] == i) {
int adr = m->D_rowadr[j] + cnt[j];
if (cnt[j] < m->D_rownnz[j] && m->D_colind[adr] == i) {
d->qDeriv[adr] = fd[j];
cnt[j]++;
}
@@ -263,8 +263,8 @@ void mjd_smooth_velFD(const mjModel* m, mjData* d, mjtNum eps) {
// copy to sparse qDeriv
for (int j=0; j < nv; j++) {
if (cnt[j] < d->D_rownnz[j] && d->D_colind[d->D_rowadr[j]+cnt[j]] == i) {
d->qDeriv[d->D_rowadr[j]+cnt[j]] = fd[j];
if (cnt[j] < m->D_rownnz[j] && m->D_colind[m->D_rowadr[j]+cnt[j]] == i) {
d->qDeriv[m->D_rowadr[j]+cnt[j]] = fd[j];
cnt[j]++;
}
}
@@ -272,7 +272,7 @@ void mjd_smooth_velFD(const mjModel* m, mjData* d, mjtNum eps) {
// make sure final row counters equal rownnz
for (int i=0; i < nv; i++) {
if (cnt[i] != d->D_rownnz[i]) {
if (cnt[i] != m->D_rownnz[i]) {
mjERROR("error in constructing FD sparse derivative");
}
}