Skip to content

Conversation

@zfergus
Copy link
Member

@zfergus zfergus commented Aug 18, 2025

Description

This pull request introduces support for rigid body dynamics simulation.

Rigid body dynamics support in Python bindings

  • Added a new dynamics module with subfolder rigid, including Simulator, RigidBodies, Pose, and Poses classes, and exposed them via pybind11 in the Python bindings

Improvements to CMake dependency management

  • Updated CPM versions and refactored third-party recipes to use the OPTIONS argument for configuration, improving clarity and maintainability.
  • Added a new CMake recipe for TinyGLTF and integrated it into the build.

Python usability improvements and new examples

  • Added a new example script demonstrating rigid body simulation and visualization using ipctk, meshio, and polyscope (python/examples/rigid.py).

Minor Python binding improvements

  • Changed save_obj method to write_obj in Candidates Python bindings for clarity.
  • Made CollisionMesh Python class use std::shared_ptr for better memory management.

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

zfergus and others added 17 commits May 31, 2024 00:41
- Added InertialTerm class for computing energy, gradient, and Hessian of rigid bodies.
- Implemented mass properties computation for 2D and 3D meshes, including point clouds.
- Created pose representation with rotation vector and matrix conversions.
- Developed RigidBodies class to manage multiple rigid bodies from mesh data.
- Implemented ImplicitEuler time integrator for updating positions and velocities.
- Added unit tests for mass properties and pose transformations using Catch2 framework.
- Updated finite-diff package from version 1.0.1 to 1.0.3 in CMake configuration.
- Remove template from Pose.
- Modified RigidBody and related classes to use the updated Pose structure.
- Added unit tests for RigidBody construction and transformations.
- Update CPM to 0.42.0
- Add TinyGLTF dependency
- Rename save_obj to write_candidates_obj
- Add write_gltf
@zfergus zfergus added the enhancement New feature or request label Aug 18, 2025
@zfergus zfergus added this to the v1.5.0 milestone Aug 18, 2025
@codecov
Copy link

codecov bot commented Aug 18, 2025

Codecov Report

❌ Patch coverage is 74.58894% with 510 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.24%. Comparing base (893dbf2) to head (7febecd).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/ipc/io/write_gltf.cpp 0.00% 164 Missing ⚠️
src/ipc/dynamics/rigid/simulator.cpp 0.00% 88 Missing ⚠️
...rc/ipc/dynamics/affine/orthogonality_potential.cpp 36.58% 52 Missing ⚠️
src/ipc/dynamics/rigid/mass.cpp 67.10% 50 Missing ⚠️
src/ipc/dynamics/rigid/rigid_candidates.cpp 0.00% 44 Missing ⚠️
src/ipc/dynamics/rigid/pose.hpp 41.30% 27 Missing ⚠️
src/ipc/dynamics/rigid/time_integrator.hpp 48.71% 20 Missing ⚠️
src/ipc/dynamics/rigid/rigid_bodies.hpp 39.13% 14 Missing ⚠️
src/ipc/dynamics/rigid/inertial_term.cpp 84.70% 13 Missing ⚠️
src/ipc/candidates/candidates.cpp 0.00% 9 Missing ⚠️
... and 9 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #184      +/-   ##
==========================================
- Coverage   96.96%   95.24%   -1.73%     
==========================================
  Files         161      182      +21     
  Lines       24747    25905    +1158     
  Branches      893     1010     +117     
==========================================
+ Hits        23997    24672     +675     
- Misses        750     1233     +483     
Flag Coverage Δ
unittests 95.24% <74.58%> (-1.73%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- Introduce new overloads for build methods across various classes, allowing for the use of precomputed AABBs.
- Update related documentation and ensure consistent handling of vertex boxes and edges.
- Improve voxel size suggestion logic based on bounding box dimensions.
@zfergus zfergus removed this from the v1.5.0 milestone Jan 26, 2026
Move sinc implementation from ipc/utils to ipc/math and update CMake.
Replace includes of ipc/utils/interval.hpp with ipc/math/interval.hpp.
Expose NonlinearCCD constructor and properties in Python bindings and
adjust tests accordingly. Rename candidates::save_obj to write_obj and
add missing ipc/geometry/normal.hpp includes where required.
- Reorder conservative_piecewise_linear_ccd parameters so min_distance
  comes before tmax, rename the intermediate min_distance to
  min_distance_linear to avoid confusion/shadowing, and update all
  call-sites accordingly.
- Also remove an overly restrictive assertion in
  HashGrid::resize that limited the grid size.
- Rename BodyForces parameters (force/torque -> q_hat/Q_hat).
- Add const qualifiers to InertialTerm methods.
- Take RigidBodies shared_ptr and the Simulator callback by reference.
- Add linter NOLINT annotations, remove an unused include, replace/tidy
  sinc taylor bound constants, and fix RigidBodies initializer and
  RigidBody enum underlying type.
- q_hat and Q_hat should be force and torque in BodyForces
Replace many Eigen vector/matrix parameters with Eigen::ConstRef to
avoid unnecessary copies and clarify ownership. Also add const
correctness to various methods (e.g. BodyForces operator(), gradient),
rename forces/torques to m_forces/m_torques, add test_body_forces.
- Add Pose::inverse
- Fix Pose::operator*
- Update tests to use finite_jacobian_tensor
Add checks in BodyForces to skip translational and rotational
computations when force or torque is zero, avoiding unnecessary
dot/jacobian/hessian work. Also add test diagnostics: include iostream
and print analytical vs numerical gradient/hessian on comparison
failures to aid debugging.
- Updated the return types of tangent basis Jacobian functions to reflect correct matrix dimensions.
- Modified the corresponding test cases to use auto for Jacobian variable declarations for improved readability.
- Added new test cases for point-point, point-edge, edge-edge, and point-triangle relative velocity matrix Jacobians, ensuring analytical and numerical Jacobians are compared.
- Included necessary headers for finite difference calculations in the test files.
- Implemented GroundContact class for handling ground interaction in rigid body dynamics.
- Added methods for energy computation, gradient, and Hessian in GroundContact.
- Updated rigid body simulator to include body forces and integrate ground contact dynamics.
- Refactored rigid body initialization to apply centering pose correctly.
- Added tests for GroundContact energy, gradient, and Hessian calculations.
- Enhanced pose class with methods for transforming vertices and computing Jacobians and Hessians.
- Updated existing tests to ensure compatibility with new features and validate correctness.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants