Skip to content

Conversation

@andrewkaufman
Copy link
Member

Description

This is an initial implementation of #2 to test out the CI workflow now that we are public.

Checklist

This is an initial single apply API just to get started. It will have more attributes eventually
@andrewkaufman andrewkaufman self-assigned this Nov 5, 2025
@codecov
Copy link

codecov bot commented Nov 5, 2025

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

@andrewkaufman andrewkaufman marked this pull request as ready for review November 6, 2025 00:02
Copy link
Member Author

@andrewkaufman andrewkaufman left a comment

Choose a reason for hiding this comment

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

I pushed an update to limit NewtonSceneAPI to PhysicsScene prims only & I added an API level doc string.

I decided to leave the other attribute strings simple for now, we can revisit if someone has a better suggestion in review.

vastsoun
vastsoun previously approved these changes Nov 26, 2025
Copy link
Member

@vastsoun vastsoun left a comment

Choose a reason for hiding this comment

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

LGTM overall.

My only comment pertains to the docstring of the max iterations parameter.

Note enableGravity is varying to allow animating gravity on/off
@andrewkaufman andrewkaufman changed the title Add NewtonSceneAPI with 2 attributes Add NewtonSceneAPI Nov 26, 2025
@andrewkaufman
Copy link
Member Author

@vastsoun I addressed your comment & also pushed an additional change to add enableGravity as we discussed in the meeting. Please re-review 🙇

@AlesBorovicka
Copy link

Can we please add a convention to all the attributes related to ranges and units? Like this ideally:
Range: [0, inf)
Units: dimensionless
It would make our live easier for validation, we can process the ranges and units and validate. Ideally we follow some convention. The above is what we already use.
See also: https://github.com/PixarAnimationStudios/OpenUSD/blob/release/pxr/usd/usdPhysics/schema.usda#L576

doc = "Maximum number of iterations of the physics solver"
)

