Skip to content

Commit db7a24a

Browse files
authored
[Kamino] Remove unused inertia statistics (#3542)
1 parent 8f6713e commit db7a24a

6 files changed

Lines changed: 2 additions & 120 deletions

File tree

newton/_src/solvers/kamino/_src/core/builder.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -979,10 +979,6 @@ def finalize(
979979
info_jkcio = []
980980
info_base_bid = []
981981
info_base_jid = []
982-
info_mass_min = []
983-
info_mass_max = []
984-
info_mass_total = []
985-
info_inertia_total = []
986982

987983
# Initialize the gravity data collections
988984
gravity_g_dir_acc = []
@@ -1087,12 +1083,6 @@ def collect_model_info_data():
10871083
info_jio.append(world.joints_idx_offset)
10881084
info_gio.append(world.geoms_idx_offset)
10891085

1090-
# Collect the model mass and inertia data
1091-
info_mass_min.append(world.mass_min)
1092-
info_mass_max.append(world.mass_max)
1093-
info_mass_total.append(world.mass_total)
1094-
info_inertia_total.append(world.inertia_total)
1095-
10961086
# Collect the index offsets for bodies and joints
10971087
for world in self._worlds:
10981088
info_bdio.append(world.body_dofs_idx_offset)
@@ -1366,10 +1356,6 @@ def collect_material_pairs_model_data():
13661356
joint_kinematic_cts_offset=to_warp_int32_array(info_jkcio),
13671357
base_body_index=to_warp_int32_array(info_base_bid),
13681358
base_joint_index=to_warp_int32_array(info_base_jid),
1369-
mass_min=wp.array(info_mass_min, dtype=wp.float32),
1370-
mass_max=wp.array(info_mass_max, dtype=wp.float32),
1371-
mass_total=wp.array(info_mass_total, dtype=wp.float32),
1372-
inertia_total=wp.array(info_inertia_total, dtype=wp.float32),
13731359
)
13741360

13751361
# Create the model time data

newton/_src/solvers/kamino/_src/core/conversions.py

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -124,45 +124,6 @@ def rigid_bodies_indexing_kernel(
124124
world_body_dof_offset[world_id] = 6 * model_body_world_start[world_id]
125125

126126

127-
@wp.kernel
128-
def mass_prop_accumulation_kernel(
129-
# Inputs:
130-
model_body_world_start: wp.array[wp.int32],
131-
model_body_mass: wp.array[wp.float32],
132-
body_inertia: wp.array[wp.mat33f],
133-
# Outputs:
134-
mass_total: wp.array[wp.float32],
135-
mass_min: wp.array[wp.float32],
136-
mass_max: wp.array[wp.float32],
137-
inertia_total: wp.array[wp.float32],
138-
):
139-
# Retrieve the world index
140-
world_id = wp.tid()
141-
# Retrieve the body index range for this world
142-
body_id_start = model_body_world_start[world_id]
143-
body_id_end = model_body_world_start[world_id + 1] - 1
144-
145-
mass = wp.float32(0.0)
146-
m_min = wp.float32(1e10)
147-
m_max = wp.float32(0.0)
148-
inertia = wp.float32(0.0)
149-
150-
for body_id in range(body_id_start, body_id_end + 1):
151-
mass_b = model_body_mass[body_id]
152-
mass += mass_b
153-
if mass_b < m_min:
154-
m_min = mass_b
155-
if mass_b > m_max:
156-
m_max = mass_b
157-
inertia_diag = wp.get_diag(body_inertia[body_id])
158-
inertia += 3.0 * mass_b + inertia_diag[0] + inertia_diag[1] + inertia_diag[2]
159-
160-
mass_total[world_id] = mass
161-
mass_min[world_id] = m_min
162-
mass_max[world_id] = m_max
163-
inertia_total[world_id] = inertia
164-
165-
166127
@wp.kernel
167128
def joint_conversion_kernel(
168129
# Inputs:
@@ -741,29 +702,6 @@ def convert_rigid_bodies(
741702
device=model.device,
742703
)
743704

744-
# Construct per-world inertial summaries
745-
with wp.ScopedDevice(model.device):
746-
mass_total = wp.empty((model.world_count,), dtype=wp.float32)
747-
mass_min = wp.empty((model.world_count,), dtype=wp.float32)
748-
mass_max = wp.empty((model.world_count,), dtype=wp.float32)
749-
inertia_total = wp.empty((model.world_count,), dtype=wp.float32)
750-
wp.launch(
751-
kernel=mass_prop_accumulation_kernel,
752-
dim=model.world_count,
753-
inputs=[
754-
model.body_world_start,
755-
model.body_mass,
756-
model.body_inertia,
757-
],
758-
outputs=[
759-
mass_total,
760-
mass_min,
761-
mass_max,
762-
inertia_total,
763-
],
764-
device=model.device,
765-
)
766-
767705
# model.body_q stores body-origin world poses, but Kamino expects
768706
# COM world poses (joint attachment vectors are COM-relative).
769707
q_i_0 = wp.empty((model.body_count,), dtype=wp.transformf, device=model.device)
@@ -792,10 +730,6 @@ def convert_rigid_bodies(
792730
model_info.bodies_offset = world_body_offset
793731
model_info.geoms_offset = world_shape_offset
794732
model_info.body_dofs_offset = world_body_dof_offset
795-
model_info.mass_min = mass_min
796-
model_info.mass_max = mass_max
797-
model_info.mass_total = mass_total
798-
model_info.inertia_total = inertia_total
799733

800734
model_bodies = RigidBodiesModel(
801735
num_bodies=model.body_count,

newton/_src/solvers/kamino/_src/core/model.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -401,34 +401,6 @@ class ModelKaminoInfo:
401401
Shape of ``(num_worlds,)``.
402402
"""
403403

404-
###
405-
# Inertial Properties
406-
###
407-
408-
mass_min: wp.array[wp.float32] | None = None
409-
"""
410-
Smallest mass amongst all bodies in each world.
411-
Shape of ``(num_worlds,)``.
412-
"""
413-
414-
mass_max: wp.array[wp.float32] | None = None
415-
"""
416-
Largest mass amongst all bodies in each world.
417-
Shape of ``(num_worlds,)``.
418-
"""
419-
420-
mass_total: wp.array[wp.float32] | None = None
421-
"""
422-
Total mass over all bodies in each world.
423-
Shape of ``(num_worlds,)``.
424-
"""
425-
426-
inertia_total: wp.array[wp.float32] | None = None
427-
"""
428-
Total diagonal inertia over all bodies in each world.
429-
Shape of ``(num_worlds,)``.
430-
"""
431-
432404

433405
@dataclass
434406
class ModelKamino:

newton/_src/solvers/kamino/solver_kamino.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,8 +1162,8 @@ def _check_dynamic_constraint_topology(self) -> None:
11621162
joint = int(changed[0]) # report only first violation
11631163
raise RuntimeError(
11641164
f"Changing dynamic constraint topology for joint {joint} "
1165-
f"({self.model.joint_label[joint]!r}) is not supported; recreate SolverKamino to apply the change."
1166-
"The dynamic constraint topology changes if armature, damping, target stiffness, or target damping are updated to non-zero values, while they were zero when creating the solver."
1165+
f"({self.model.joint_label[joint]!r}) is not supported; recreate SolverKamino to apply the change. "
1166+
"The dynamic constraint topology changes if armature, damping, target stiffness, or target damping are updated to non-zero values, while they were zero when creating the solver. "
11671167
"The opposite is also true: if the values are updated to zero, while they were non-zero when creating the solver, the dynamic constraint topology also changes."
11681168
)
11691169

newton/_src/solvers/kamino/tests/utils/checks.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,10 +406,6 @@ def assert_model_info_equal(
406406
"joint_kinematic_cts_group_offset",
407407
"base_body_index",
408408
"base_joint_index",
409-
"mass_min",
410-
"mass_max",
411-
"mass_total",
412-
"inertia_total",
413409
]
414410
if excluded:
415411
array_attributes = [attr for attr in array_attributes if attr not in excluded]

newton/_src/solvers/kamino/tests/utils/print.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,6 @@ def print_model_info(model: ModelKamino):
9191
print(f"model.info.total_cts_offset: {model.info.total_cts_offset}")
9292
print(f"model.info.joint_dynamic_cts_group_offset: {model.info.joint_dynamic_cts_group_offset}")
9393
print(f"model.info.joint_kinematic_cts_group_offset: {model.info.joint_kinematic_cts_group_offset}")
94-
# Print the inertial properties
95-
print("-------------------------------------------------------------------------------")
96-
print(f"model.info.mass_min: {model.info.mass_min}")
97-
print(f"model.info.mass_max: {model.info.mass_max}")
98-
print(f"model.info.mass_total: {model.info.mass_total}")
99-
print(f"model.info.inertia_total: {model.info.inertia_total}")
10094

10195

10296
def print_model_constraint_info(model: ModelKamino):

0 commit comments

Comments
 (0)