Skip to content

Commit a124b9b

Browse files
authored
Flatten dartpy namespace and add snake_case shims (#2259)
1 parent 8da1382 commit a124b9b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1138
-805
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- See [Compatibility Policy](docs/onboarding/compatibility-policy.md) for details
1010
- Renamed `RootJointType` enum values to PascalCase (`Floating`, `Fixed`) across `dart::utils::SdfParser`, `dart::utils::DartLoader`, and their dartpy bindings to align with the code-style guidelines.
1111
- Removed all optional optimizer plugins (`dart-optimizer-ipopt`, `dart-optimizer-nlopt`, `dart-optimizer-pagmo`, and `dart-optimizer-snopt`) along with the pagmo-based multi-objective optimization APIs since they were only exercised by tests.
12+
- Flattened the dartpy namespace to `dartpy`, `dartpy.io` (alias for `utils`), and `dartpy.gui`, promoting core symbols to the package root and deprecating deep module paths (`dartpy.dynamics`, `dartpy.collision`, etc.) plus camelCase names. Legacy modules and camelCase remain available with `DeprecationWarning` for DART 7.x and are slated for removal in DART 8.0 (see `DARTPY_ENABLE_LEGACY_MODULES`, `DARTPY_WARN_ON_LEGACY_MODULES`, `DARTPY_ENABLE_SNAKE_CASE`, `DARTPY_WARN_ON_CAMELCASE`).
1213
- Moved the generic optimization primitives (`Function`, `Problem`, `Solver`, `GradientDescentSolver`) under `dart/math/optimization`; the legacy `<dart/optimizer/...>` headers and `dart::optimizer::*` namespace now forward (with deprecation notices) to the new `dart::math::*` definitions.
1314
- Dropped the deprecated `docker/dev/v6.15` images; use the maintained v6.16 images instead.
1415
- Renamed the OpenSceneGraph GUI component/target to `gui`/`dart-gui` (previously `gui-osg`/`dart-gui-osg`) and replaced the `DART_BUILD_GUI_OSG` toggle with `DART_BUILD_GUI`.

docs/onboarding/README.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -558,13 +558,10 @@ graph TB
558558

559559
**Key Modules**:
560560

561-
- `dartpy.math` - Mathematical utilities and Eigen↔NumPy conversion
562-
- `dartpy.dynamics` - Skeletons, BodyNodes, Joints, IK
563-
- `dartpy.collision` - Collision detection backends
564-
- `dartpy.constraint` - Constraint solving
565-
- `dartpy.simulation` - World simulation
561+
- `dartpy` (top-level) - Core classes/functions (math, dynamics, collision, simulation, constraint, optimizer) exposed in snake_case
562+
- `dartpy.io` - File parsers (URDF, SDF, SKEL, MJCF) [alias for legacy `utils`]
566563
- `dartpy.gui` - 3D visualization with OSG and ImGui
567-
- `dartpy.utils` - File parsers (URDF, SDF, SKEL, MJCF)
564+
- Legacy `dartpy`/`math`/`dynamics`/`collision`/`simulation`/`constraint`/`optimizer`/`utils` remain importable in DART 7.x but emit `DeprecationWarning` and will be removed in DART 8.0.
568565

569566
**Key Files**:
570567

@@ -818,20 +815,20 @@ sequenceDiagram
818815
participant NumPy as NumPy
819816
820817
Python->>dartpy: import dartpy
821-
Python->>dartpy: world = dartpy.simulation.World()
818+
Python->>dartpy: world = dartpy.World()
822819
dartpy->>DART: World::create()
823820
824-
Python->>dartpy: skel = dartpy.dynamics.Skeleton.create()
821+
Python->>dartpy: skel = dartpy.Skeleton.create()
825822
dartpy->>DART: Skeleton::create()
826823
827-
Python->>dartpy: world.addSkeleton(skel)
824+
Python->>dartpy: world.add_skeleton(skel)
828825
dartpy->>DART: World::addSkeleton()
829826
830827
loop Simulation
831828
Python->>dartpy: world.step()
832829
dartpy->>DART: World::step()
833-
Python->>dartpy: q = skel.getPositions()
834-
dartpy->>DART: Skeleton::getPositions()
830+
Python->>dartpy: q = skel.get_positions()
831+
dartpy->>DART: Skeleton::get_positions()
835832
DART->>NumPy: convert Eigen to ndarray
836833
NumPy-->>Python: positions array
837834
end
@@ -1207,7 +1204,7 @@ dart_gui/
12071204
```python
12081205
import dartpy as dart
12091206
from dartpy.gui import Viewer, RealTimeWorldNode
1210-
from dartpy.utils import DartLoader
1207+
from dartpy.io import DartLoader
12111208
```
12121209

12131210
---

docs/onboarding/python-bindings.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,21 @@
4545

4646
### Module Structure
4747

48-
dartpy organizes DART's C++ API into Python modules:
48+
dartpy now flattens most symbols onto the top-level package to avoid deep
49+
namespaces:
4950

5051
```
5152
dartpy/
52-
├── math # Eigen integration, geometry utilities
53-
├── dynamics # Skeletons, BodyNodes, Joints
54-
├── collision # Collision detection backends
55-
├── constraint # Constraint solving
56-
├── simulation # World simulation
57-
├── utils # File parsers (URDF, SDF, SKEL, MJCF)
53+
├── io # File parsers (URDF, SDF, SKEL, MJCF)
5854
└── gui # 3D visualization (OpenSceneGraph + ImGui)
5955
```
6056

57+
- Core classes/functions (dynamics, collision, math, simulation, constraint,
58+
optimizer) are promoted onto `dartpy` directly.
59+
- Legacy submodules remain importable in DART 7.x but will be removed in DART
60+
8.0. Toggle deprecation handling with `DARTPY_WARN_ON_LEGACY_MODULES` or
61+
`DARTPY_ENABLE_LEGACY_MODULES`.
62+
6163
**Source**: See `python/dartpy/` directory for module implementations
6264

6365
### Eigen ↔ NumPy Integration
@@ -80,10 +82,10 @@ import dartpy as dart
8082
import numpy as np
8183

8284
# NumPy arrays automatically convert to Eigen types
83-
skel.setPositions(np.array([0.1, 0.2, 0.3]))
85+
skel.set_positions(np.array([0.1, 0.2, 0.3]))
8486

8587
# Eigen types automatically convert to NumPy arrays
86-
positions = skel.getPositions() # Returns ndarray
88+
positions = skel.get_positions() # Returns ndarray
8789
```
8890

8991
### OSG Bindings Design
@@ -111,6 +113,13 @@ positions = skel.getPositions() # Returns ndarray
111113

112114
**Result**: OSG now works on all platforms where OpenSceneGraph is available (Linux, macOS, Windows via conda-forge)
113115

116+
## Pythonic Naming Transition
117+
118+
- All camelCase bindings now receive snake_case aliases at import time (runtime shim lives in `python/dartpy/_naming.py`)
119+
- camelCase still works but emits a one-time `DeprecationWarning` per symbol by default; set `DARTPY_WARN_ON_CAMELCASE=0` to silence
120+
- Turn the shim off entirely with `DARTPY_ENABLE_SNAKE_CASE=0` (useful for bisecting)
121+
- Prefer snake_case in new code; ship a codemod/release note alongside the next major to help users update usages
122+
114123
## Installation Methods
115124

116125
### For End Users
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
dartpy.collision
2-
================
1+
dartpy
2+
======
33

4-
.. automodule:: dartpy.collision
4+
.. note:: Legacy submodules will be removed in DART 8.0; use top-level `dartpy`.
5+
6+
.. automodule:: dartpy
57
:members:
6-
:undoc-members:
7-
:show-inheritance:

docs/python_api/modules/common.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
dartpy.common
2-
=============
1+
dartpy
2+
======
33

4-
.. automodule:: dartpy.common
4+
.. note:: Legacy submodules will be removed in DART 8.0; use top-level `dartpy`.
5+
6+
.. automodule:: dartpy
57
:members:
6-
:undoc-members:
7-
:show-inheritance:
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
dartpy.constraint
2-
=================
1+
dartpy
2+
======
33

4-
.. automodule:: dartpy.constraint
4+
.. note:: Legacy submodules will be removed in DART 8.0; use top-level `dartpy`.
5+
6+
.. automodule:: dartpy
57
:members:
6-
:undoc-members:
7-
:show-inheritance:
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
dartpy.dynamics
2-
===============
1+
dartpy
2+
======
33

4-
.. automodule:: dartpy.dynamics
4+
.. note:: Legacy submodules will be removed in DART 8.0; use top-level `dartpy`.
5+
6+
.. automodule:: dartpy
57
:members:
6-
:undoc-members:
7-
:show-inheritance:

docs/python_api/modules/gui.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@ dartpy.gui
33

44
.. automodule:: dartpy.gui
55
:members:
6-
:undoc-members:
7-
:show-inheritance:

docs/python_api/modules/math.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
dartpy.math
2-
============
1+
dartpy
2+
======
33

4-
.. automodule:: dartpy.math
4+
.. note:: Legacy submodules will be removed in DART 8.0; use top-level `dartpy`.
5+
6+
.. automodule:: dartpy
57
:members:
6-
:undoc-members:
7-
:show-inheritance:
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
dartpy.optimizer
2-
================
1+
dartpy
2+
======
33

4-
.. automodule:: dartpy.optimizer
4+
.. note:: Legacy submodules will be removed in DART 8.0; use top-level `dartpy`.
5+
6+
.. automodule:: dartpy
57
:members:
6-
:undoc-members:
7-
:show-inheritance:

0 commit comments

Comments
 (0)