uniform double newton:timeStep = 0.005 (

Choose a reason for hiding this comment

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

Before we go double crazy, can we double check with Pixar? When we wrote UsdPhysics it was recommended to use floats everywhere instead of doubles. Using double in timeStep is strange, if you care about precision why do we not use integer and frequency.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep I will double check. Happy to change to float

Copy link
Member Author

Choose a reason for hiding this comment

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

It seems they are both used frequently. Interesting note from Claude, that kind of implies UsdPhysics should use more doubles than it does currently:

Semantic distinction:
float → rendering/visual parameters, light properties, camera settings
double → geometric dimensions, precise measurements, parametric ranges

On the timeStep, I agree with @AlesBorovicka point that float is good enough for timeStep, so I've changed that. If anyone disagrees please re-open the thread.

Copy link
Member Author

Choose a reason for hiding this comment

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

Though probably worth pointing out this change required switching to assertAlmostEqual in the unittests, so we immediately hit the precision issue with the fallback value 0.005

Choose a reason for hiding this comment

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

But if you care about precision why dont use hz - uint? Even authoring these tiny values dont make sense. Hz are very clear, any engine can divide...

Choose a reason for hiding this comment

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

We do use it in PhysxSchema, it seems to be supported by USD.

Yes, I would suggest we discuss this next time, hope I wont get a conflict meeting this time.

Copy link
Member Author

@andrewkaufman andrewkaufman Dec 2, 2025

Choose a reason for hiding this comment

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

uint is a supported type for sure, it just doesn't occur in any schema.usda in the USD repo (fakes schemas for test coverage aside). All of the "should probably be a uint" attributes in USD official schemas use int instead (e.g. sampling settings, indices)

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

FWIW, I would also be OK with frequency.

The rationale makes sense as it is closer to thinking in terms of frame-rate, which often is more intuitive for many users.

@andrewkaufman
Copy link
Member Author

andrewkaufman commented Dec 1, 2025

Can we please add a convention to all the attributes related to ranges and units? Like this ideally:
Range: [0, inf)
Units: dimensionless

There is a fairly new official mechanism for range UI hints, I think we should adopt the official system instead. I've split this out into #11 to investigate the new mechanism. We can still do it asap, just don't want to block this PR on it.

doc = "NewtonSceneAPI applies on top of a PhysicsScene Prim, providing attributes to control a Newton Solver."
)
{
uniform int newton:maxSolverIterations = 100 (
Copy link
Member

Choose a reason for hiding this comment

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

is 100 a reasonable default value? I think a reasonable default value is way smaller for both mjc and physX IIRC.
I think we should either interpolate between the default values used by physX and MJC, or just use of them directly

Copy link
Member Author

Choose a reason for hiding this comment

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

You had 100 in the spreadsheet, so I assumed that's what people agreed to. Happy to change it to any value that has majority consensus.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

yeah I must have taken the mujoco default but for physX articulations for instance we have the following defaults
physxArticulation:solverPositionIterationCount = 32
physxArticulation:solverVelocityIterationCount = 1

the global ones (which I am not sure how are used in conjunction with per-actor ones above
physxScene:maxVelocityIterationCount = 255
physxScene:maxPositionIterationCount = 255

XPBD default iteration count is 2 for cloth solvers like VBD/Style3D this is 10.

Copy link
Member

Choose a reason for hiding this comment

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

I am having second thoughts on this and I am wondering if we should add this at all to scene given that this is solver parameter. For instance, I imagine that specific solvers may want to avoid using this (in case this is also used for any other subsystem they don't want to mess up, e.g. having a both cloth solver and rigid solver in the scene, the cloth solver may want to use different value)

Copy link
Member

Choose a reason for hiding this comment

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

Let's discuss the options in the next meeting. The other option is to have each solver define their own schema API and add it to the single scene prim, but I agree that timestep and iteration are two of the most common solver parameters that probably make sense to have here. @AlesBorovicka @preist-nvidia what do you think?

Choose a reason for hiding this comment

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

I always thought we would use variants for this or different scenes, if there is a clear separation in the stage that some part is simulated by one engine and another by another engine, then you should have two scenes, hence two APIs that define this.
If this is within one asset I though we use variants for the engines or as proposed by Renato sublayers, though I have to say I would prefer variants to have all self contained in one asset. But I expect that it will happen that some parameters will be different for a different engine especially parameters that dont have physical meaning like the solve iteration count, step size...

Copy link
Member

Choose a reason for hiding this comment

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

  1. Regarding the question of default values:
    Does it make sense to use sentinel values (e.g. -1) by default to allow solvers to configure themselves according to their own defaults, that they set/define internally? This would avoid the question altogether, and then just allow the resolver/importer to set values only if set explicitly.

  2. On the matter of how some solvers actually require more than one maxiters, or a very special set:
    Why not treat this as scene attribute as optional, just like how in other parts of USD, e.g. not all physics backends realize certain types of friction models like static/dynamics, so it's up to the implementation to decide whether to use it or not. So in effect, I'm propose to have newton:solverMaxIterations, but use it only if-and-only-if it's set and supported.

As others mentioned above, if a solver requires it's own special configs, then their custom API could be the mechanism to facilitate it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I like the sentinal idea & also it justifies int over uint 😅

Copy link
Member

Choose a reason for hiding this comment

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

yeah that sounds good, I am fine with keeping them since they are super generic and any solver can use them really with their own interpretation of what that should mean

Copy link
Collaborator

@havess havess left a comment

Choose a reason for hiding this comment

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

LGTM, I'm not super pressed about maxSolverIterations defaults. Odds are if you're authoring this you know what you're targeting, and defaults are easy enough to change later.

Copy link
Member

@vastsoun vastsoun left a comment

Choose a reason for hiding this comment

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

@andrewkaufman I've provided a few comments, and like the other reviewers, regarding the question of SceneAPI parameters and default values.

One other concern I have is regrading the default values used for gravity, as internationally the globally accepted value is actually 9.80665 m⋅s−2, and not 9.81. This is more of a question for Newton sim, but I raise it here, as to whether the NewtonSceneAPI should consider using an actual number instead of the -INF value of USD.

doc = "NewtonSceneAPI applies on top of a PhysicsScene Prim, providing attributes to control a Newton Solver."
)
{
uniform int newton:maxSolverIterations = 100 (
Copy link
Member

Choose a reason for hiding this comment

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

  1. Regarding the question of default values:
    Does it make sense to use sentinel values (e.g. -1) by default to allow solvers to configure themselves according to their own defaults, that they set/define internally? This would avoid the question altogether, and then just allow the resolver/importer to set values only if set explicitly.

  2. On the matter of how some solvers actually require more than one maxiters, or a very special set:
    Why not treat this as scene attribute as optional, just like how in other parts of USD, e.g. not all physics backends realize certain types of friction models like static/dynamics, so it's up to the implementation to decide whether to use it or not. So in effect, I'm propose to have newton:solverMaxIterations, but use it only if-and-only-if it's set and supported.

As others mentioned above, if a solver requires it's own special configs, then their custom API could be the mechanism to facilitate it.

doc = "Maximum number of iterations of the physics solver"
)

uniform float newton:timeStep = 0.005 (
Copy link
Member

Choose a reason for hiding this comment

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

IMHO 1ms might be a more robust value for default time-step.

Within the context of in simulation and control, I have the impression 0.001 is considered a gold-standard, so it might pose a better and more sane default value.

It is also the default of Kamino, and was selected as such because of the aforedescribed rationale.

Copy link
Member

@vastsoun vastsoun left a comment

Choose a reason for hiding this comment

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

Overall LGTM, we can always come back with refinements to defaults at a later time. Probably building up the skeleton and mean is more important than the details.

@AlesBorovicka
Copy link

@andrewkaufman I've provided a few comments, and like the other reviewers, regarding the question of SceneAPI parameters and default values.

One other concern I have is regrading the default values used for gravity, as internationally the globally accepted value is actually 9.80665 m⋅s−2, and not 9.81. This is more of a question for Newton sim, but I raise it here, as to whether the NewtonSceneAPI should consider using an actual number instead of the -INF value of USD.

This is deliberate (-INF) and it should stay, you cant have a real value there, because USD by default can be in any units, not just meters. Hence many of the attributes use as a default value a sentinel value, where the value is computed based on the actual units.

@vastsoun
Copy link
Member

vastsoun commented Dec 3, 2025

@andrewkaufman I've provided a few comments, and like the other reviewers, regarding the question of SceneAPI parameters and default values.
One other concern I have is regrading the default values used for gravity, as internationally the globally accepted value is actually 9.80665 m⋅s−2, and not 9.81. This is more of a question for Newton sim, but I raise it here, as to whether the NewtonSceneAPI should consider using an actual number instead of the -INF value of USD.

This is deliberate (-INF) and it should stay, you cant have a real value there, because USD by default can be in any units, not just meters. Hence many of the attributes use as a default value a sentinel value, where the value is computed based on the actual units.

Oh, I wasn't aware. Thanks for the clarification @AlesBorovicka.

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.

6 participants