Skip to content

add explicit feedback for illegal operations in GPU mode #295

Open
fffffq00 wants to merge 1 commit into
haosulab:devfrom
fffffq00:dev
Open

add explicit feedback for illegal operations in GPU mode #295
fffffq00 wants to merge 1 commit into
haosulab:devfrom
fffffq00:dev

Conversation

@fffffq00

Copy link
Copy Markdown
Contributor

Hi @fbxiang, regarding the issue mentioned in #292, I've made a simple fix. Note that PhysX also disallows setting root properties in GPU mode, so I think throwing an error (instead of silent ignore) is the right approach here. I've tested it locally in both GPU and CPU modes, and everything runs fine. Please feel free to test it further or let me know any suggestions for improvement.

Copilot AI review requested due to automatic review settings June 15, 2026 16:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates PhysX articulation root getters/setters to behave more explicitly when running with the Direct GPU API, switching from commented-out exceptions to runtime warnings (getters) and hard errors (setters).

Changes:

  • Add GPU-simulation warnings for root pose and velocity getters that may return unsynchronized CPU data.
  • Add GPU-simulation runtime errors for root pose and velocity setters to prevent illegal writes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +362 to +364
if (getRoot()->isUsingDirectGPUAPI()) {
logger::warn("getting root pose may yields unsynchronized CPU data in GPU simulation.");
}
Comment on lines +381 to +383
if (getRoot()->isUsingDirectGPUAPI()) {
throw std::runtime_error("setting root pose is illegal in GPU simulation.");
}
Comment on lines +388 to +390
if (getRoot()->isUsingDirectGPUAPI()) {
throw std::runtime_error("setting root linear velocity is illegal in GPU simulation.");
}
Comment on lines +394 to +396
if (getRoot()->isUsingDirectGPUAPI()) {
throw std::runtime_error("setting root angular velocity is illegal in GPU simulation.");
}
Comment on lines +362 to +364
if (getRoot()->isUsingDirectGPUAPI()) {
logger::warn("getting root pose may yields unsynchronized CPU data in GPU simulation.");
}
Comment on lines +368 to +370
if (getRoot()->isUsingDirectGPUAPI()) {
logger::warn("getting root linear velocity may yield unsynchronized CPU data in GPU simulation.");
}
Comment on lines +374 to +376
if (getRoot()->isUsingDirectGPUAPI()) {
logger::warn("getting root angular velocity may yield unsynchronized CPU data in GPU simulation.");
}
Comment on lines +381 to +383
if (getRoot()->isUsingDirectGPUAPI()) {
throw std::runtime_error("setting root pose is illegal in GPU simulation.");
}
Comment on lines +388 to +390
if (getRoot()->isUsingDirectGPUAPI()) {
throw std::runtime_error("setting root linear velocity is illegal in GPU simulation.");
}
Comment on lines +394 to +396
if (getRoot()->isUsingDirectGPUAPI()) {
throw std::runtime_error("setting root angular velocity is illegal in GPU simulation.");
}
@fbxiang

fbxiang commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

I think your fix is correct and reasonable, but to avoid breaking existing code, we probably should log an error for the set methods as well.

Set could also be valid if the entity has not been added to scene or physics has not been initialized. I will look into a more comprehensive fix but for now logging is probably enough.

@fffffq00

Copy link
Copy Markdown
Contributor Author

Ah I see, but isUsingDirectGPUAPI() already checks getScene() — so if the entity hasn't been added to scene, it returns false and won't throw. Or am I missing something? Anyway, I can switch to logging for safety. Thanks!

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.

3 participants