PhysicsManager#
Fully qualified name: isaacsim::physics::manager::PhysicsManager
-
class PhysicsManager#
Singleton that manages physics simulations.
Public Functions
-
PhysicsManager(const PhysicsManager&) = delete#
-
PhysicsManager &operator=(const PhysicsManager&) = delete#
-
bool isInitialized() const#
Reports whether the physics manager is initialized.
- Returns:
True if the physics manager is initialized, false otherwise.
-
void configure(float deltaTime = 1.0f / 60.0f)#
Configures the simulation.
- Parameters:
deltaTime – [in] Physics time step in seconds (default 1/60 s).
-
bool initialize(void *ovstageInstance, int64_t usdStageId)#
Attaches a USD stage to all active physics simulations.
Broadcasts the stage to every active backend. If any backend fails, previously succeeded backends are rolled back before returning.
- Parameters:
ovstageInstance – [in] Pointer to the caller-owned ovstage instance, or
nullptr.usdStageId – [in] USD stage-cache identifier of the stage to attach.
- Returns:
True if every active backend attached the stage successfully, false otherwise.
-
bool invalidate()#
Closes all attached stages and marks the manager as uninitialized.
Delegates to the underlying engine close call and propagates its result. If the engine close call returns
false, one or more engines failed to detach and the manager remains in the initialized state so the caller can retry. The caller must keep any stage pointer alive until this method returnstrue.- Returns:
trueif every engine closed successfully;falseif an engine reported a close failure.
- int step(
- int stepCount = 1,
- std::function<bool(int, int)> callback = nullptr,
Steps the physics simulation one or more times.
Each iteration calls
simulate()andfetchResults()on the underlying physics engine, then invokes the optional callback. If the callback returns false the loop exits early.- Parameters:
stepCount – [in] Number of physics steps to perform (default 1).
callback – [in] Callback called after each step as callback(currentStep, stepCount). Return false to stop stepping early.
- Throws:
std::runtime_error – if the manager has not been initialized via initialize().
- Returns:
Number of steps actually simulated.
-
bool publishTransformsToStage()#
Publishes the latest simulated transforms to the attached stage.
- Throws:
std::runtime_error – if the manager has not been initialized via initialize().
- Returns:
trueif the active physics backend published successfully; otherwise,false.
-
float getSimulatedTime() const#
Gets the accumulated simulation time.
- Returns:
Simulation time in seconds since the last initialize() call.
-
int getSimulatedPhysicsStepCount() const#
Gets the physics-step count since the last initialize() call.
- Returns:
Physics-step count.
- size_t registerCallback(
- SimulationEventFunction callback,
- PhysicsEvent event,
- int order = 0,
Registers a callback to be triggered when a specific simulation event occurs.
The callback is invoked with a dictionary populated with the event payload.
For PhysicsEvent::ePhysicsPreStep and PhysicsEvent::ePhysicsPostStep events:
”elapsed_time” (float): elapsed time since the previous physics step.
”scene_path” (size_t): USD scene path encoded as size_t.
”simulation_id” (size_t): identifier of the simulation that produced the event.
- Parameters:
callback – [in] Callback invoked with the event payload dictionary.
event – [in] Event to subscribe to.
order – [in] Subscription order. Lower values run earlier; callbacks within the same order are triggered in registration order.
- Returns:
Unique callback identifier on success, or 0 if the event is unsupported, the physics simulation is unavailable, or the subscription failed.
-
bool deregisterCallback(size_t callbackId) noexcept#
Deregisters a callback.
- Parameters:
callbackId – [in] Callback identifier.
- Returns:
True if the callback was deregistered, false if the identifier is invalid.
-
void deregisterAllCallbacks() noexcept#
Deregisters every callback previously registered via registerCallback().
Unsubscribes each tracked physics subscription and clears the internal callback map. Identifiers issued in the future continue to be strictly increasing; previously issued identifiers are not reused.
- std::vector<std::pair<std::string, bool>> getRegisteredPhysicsEngines(
Gets all registered physics engines and their active state.
- Returns:
Vector of (engine, isActive).
-
bool switchPhysicsEngine(const std::string &engine)#
Switches to a specific physics engine.
The requested engine name is matched case-insensitively. All other active engines are deactivated before activating the target engine.
- Parameters:
engine – [in] Target engine name.
- Returns:
True if the target engine exists and switch logic ran; false otherwise.
- std::shared_ptr<isaacsim::physics::tensors::IEntityView> createEntity(
- const std::string &engine,
- const std::string &entityType,
- const std::variant<std::string, std::vector<std::string>> &primPathPatterns,
- const std::optional<isaacsim::physics::tensors::EntityOptions> &options = std::nullopt,
Creates a physics tensor entity.
- Parameters:
engine – [in] Target engine name.
entityType – [in] Type of the entity to create.
primPathPatterns – [in] Prim-path patterns or explicit prim paths to include.
options – [in] Engine-defined construction arguments, such as a contact view’s filters, or
std::nulloptto use the engine’s defaults. Each engine documents the option names it reads and ignores the rest.
- Returns:
Shared pointer to the entity view.
Public Static Functions
-
static PhysicsManager &getInstance()#
Gets the singleton instance.
- Returns:
Singleton instance.
-
PhysicsManager(const PhysicsManager&) = delete#