execute_script
Execute arbitrary Python code in Isaac Sim for operations not covered by named tools. Stop a running simulation before modifying articulations; read-only diagnostics remain safe.
Instructions
Escape hatch: execute arbitrary Python code in Isaac Sim.
PREFER named tools over this for: reading/setting joints (set_joint_positions, get_joint_positions), inspecting state (get_prim_info, get_physics_state, get_joint_config), stepping simulation (step_simulation), and checking logs (get_isaac_logs).
USE this only for a trusted operation that no named tool covers. Execution is policy-gated, cooperatively timed, output-bounded, cwd-restricted, and audited by code hash. Background scheduling is denied unless both the request and administrator policy explicitly opt in.
CAUTION: touching an articulation controlled by a running ScriptNode / Action Graph can silently break its control path (no error is raised). While a graph is running, read-only diagnostics (get_prim_info, get_physics_state, get_joint_positions, get_isaac_logs) are safe, but stop_simulation before using execute_script or named write tools on the same articulation.
For persistent controllers (>20 lines), write a .py file and load it with reload_script instead of pasting code here.
Args: code: Python code to execute in the Isaac Sim context. cwd: Optional working directory to add to sys.path before execution. timeout_s: Cooperative Python deadline; capped by extension policy. max_output_bytes: Combined per-stream capture limit; capped by policy. allow_background: Request background scheduling. Default false and rejected unless the extension policy also enables it.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | No | ||
| code | Yes | ||
| timeout_s | No | ||
| command_id | No | ||
| idempotency_key | No | ||
| allow_background | No | ||
| max_output_bytes | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |