Skip to content

Document maximal vs. generalized coordinates, update overview page#859

Merged
eric-heiden merged 13 commits into
newton-physics:mainfrom
eric-heiden:improve-docs
Oct 6, 2025
Merged

Document maximal vs. generalized coordinates, update overview page#859
eric-heiden merged 13 commits into
newton-physics:mainfrom
eric-heiden:improve-docs

Conversation

@eric-heiden

@eric-heiden eric-heiden commented Sep 30, 2025

Copy link
Copy Markdown
Member

Description

  • Document maximal vs. generalized coordinates - closes Document maximal vs. reduced coordinates #325.
  • Document ModelBuilder.add_articulation()
  • Use "forest" theme and NVIDIA green edge colors for mermaid diagram to improve legibility under dark theme:
image

Newton Migration Guide

Please ensure the migration guide for warp.sim users is up-to-date with the changes made in this PR.

  • The migration guide in docs/migration.rst is up-to date

Before your PR is "Ready for review"

  • Necessary tests have been added and new examples are tested (see newton/tests/test_examples.py)
  • Documentation is up-to-date
  • Code passes formatting and linting checks with pre-commit run -a

Summary by CodeRabbit

  • Documentation
    • Added “Generalized and maximal coordinates” under Articulations with representations, forward/inverse kinematics, examples, and usage snippets.
    • Updated overview wording/capitalization, renamed Renderer → Viewer, added Open Source to Key Features, and improved architecture diagram/config.
    • Added Newton solver workflow docs, Supported Features table, and module-level solver documentation; clarified builder behavior via expanded docstring and a brief note for Featherstone.
    • Bumped documented API version, added vec_allclose / vec_inside_limits to utils docs, and improved API doc generation to include full module docstrings.

Signed-off-by: Eric Heiden <eric-heiden@outlook.com>
Signed-off-by: Eric Heiden <eric-heiden@outlook.com>
Signed-off-by: Eric Heiden <eric-heiden@outlook.com>
@coderabbitai

coderabbitai Bot commented Sep 30, 2025

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Documentation-focused updates: added a "Generalized and maximal coordinates" section under Articulations, multiple guide/API doc edits (overview, solver docs, version bump), autosummary additions for utils, generator tweak to include full module docstrings, and small module/docstring additions in builder and solver modules. No behavioral or public API changes.

Changes

Cohort / File(s) Summary
Docs — Concepts: Articulations
docs/concepts/articulations.rst
Added "Generalized and maximal coordinates" section describing generalized/reduced and maximal parameterizations, representations, FK/IK conversions, solver-specific notes, ModelBuilder examples (revolute/free joints), xform initialization, eval_fk usage, and testcode snippets.
Docs — Guide: Overview
docs/guide/overview.rst
Copy edits: corrected "MuJoCo" capitalization, renamed "Renderer" → "Viewer" (text and architecture diagram), added Mermaid config (theme/line color), and added an "Open Source" bullet under Key Features.
Docs — API / Solvers docs
docs/api/newton_solvers.rst
docs/api/newton.rst
Expanded newton_solvers.rst with solver workflow and "Supported Features" table and mermaid flow; bumped __version__ in newton.rst from 0.1.1.a20.1.3. Documentation-only edits.
Docs — Utilities autosummary
docs/api/newton_utils.rst
Added vec_allclose and vec_inside_limits to the newton.utils autosummary (documentation entries added; no implementation changes indicated).
Docs — Doc generation
docs/generate_api.py
Changed module documentation extraction to include the full module docstring (no longer truncating at first paragraph).
Code — Builder docstring
newton/_src/sim/builder.py
Replaced inline comments in add_articulation with a descriptive docstring explaining articulation ranges, parallelization over articulations (e.g., FK), and finalize behavior. No signature or behavior changes.
Code — Solvers module docstring
newton/solvers.py
Added module-level docstring describing solver workflow, inputs/outputs, and supported features. No API or behavioral changes.
Code — Featherstone solver docstring
newton/_src/solvers/featherstone/solver_featherstone.py
Added a single-line docstring noting reuse of SolverSemiImplicit routines for particles/cloth/soft bodies. No functional changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • mmacklin

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning Beyond the primary documentation for maximal versus generalized coordinates, this pull request introduces numerous unrelated changes including overview page terminology updates, API reference enhancements, documentation generator behavior adjustments, version bumps, and module docstring additions that fall outside the scope of issue #325. Please isolate non-coordinate documentation and tooling changes into separate pull requests so that this one remains focused solely on addressing issue #325.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly describes the core documentation update of maximal versus generalized coordinates and the overview page modification, directly aligning with the main focus of the changeset.
Linked Issues Check ✅ Passed The pull request adds a comprehensive “Generalized and maximal coordinates” section under Articulations that clearly documents both parameterizations and conversion workflows, thereby satisfying the requirements of issue #325.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

📜 Recent review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between df33f15 and 9e4bca9.

📒 Files selected for processing (2)
  • docs/api/newton_solvers.rst (1 hunks)
  • newton/solvers.py (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@eric-heiden eric-heiden changed the title Improve docs Document maximal vs. generalized coordinates, update overview page Sep 30, 2025
Comment thread docs/concepts/articulations.rst Outdated
Comment thread docs/concepts/articulations.rst Outdated
Comment thread docs/concepts/articulations.rst
Comment thread docs/concepts/articulations.rst
Comment thread docs/concepts/articulations.rst
Comment thread docs/concepts/articulations.rst Outdated
Comment thread docs/concepts/articulations.rst Outdated
Signed-off-by: Eric Heiden <eric-heiden@outlook.com>
Signed-off-by: Eric Heiden <eric-heiden@outlook.com>
Signed-off-by: Eric Heiden <eric-heiden@outlook.com>
Signed-off-by: Eric Heiden <eric-heiden@outlook.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/concepts/articulations.rst (1)

207-229: Variable-name mixup (joint_index vs joint_id) and base index.

You introduce joint_index but then use joint_id. Pick one consistently. Also explicitly state that axis arrays are indexed in the same order as joint_qd_start.

-    num_linear_dofs = Model.joint_dof_dim[joint_index, 0]
-    num_angular_dofs = Model.joint_dof_dim[joint_index, 1]
-    # the joint axes for each joint start at this index:
-    axis_start = Model.joint_qd_start[joint_id]
+    num_linear_dofs = Model.joint_dof_dim[joint_index, 0]
+    num_angular_dofs = Model.joint_dof_dim[joint_index, 1]
+    # the per‑axis arrays follow the same ordering as joint velocities; start at:
+    axis_start = Model.joint_qd_start[joint_index]
♻️ Duplicate comments (1)
docs/concepts/articulations.rst (1)

14-18: Clarify fixed-base vs floating-base in the first example sentence.

As written, “two generalized coordinates … corresponding to the two joint angles and velocities” mixes positions and velocities and implicitly assumes a fixed base. Suggest being explicit and separating positions from velocities.

- Generalized (sometimes also called "reduced") coordinates describe the configuration of an articulation in terms of joint positions and velocities.
- That means, if an articulation has three bodies connected by two revolute joints, the articulation has two generalized coordinates corresponding to the two joint angles (:attr:`newton.State.joint_q`) and joint velocities (:attr:`newton.State.joint_qd`).
+ Generalized (sometimes also called "reduced") coordinates describe the configuration of an articulation in terms of joint positions (:attr:`newton.State.joint_q`) and joint velocities (:attr:`newton.State.joint_qd`).
+ For a fixed‑base articulation with three bodies connected by two revolute joints, there are two positional generalized coordinates (the two joint angles) and two velocity coordinates (the two joint angular velocities).
🧹 Nitpick comments (4)
docs/concepts/articulations.rst (4)

32-48: Doctest robustness: add imports and tolerant float checks.

These doctests rely on newton, wp, and exact float equality. Make the block self‑contained and use np.isclose/allclose.

 .. testcode::
 
-  builder = newton.ModelBuilder()
+  import numpy as np
+  import warp as wp
+  import newton
+
+  builder = newton.ModelBuilder()
   builder.add_articulation()
   body = builder.add_body()
   builder.add_shape_box(body)  # add a shape to the body to add some inertia
   builder.add_joint_revolute(parent=-1, child=body, axis=wp.vec3(0.0, 0.0, 1.0))  # add a revolute joint to the body
   builder.joint_q[-1] = 0.5
   builder.joint_qd[-1] = 10.0
 
   model = builder.finalize()
   state = model.state()
 
   # The generalized coordinates have been initialized by the revolute joint:
-  assert all(state.joint_q.numpy() == [0.5])
-  assert all(state.joint_qd.numpy() == [10.0])
+  assert np.allclose(state.joint_q.numpy(), [0.5])
+  assert np.allclose(state.joint_qd.numpy(), [10.0])

101-107: Use tolerant comparison for joint_q vs transform.

Same flattening/equality concerns as above; compare pos/quat with tolerance.

-  assert len(state.joint_q) == 7
-  assert all(state.joint_q.numpy() == [*tf])
+  import numpy as np
+  assert len(state.joint_q) == 7
+  pos = wp.transform_get_translation(tf); quat = wp.transform_get_rotation(tf)
+  assert np.allclose(state.joint_q.numpy(), [pos[0], pos[1], pos[2], quat[0], quat[1], quat[2], quat[3]])

167-178: Minor consistency: qualify Model/State in examples or add a preface.

Elsewhere you use fully qualified names. Consider either from newton import Model, State in a setup block or qualify here for consistency.


83-98: Remove invalid slice assignment in free joint example.

  • add_joint_free(body) already binds to the world by default (parent=-1), so no change needed.
  • The commented
    # builder.joint_q[-7:] = *tf
    is invalid (and references non-existent helpers). Either remove it or replace it with a valid example using the actual API for extracting the translation and quaternion from the tf transform.
📜 Review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b40e377 and 80363bb.

📒 Files selected for processing (2)
  • docs/concepts/articulations.rst (1 hunks)
  • newton/_src/sim/builder.py (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • newton/_src/sim/builder.py
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Run GPU Unit Tests on AWS EC2 (Pull Request)
  • GitHub Check: Run GPU Benchmarks (Pull Request)
  • GitHub Check: run-newton-tests / newton-unittests (windows-latest)
🔇 Additional comments (4)
docs/concepts/articulations.rst (4)

53-61: Good: FK guidance for maximal-coordinate solvers.

Clear call‑out that generalized solvers don’t require eval_fk; this addresses earlier confusion.


231-273: Kinematics section looks solid.

Notation, variable table, and FK equation are clear and consistent.


120-160: Remove incorrect distance DOF recheck. The docs table matches the implementation in sim/joints.py (for JointType.DISTANCE, coord_count = 7 and dof_count = 6 with one constraint axis), so no changes needed.

Likely an incorrect or invalid review comment.


26-28: Coordinate conventions confirmed
SolverFeatherstone and SolverMuJoCo operate on generalized coordinates (State.joint_q/joint_qd), while SolverXPBD and SolverSemiImplicit operate on maximal coordinates (State.body_q/body_qd). Class names and modules are correct.

Comment thread docs/concepts/articulations.rst
Comment thread docs/concepts/articulations.rst
Comment thread docs/concepts/articulations.rst
Comment thread docs/concepts/articulations.rst Outdated
Comment thread newton/_src/sim/builder.py
Comment thread newton/_src/sim/builder.py
Comment thread docs/concepts/articulations.rst
Comment thread docs/concepts/articulations.rst
Comment thread docs/concepts/articulations.rst Outdated
Comment thread docs/concepts/articulations.rst Outdated
Signed-off-by: Eric Heiden <eric-heiden@outlook.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
newton/solvers.py (1)

16-18: LGTM! Consider optionally expanding the docstring.

The module docstring is clear and accurate. Since this module re-exports multiple solver types, you might optionally enhance it to briefly mention the available solvers or link to the documentation.

For example:

 """
-Solvers are used to integrate the dynamics of a Newton model.
+Solvers are used to integrate the dynamics of a Newton model.
+
+Available solvers include Featherstone, Semi-Implicit, XPBD, VBD, and others.
+See the documentation for details on each solver type and usage examples.
 """
📜 Review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 80363bb and 78d0e21.

📒 Files selected for processing (4)
  • docs/api/newton.rst (1 hunks)
  • docs/api/newton_solvers.rst (1 hunks)
  • docs/concepts/articulations.rst (1 hunks)
  • newton/solvers.py (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • docs/api/newton.rst
  • docs/concepts/articulations.rst
  • docs/api/newton_solvers.rst
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Run GPU Benchmarks (Pull Request)
  • GitHub Check: Run GPU Unit Tests on AWS EC2 (Pull Request)

Signed-off-by: Eric Heiden <eric-heiden@outlook.com>
Signed-off-by: Eric Heiden <eric-heiden@outlook.com>
@eric-heiden

Copy link
Copy Markdown
Member Author

@preist-nvidia, @adenzler-nvidia I've just updated the docs again, let me know if you have any more comments.

Comment thread newton/solvers.py Outdated
preist-nvidia
preist-nvidia previously approved these changes Oct 6, 2025

@preist-nvidia preist-nvidia left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @eric-heiden !

@eric-heiden eric-heiden merged commit 1f96ffc into newton-physics:main Oct 6, 2025
10 of 11 checks passed
eric-heiden added a commit to eric-heiden/newton that referenced this pull request Jan 28, 2026
mmacklin pushed a commit to mmacklin/newton that referenced this pull request Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document maximal vs. reduced coordinates

3 participants