Remove M matrix structure from mjData.
Introduced in March 2025 as a temporary measure, this is not considered a breaking change. PiperOrigin-RevId: 758311298 Change-Id: Ia08857c18b791f6a62a2d8d136b45fc075507b93
This commit is contained in:
committed by
Copybara-Service
parent
6bc0bbf7df
commit
1e02d66c3d
@@ -312,10 +312,6 @@ struct mjData_ {
|
||||
int* B_rownnz; // body-dof: non-zeros in each row (nbody x 1)
|
||||
int* B_rowadr; // body-dof: address of each row in B_colind (nbody x 1)
|
||||
int* B_colind; // body-dof: column indices of non-zeros (nB x 1)
|
||||
int* M_rownnz; // inertia: non-zeros in each row (nv x 1)
|
||||
int* M_rowadr; // inertia: address of each row in M_colind (nv x 1)
|
||||
int* M_colind; // inertia: column indices of non-zeros (nM x 1)
|
||||
int* mapM2M; // index mapping from M (legacy) to M (CSR) (nM x 1)
|
||||
int* C_rownnz; // reduced dof-dof: non-zeros in each row (nv x 1)
|
||||
int* C_rowadr; // reduced dof-dof: address of each row in C_colind (nv x 1)
|
||||
int* C_colind; // reduced dof-dof: column indices of non-zeros (nC x 1)
|
||||
|
||||
@@ -340,10 +340,6 @@ struct mjData_ {
|
||||
int* B_rownnz; // body-dof: non-zeros in each row (nbody x 1)
|
||||
int* B_rowadr; // body-dof: address of each row in B_colind (nbody x 1)
|
||||
int* B_colind; // body-dof: column indices of non-zeros (nB x 1)
|
||||
int* M_rownnz; // inertia: non-zeros in each row (nv x 1)
|
||||
int* M_rowadr; // inertia: address of each row in M_colind (nv x 1)
|
||||
int* M_colind; // inertia: column indices of non-zeros (nM x 1)
|
||||
int* mapM2M; // index mapping from M (legacy) to M (CSR) (nM x 1)
|
||||
int* C_rownnz; // reduced dof-dof: non-zeros in each row (nv x 1)
|
||||
int* C_rowadr; // reduced dof-dof: address of each row in C_colind (nv x 1)
|
||||
int* C_colind; // reduced dof-dof: column indices of non-zeros (nC x 1)
|
||||
|
||||
@@ -675,10 +675,6 @@
|
||||
X ( int, B_rownnz, nbody, 1 ) \
|
||||
X ( int, B_rowadr, nbody, 1 ) \
|
||||
X ( int, B_colind, nB, 1 ) \
|
||||
X ( int, M_rownnz, nv, 1 ) \
|
||||
X ( int, M_rowadr, nv, 1 ) \
|
||||
X ( int, M_colind, nM, 1 ) \
|
||||
X ( int, mapM2M, nM, 1 ) \
|
||||
X ( int, C_rownnz, nv, 1 ) \
|
||||
X ( int, C_rowadr, nv, 1 ) \
|
||||
X ( int, C_colind, nC, 1 ) \
|
||||
|
||||
@@ -627,10 +627,6 @@ def _make_data_c(
|
||||
'B_rownnz': (m.nbody, np.int32),
|
||||
'B_rowadr': (m.nbody, np.int32),
|
||||
'B_colind': (m.nB, np.int32),
|
||||
'M_rownnz': (m.nv, np.int32),
|
||||
'M_rowadr': (m.nv, np.int32),
|
||||
'M_colind': (m.nM, np.int32),
|
||||
'mapM2M': (m.nM, np.int32),
|
||||
'C_rownnz': (m.nv, np.int32),
|
||||
'C_rowadr': (m.nv, np.int32),
|
||||
'C_colind': (m.nC, np.int32),
|
||||
|
||||
@@ -471,7 +471,7 @@ class DataIOTest(parameterized.TestCase):
|
||||
|
||||
if backend_impl == 'c':
|
||||
# check fields specific to the C implementation
|
||||
np.testing.assert_allclose(d_2.M_rownnz, d.M_rownnz)
|
||||
np.testing.assert_allclose(d_2.bvh_active, d.bvh_active)
|
||||
|
||||
def test_get_data_runs(self):
|
||||
xml = """
|
||||
|
||||
@@ -984,10 +984,6 @@ class DataC(PyTreeNode):
|
||||
B_rownnz: jax.Array # pylint:disable=invalid-name
|
||||
B_rowadr: jax.Array # pylint:disable=invalid-name
|
||||
B_colind: jax.Array # pylint:disable=invalid-name
|
||||
M_rownnz: jax.Array # pylint:disable=invalid-name
|
||||
M_rowadr: jax.Array # pylint:disable=invalid-name
|
||||
M_colind: jax.Array # pylint:disable=invalid-name
|
||||
mapM2M: jax.Array # pylint:disable=invalid-name
|
||||
C_rownnz: jax.Array # pylint:disable=invalid-name
|
||||
C_rowadr: jax.Array # pylint:disable=invalid-name
|
||||
C_colind: jax.Array # pylint:disable=invalid-name
|
||||
|
||||
@@ -5568,38 +5568,6 @@ STRUCTS: Mapping[str, StructDecl] = dict([
|
||||
doc='body-dof: column indices of non-zeros',
|
||||
array_extent=('nB',),
|
||||
),
|
||||
StructFieldDecl(
|
||||
name='M_rownnz',
|
||||
type=PointerType(
|
||||
inner_type=ValueType(name='int'),
|
||||
),
|
||||
doc='inertia: non-zeros in each row',
|
||||
array_extent=('nv',),
|
||||
),
|
||||
StructFieldDecl(
|
||||
name='M_rowadr',
|
||||
type=PointerType(
|
||||
inner_type=ValueType(name='int'),
|
||||
),
|
||||
doc='inertia: address of each row in M_colind',
|
||||
array_extent=('nv',),
|
||||
),
|
||||
StructFieldDecl(
|
||||
name='M_colind',
|
||||
type=PointerType(
|
||||
inner_type=ValueType(name='int'),
|
||||
),
|
||||
doc='inertia: column indices of non-zeros',
|
||||
array_extent=('nM',),
|
||||
),
|
||||
StructFieldDecl(
|
||||
name='mapM2M',
|
||||
type=PointerType(
|
||||
inner_type=ValueType(name='int'),
|
||||
),
|
||||
doc='index mapping from M (legacy) to M (CSR)',
|
||||
array_extent=('nM',),
|
||||
),
|
||||
StructFieldDecl(
|
||||
name='C_rownnz',
|
||||
type=PointerType(
|
||||
|
||||
+1
-16
@@ -1141,9 +1141,6 @@ static void copyM2Sparse(const mjModel* m, mjData* d, int* dst, const int* src,
|
||||
if (reduced && !upper) {
|
||||
rownnz = d->C_rownnz;
|
||||
rowadr = d->C_rowadr;
|
||||
} else if (!reduced && !upper) {
|
||||
rownnz = d->M_rownnz;
|
||||
rowadr = d->M_rowadr;
|
||||
} else if (!reduced && upper) {
|
||||
rownnz = d->D_rownnz;
|
||||
rowadr = d->D_rowadr;
|
||||
@@ -1261,17 +1258,6 @@ static void makeDofDofmaps(const mjModel* m, mjData* d) {
|
||||
}
|
||||
}
|
||||
|
||||
// make mapM2M
|
||||
for (int i=0; i < nM; i++) d->mapM2M[i] = -1;
|
||||
copyM2Sparse(m, d, d->mapM2M, M, /*reduced=*/0, /*upper=*/0);
|
||||
|
||||
// check that all indices are filled in
|
||||
for (int i=0; i < nM; i++) {
|
||||
if (d->mapM2M[i] < 0) {
|
||||
mjERROR("unassigned index in mapM2M");
|
||||
}
|
||||
}
|
||||
|
||||
mj_freeStack(d);
|
||||
}
|
||||
|
||||
@@ -1989,8 +1975,7 @@ static void _resetData(const mjModel* m, mjData* d, unsigned char debug_value) {
|
||||
makeBSparse(m, d);
|
||||
checkDBSparse(m, d);
|
||||
|
||||
// make M, C
|
||||
makeDofDofSparse(m, d, d->M_rownnz, d->M_rowadr, NULL, d->M_colind, /*reduced=*/0, /*upper=*/0);
|
||||
// make C
|
||||
makeDofDofSparse(m, d, d->C_rownnz, d->C_rowadr, NULL, d->C_colind, /*reduced=*/1, /*upper=*/0);
|
||||
|
||||
// make index mappings: mapM2D, mapD2M, mapM2C, mapM2M
|
||||
|
||||
@@ -1160,37 +1160,6 @@ void mj_printFormattedData(const mjModel* m, const mjData* d, const char* filena
|
||||
}
|
||||
fprintf(fp, "\n\n");
|
||||
|
||||
// M sparse structure
|
||||
mj_printSparsity("M: inertia matrix", m->nv, m->nv, d->M_rowadr, NULL, d->M_rownnz,
|
||||
NULL, d->M_colind, fp);
|
||||
|
||||
fprintf(fp, NAME_FORMAT, "M_rownnz");
|
||||
for (int i = 0; i < m->nv; i++) {
|
||||
fprintf(fp, " %d", d->M_rownnz[i]);
|
||||
}
|
||||
fprintf(fp, "\n\n");
|
||||
|
||||
// M_rowadr
|
||||
fprintf(fp, NAME_FORMAT, "M_rowadr");
|
||||
for (int i = 0; i < m->nv; i++) {
|
||||
fprintf(fp, " %d", d->M_rowadr[i]);
|
||||
}
|
||||
fprintf(fp, "\n\n");
|
||||
|
||||
// M_colind
|
||||
fprintf(fp, NAME_FORMAT, "M_colind");
|
||||
for (int i = 0; i < m->nM; i++) {
|
||||
fprintf(fp, " %d", d->M_colind[i]);
|
||||
}
|
||||
fprintf(fp, "\n\n");
|
||||
|
||||
// mapM2M
|
||||
fprintf(fp, NAME_FORMAT, "mapM2M");
|
||||
for (int i = 0; i < m->nM; i++) {
|
||||
fprintf(fp, " %d", d->mapM2M[i]);
|
||||
}
|
||||
fprintf(fp, "\n\n");
|
||||
|
||||
// C sparse structure
|
||||
mj_printSparsity("C: reduced dof-dof matrix", m->nv, m->nv, d->C_rowadr, NULL, d->C_rownnz,
|
||||
NULL, d->C_colind, fp);
|
||||
|
||||
@@ -4951,10 +4951,6 @@ public unsafe struct mjData_ {
|
||||
public int* B_rownnz;
|
||||
public int* B_rowadr;
|
||||
public int* B_colind;
|
||||
public int* M_rownnz;
|
||||
public int* M_rowadr;
|
||||
public int* M_colind;
|
||||
public int* mapM2M;
|
||||
public int* C_rownnz;
|
||||
public int* C_rowadr;
|
||||
public int* C_colind;
|
||||
|
||||
Reference in New Issue
Block a user